diff --git a/Libraries/Lists/FlatList.d.ts b/Libraries/Lists/FlatList.d.ts index f4958fe93610e1..8676fb4d28b4f8 100644 --- a/Libraries/Lists/FlatList.d.ts +++ b/Libraries/Lists/FlatList.d.ts @@ -66,7 +66,7 @@ export interface FlatListProps extends VirtualizedListProps { */ getItemLayout?: | (( - data: Array | null | undefined, + data: ArrayLike | null | undefined, index: number, ) => {length: number; offset: number; index: number}) | undefined; diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 90ddc9acf1ba26..573e5223a9308e 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -91,7 +91,7 @@ type OptionalProps = {| * specify `ItemSeparatorComponent`. */ getItemLayout?: ( - data: ?Array, + data: ?$ArrayLike, index: number, ) => { length: number, diff --git a/types/__typetests__/index.tsx b/types/__typetests__/index.tsx index 070a59abe2cc45..848a7b5239dfd2 100644 --- a/types/__typetests__/index.tsx +++ b/types/__typetests__/index.tsx @@ -705,6 +705,21 @@ export class FlatListTest extends React.Component, {}> { } } + | null | undefined, + index: number, + ) => { + return { + length: data![index] % 2 === 0 ? 10 : 5, + offset: 1234, + index, + }; + }} +/>; + export class SectionListTest extends React.Component< SectionListProps, {}