react-native-swiper-flatlist
react-native-swiper-flatlist copied to clipboard
tsc fails because of SwiperFlatList.tsx file
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Running tsc in the project causes this type issue
node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx:238:7 - error TS2322: Type 'RefObject<FlatList<unknown> | null>' is not assignable to type 'RefObject<FlatList<unknown>>'.
Type 'FlatList<unknown> | null' is not assignable to type 'FlatList<unknown>'.
Type 'null' is not assignable to type 'FlatList<unknown>'.
238 ref: flatListElement,
~~~
node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx:236:53
236 const flatListProps: FlatListProps<unknown> & { ref: React.RefObject<RNFlatList<unknown>> } = {
~~~
The expected type comes from property 'ref' which is declared here on type 'FlatListProps<unknown> & { ref: RefObject<FlatList<unknown>>; }'
Found 1 error in node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx:238
Here is my ts config
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"baseUrl": ".",
"paths": {
"~/*": ["src/*"],
"~~/*": ["./*"],
}
},
"exclude": [
"node_modules",
"**/Pods"
],
"include": [
"**/*.ts",
"**/*.tsx"
]
}
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx b/node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx
index 9f6aaf0..fcdafe3 100644
--- a/node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx
+++ b/node_modules/react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatList.tsx
@@ -235,6 +235,7 @@ export const SwiperFlatList = React.forwardRef(
const flatListProps: FlatListProps<unknown> & { ref: React.RefObject<RNFlatList<unknown>> } = {
scrollEnabled,
+ // @ts-ignore
ref: flatListElement,
keyExtractor: (_item, _index) => {
const item = _item as { key?: string; id?: string };
This issue body was partially generated by patch-package.