From 4f0bd0ee934ae62c319a637d374454a64ac1e2be Mon Sep 17 00:00:00 2001 From: Marco Wang Date: Tue, 10 Mar 2026 18:03:55 -0700 Subject: [PATCH] Codemod : to extends to a few react-native-github package (#56025) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56025 Flow is migrating from colon style type parameter bound to `extends` Changelog:[internal] Reviewed By: SamChou19815 Differential Revision: D95867062 fbshipit-source-id: 201483bcbae9b628c8fbd9ffda70d8adfa3a2dc6 --- packages/react-native-codegen/src/CodegenSchema.js | 13 +++++++------ .../src/parsers/parsers-commons.js | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) 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 {