Skip to content

Commit 404c091

Browse files
authored
Keep the pointerEvents ts-expect-error in emitted spec declarations (#4601)
## Description The three codegen specs redeclare `pointerEvents` as `WithDefault<..., 'auto'>`, which codegen requires. `WithDefault` adds `null`, so the interface no longer satisfies `ViewProps.pointerEvents`, and the source suppresses that with a `// @ts-expect-error` (or `// @ts-ignore`) line. Declaration emit drops line comments, so the published `lib/typescript/specs/*.d.ts` carry a bare TS2430. Any consumer with `skipLibCheck: false` fails to type-check: error TS2430: Interface 'NativeProps' incorrectly extends interface 'ViewProps'. Types of property 'pointerEvents' are incompatible. This turns the directives into `/** */` block comments. TypeScript honours directives in block comments, and JSDoc survives declaration emit, so the suppression now ships with the types. Codegen can't do this itself: `extends Omit<ViewProps, 'pointerEvents'>` fails with "Unable to handle prop spread: Omit" and dropping `WithDefault` fails with "A default enum value is required". ## Test plan - `yarn ts-check` and `yarn lint:js` in the package - Codegen schema (`combine-js-to-schema-cli`, iOS and Android) identical before and after - `yarn build`, then installed the packed tarball into a fresh RN 0.87 app with `skipLibCheck: false`: the two RNGH TS2430 errors are gone, only RN's own typing errors remain - Same check against RN 0.88 declarations
1 parent fe86f59 commit 404c091

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type ButtonEvent = Readonly<{
1111
pointerType: CodegenTypes.Int32;
1212
}>;
1313

14-
// @ts-ignore - Redefining pointerEvents with WithDefault for codegen, conflicts with ViewProps type but codegen needs it
14+
/** @ts-ignore - Redefining pointerEvents with WithDefault for codegen, conflicts with ViewProps type but codegen needs it */
1515
interface NativeProps extends ViewProps {
1616
// The events are namespaced with `Button` because the base view config on iOS
1717
// already registers `topPress` as a bubbling event — a direct event with the

‎packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface VirtualChildrenProps {
4141
viewTag: CodegenTypes.Int32;
4242
}
4343

44-
// @ts-expect-error WithDefault adds `| null` to the type, which doesn't align with ViewProps.pointerEvents
44+
/** @ts-expect-error WithDefault adds `| null` to the type, which doesn't align with ViewProps.pointerEvents */
4545
// Using Exclude to remove null from the type makes the error go away, but breaks codegen.
4646
export interface NativeProps extends ViewProps {
4747
onGestureHandlerEvent?:

‎packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface RootViewNativeProps extends ViewProps {
66
unstable_forceActive?: boolean;
77
}
88

9-
// @ts-expect-error WithDefault adds null for codegen, unlike ViewProps.pointerEvents.
9+
/** @ts-expect-error WithDefault adds null for codegen, unlike ViewProps.pointerEvents. */
1010
interface NativeProps extends ViewProps {
1111
pointerEvents?: CodegenTypes.WithDefault<
1212
'box-none' | 'none' | 'box-only' | 'auto',

0 commit comments

Comments
 (0)