react-native-bottom-sheet
react-native-bottom-sheet copied to clipboard
[v4] wrong data prop type-def --> BottomSheetFlatList type-def incompatible with union types
Bug
Typescript ERROR:
index.d.ts(3966, 5): The expected type comes from property 'data' which is declared here on type 'IntrinsicAttributes & Omit<AnimateProps<FlatListProps<A[] | B[]>>, "decelerationRate" | "onScroll" | "scrollEventThrottle"> & ... 5 more ... & RefAttributes<...>'
(property) data: ((readonly (A[] | B[])[] | AnimatedNode<readonly (A[] | B[])[] | null | undefined>) & readonly any[]) | null | undefined
Type 'A[] | B[]' is not assignable to type '((readonly (A[] | B[])[] | AnimatedNode<readonly (A[] | B[])[] | null | undefined>) & readonly any[]) | null | undefined'.
Type 'A[]' is not assignable to type '((readonly (A[] | B[])[] | AnimatedNode<readonly (A[] | B[])[] | null | undefined>) & readonly any[]) | null | undefined'.
Type 'A[]' is not assignable to type 'AnimatedNode<readonly (A[] | B[])[] | null | undefined> & readonly any[]'.
Type 'A[]' is missing the following properties from type 'AnimatedNode<readonly (A[] | B[])[] | null | undefined>': isNativelyInitialized, ' __value'ts(2322)

Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | 4.3.2 |
react-native | 0.68.2 |
Steps To Reproduce
-
const arrayA: A[] = [0] ; const arrayB: B[] = [1]
(==> example just for show) - Have some union-type property
const dataResult = someVar ? arrayA : arrayB
( ==>dataResult: A[] | B[]
) - Assign union-type variable to data property of FlatList (and assign union-type also to renderItem) -->
<FlatList
data={dataResult}
renderItem={({ item }: { item: A[] | B[] }): JSX.Element => {
return (
Describe what you expected to happen:
No typescript error, like the native (react) FlatList type.
Reproducible sample code
code above
@ThaBrad: hello! :wave:
This issue is being automatically closed because it does not follow the issue template.
Yes data={dataResult as any}
solves this, but why should this libs type differ from the working native implementation?! 🤔
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Should be be simple copy & paste-ing the Typescript types from the native BottomSheet implementation, no?!
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.