11import React , {
22 PropsWithChildren ,
3- ForwardedRef ,
4- RefAttributes ,
53 ReactElement ,
64 useRef ,
75 useImperativeHandle ,
86 useState ,
7+ RefObject ,
98} from 'react' ;
109import {
1110 ScrollView as RNScrollView ,
@@ -111,9 +110,9 @@ export const TextInput = createNativeWrapper<RNTextInputProps>(RNTextInput);
111110// eslint-disable-next-line @typescript-eslint/no-redeclare
112111export type TextInput = typeof TextInput & RNTextInput ;
113112
114- type ImperativeFlatListRef =
113+ export type ImperativeFlatListRef < T = any > =
115114 | ( ComponentWrapperRef < RNScrollViewProps > & {
116- flatListRef : React . RefObject < FlatList < unknown > > ;
115+ flatListRef : FlatList < T > | null ;
117116 } )
118117 | null ;
119118
@@ -125,7 +124,7 @@ export const FlatList = ((props) => {
125124 ) ;
126125
127126 const wrapperRef = useRef < ImperativeScrollViewRef > ( null ) ;
128- const flatListRef = useRef < FlatList < unknown > > ( null ) ;
127+ const flatListRef = useRef < FlatList < any > > ( null ) ;
129128
130129 const flatListProps = { } ;
131130 const scrollViewProps = { } ;
@@ -185,11 +184,11 @@ export const FlatList = ((props) => {
185184 ) ;
186185} ) as < ItemT = any > (
187186 props : PropsWithChildren <
188- Omit < RNFlatListProps < ItemT > , 'renderScrollComponent' > &
189- RefAttributes < FlatList < ItemT > > &
190- NativeWrapperProperties
191- > ,
192- ref ?: ForwardedRef < FlatList < ItemT > >
187+ Omit < RNFlatListProps < ItemT > , 'renderScrollComponent' | 'ref' > &
188+ NativeWrapperProperties & {
189+ ref ?: RefObject < ImperativeFlatListRef < ItemT > > ;
190+ }
191+ >
193192) => ReactElement | null ;
194193// eslint-disable-next-line @typescript-eslint/no-redeclare
195194export type FlatList < ItemT = any > = typeof FlatList & RNFlatList < ItemT > ;
0 commit comments