diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 56149dcad59..90043816eeb 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -265,14 +265,15 @@ export type ReservedTypeAnnotation = Readonly<{ /** * NativeModule Types */ -export type Nullable<+T: NativeModuleTypeAnnotation> = +export type Nullable<+T extends NativeModuleTypeAnnotation> = | NullableTypeAnnotation | T; -export type NullableTypeAnnotation<+T: NativeModuleTypeAnnotation> = Readonly<{ - type: 'NullableTypeAnnotation', - typeAnnotation: T, -}>; +export type NullableTypeAnnotation<+T extends NativeModuleTypeAnnotation> = + Readonly<{ + type: 'NullableTypeAnnotation', + typeAnnotation: T, + }>; export type NativeModuleSchema = Readonly<{ type: 'NativeModule', @@ -316,7 +317,7 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation< >; export type NativeModuleArrayTypeAnnotation< - +T: Nullable, + +T extends Nullable, > = ArrayTypeAnnotation< | T /** diff --git a/packages/react-native-codegen/src/parsers/parsers-commons.js b/packages/react-native-codegen/src/parsers/parsers-commons.js index 3f22512348e..4c35842bb98 100644 --- a/packages/react-native-codegen/src/parsers/parsers-commons.js +++ b/packages/react-native-codegen/src/parsers/parsers-commons.js @@ -107,7 +107,7 @@ function wrapModuleSchema( } // $FlowFixMe[unsupported-variance-annotation] -function unwrapNullable<+T: NativeModuleTypeAnnotation>( +function unwrapNullable<+T extends NativeModuleTypeAnnotation>( x: Nullable, ): [T, boolean] { if (x.type === 'NullableTypeAnnotation') { @@ -118,7 +118,7 @@ function unwrapNullable<+T: NativeModuleTypeAnnotation>( } // $FlowFixMe[unsupported-variance-annotation] -function wrapNullable<+T: NativeModuleTypeAnnotation>( +function wrapNullable<+T extends NativeModuleTypeAnnotation>( nullable: boolean, typeAnnotation: T, ): Nullable {