// @flow import * as React from 'react'; import { FixedSizeList, VariableSizeList, FixedSizeGrid, VariableSizeGrid, } from './'; type ItemData = {| num: number, str: string, |}; const assertVoid = (value: void) => {}; const assertEmpty = (value: empty) => {}; const assertNumber = (value: number) => {}; const assertString = (value: string) => {}; const assertCustomType = (value: ItemData) => {}; /* FixedSizeList */ { const Item = ({ index, style }) => { (index: number); (style: Object); return null; }; {Item} ; } { const Item = ({ data }) => { assertNumber(data); // $FlowFixMe number is passed to FixedSizeList assertString(data); return null; }; const itemKey = (index, data) => { assertNumber(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } { const Item = ({ data }) => { assertCustomType(data); // $FlowFixMe ItemData is passed to FixedSizeList assertString(data); return null; }; const itemKey = (index, data) => { assertCustomType(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } { const Item = ({ data }) => { assertVoid(data); // $FlowFixMe itemData is undefined by default assertEmpty(data); return null; }; const itemKey = (index, data) => { assertVoid(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } /* VariableSizeList */ { const Item = ({ data }) => { assertNumber(data); // $FlowFixMe number is passed to VariableSizeList assertString(data); return null; }; const itemKey = (index, data) => { assertNumber(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } { const Item = ({ data }) => { assertCustomType(data); // $FlowFixMe ItemData is passed to VariableSizeList assertString(data); return null; }; const itemKey = (index, data) => { assertCustomType(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } { const Item = ({ data }) => { assertVoid(data); // $FlowFixMe itemData is undefined by default assertEmpty(data); return null; }; const itemKey = (index, data) => { assertVoid(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } { class Item extends React.PureComponent<{ data: void }> { render() { const { data } = this.props; assertVoid(data); // $FlowFixMe itemData is undefined by default assertEmpty(data); return null; } } const itemKey = (index, data) => { assertVoid(data); // $FlowFixMe expected assertString(data); return index; }; {Item} ; } /* FixedSizeGrid */ { const Item = ({ columnIndex, rowIndex, style }) => { (columnIndex: number); (rowIndex: number); (style: Object); return null; }; {Item} ; } { const Item = ({ data }) => { assertNumber(data); // $FlowFixMe number is passed to FixedSizeGrid assertString(data); return null; }; const itemKey = ({ columnIndex, data, rowIndex }) => { assertNumber(data); // $FlowFixMe expected assertString(data); return `${columnIndex}:${rowIndex}`; }; {Item} ; } { const Item = ({ data }) => { assertCustomType(data); // $FlowFixMe ItemData is passed to FixedSizeGrid assertString(data); return null; }; const itemKey = ({ columnIndex, data, rowIndex }) => { assertCustomType(data); // $FlowFixMe expected assertString(data); return `${columnIndex}:${rowIndex}`; }; {Item} ; } { const Item = ({ data }) => { assertVoid(data); // $FlowFixMe itemData is undefined by default assertEmpty(data); return null; }; const itemKey = ({ columnIndex, data, rowIndex }) => { assertVoid(data); // $FlowFixMe expected assertString(data); return `${columnIndex}:${rowIndex}`; }; {Item} ; } /* VariableSizeGrid */ { const Item = ({ data }) => { assertNumber(data); // $FlowFixMe number is passed to VariableSizeGrid assertString(data); return null; }; {Item} ; } { const Item = ({ data }) => { assertCustomType(data); // $FlowFixMe ItemData is passed to VariableSizeGrid assertString(data); return null; }; {Item} ; } { const Item = ({ data }) => { assertVoid(data); // $FlowFixMe itemData is undefined by default assertEmpty(data); return null; }; {Item} ; } { class Item extends React.PureComponent<{ data: void }> { render() { const { data } = this.props; assertVoid(data); // $FlowFixMe itemData is undefined by default assertEmpty(data); return null; } } {Item} ; }