From 91a7da087b6ee6cbe2815a9cdcdf7864daa7f72f Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 29 Sep 2020 14:33:06 -0700 Subject: [PATCH] Refactor: Make NativeModuleArrayTypeAnnotation elementType customizable Summary: In the future, we'll use `NativeModuleArrayTypeAnnotation` inside JS struct objects. Structs cannot contain `ObjectTypeAnnotations` anywhere. Therefore, we need the elementType of `NativeModuuleArrayTypeAnnotation`'s elementType customizable. Changelog: [Internal] Reviewed By: hramos Differential Revision: D23645210 fbshipit-source-id: 97abb993d59536ebd68ec08b18ce7f2801c68a2d --- packages/react-native-codegen/src/CodegenSchema.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index a2b3d54d5ed..7e35b52207a 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -306,13 +306,15 @@ export type NativeModuleObjectTypeAnnotation = $ReadOnly<{| nullable: boolean, |}>; -export type NativeModuleArrayTypeAnnotation = $ReadOnly<{| +export type NativeModuleArrayTypeAnnotation< + T = NativeModuleBaseTypeAnnotation, +> = $ReadOnly<{| type: 'ArrayTypeAnnotation', /** * TODO(T72031674): Migrate all our NativeModule specs to not use * invalid Array ElementTypes. Then, make the elementType required. */ - elementType?: NativeModuleBaseTypeAnnotation, + elementType?: T, nullable: boolean, |}>; @@ -383,7 +385,7 @@ export type NativeModuleBaseTypeAnnotation = | NativeModuleGenericObjectTypeAnnotation | NativeModuleReservedFunctionValueTypeAnnotation | NativeModuleTypeAliasTypeAnnotation - | NativeModuleArrayTypeAnnotation + | NativeModuleArrayTypeAnnotation<> | NativeModuleObjectTypeAnnotation; export type NativeModuleParamTypeAnnotation =