-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update types to respect Strict TS API #4319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,15 +47,16 @@ const GHScrollView = createNativeWrapper<PropsWithChildren<RNScrollViewProps>>( | |
| export const LegacyScrollView = ( | ||
| props: RNScrollViewProps & | ||
| NativeViewGestureHandlerProps & { | ||
| ref?: React.Ref<RNScrollView | null>; | ||
| ref?: React.Ref<React.ComponentRef<typeof RNScrollView> | null>; | ||
| } | ||
| ) => { | ||
| const refreshControlGestureRef = React.useRef<LegacyRefreshControl>(null); | ||
| const { refreshControl, waitFor, ...rest } = props; | ||
| const { refreshControl, waitFor, ref, ...rest } = props; | ||
|
|
||
| return ( | ||
| <GHScrollView | ||
| {...rest} | ||
| ref={ref as React.Ref<React.ComponentType<any> | null>} | ||
| waitFor={[...toArray(waitFor ?? []), refreshControlGestureRef]} | ||
| // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref | ||
| refreshControl={ | ||
|
|
@@ -73,7 +74,8 @@ export const LegacyScrollView = ( | |
| // Backward type compatibility with https://github.com/software-mansion/react-native-gesture-handler/blob/db78d3ca7d48e8ba57482d3fe9b0a15aa79d9932/react-native-gesture-handler.d.ts#L440-L457 | ||
| // include methods of wrapped components by creating an intersection type with the RN component instead of duplicating them. | ||
| // eslint-disable-next-line @typescript-eslint/no-redeclare | ||
| export type LegacyScrollView = typeof GHScrollView & RNScrollView; | ||
| export type LegacyScrollView = typeof GHScrollView & | ||
| React.ComponentRef<typeof RNScrollView>; | ||
|
Comment on lines
+77
to
+78
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this give the same result?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and no.On the Strict TS API they differ: RNScrollView is a function-component type with no instance methods, so & RNScrollView silently stops contributing the very instance methods (scrollTo, scrollToEnd, …) this intersection exists to expose |
||
|
|
||
| /** | ||
| * @deprecated use `Switch` instead | ||
|
|
@@ -97,9 +99,12 @@ export type LegacyTextInput = typeof LegacyTextInput & RNTextInput; | |
| /** | ||
| * @deprecated use `DrawerLayoutAndroid` instead | ||
| */ | ||
| export const LegacyDrawerLayoutAndroid = createNativeWrapper< | ||
| PropsWithChildren<RNDrawerLayoutAndroidProps> | ||
| >(RNDrawerLayoutAndroid, { disallowInterruption: true }); | ||
| export const LegacyDrawerLayoutAndroid: React.ComponentType< | ||
| PropsWithChildren<RNDrawerLayoutAndroidProps> & NativeViewGestureHandlerProps | ||
| > = createNativeWrapper<PropsWithChildren<RNDrawerLayoutAndroidProps>>( | ||
| RNDrawerLayoutAndroid, | ||
| { disallowInterruption: true } | ||
| ); | ||
| // eslint-disable-next-line @typescript-eslint/no-redeclare | ||
| export type LegacyDrawerLayoutAndroid = typeof LegacyDrawerLayoutAndroid & | ||
| RNDrawerLayoutAndroid; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.