Skip to content

Commit

Permalink
Fix bad utility type definitions (#37662)
Browse files Browse the repository at this point in the history
Reviewed By: panagosg7

Differential Revision: D46364595

fbshipit-source-id: 5dcd484cd292d5b83b0b114675ec3c8059aefe6b
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Jun 1, 2023
1 parent d9b3339 commit 0191d16
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
42 changes: 22 additions & 20 deletions packages/react-native-codegen/src/CodegenSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,27 @@ export type EventTypeAnnotation =
elementType: EventTypeAnnotation,
}>;

export type ArrayTypeAnnotation = $ReadOnly<{
type: 'ArrayTypeAnnotation',
elementType:
| BooleanTypeAnnotation
| StringTypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
| Int32TypeAnnotation
| $ReadOnly<{
type: 'StringEnumTypeAnnotation',
default: string,
options: $ReadOnlyArray<string>,
}>
| ObjectTypeAnnotation<PropTypeAnnotation>
| ReservedPropTypeAnnotation
| $ReadOnly<{
type: 'ArrayTypeAnnotation',
elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
}>,
}>;

export type PropTypeAnnotation =
| $ReadOnly<{
type: 'BooleanTypeAnnotation',
Expand Down Expand Up @@ -167,26 +188,7 @@ export type PropTypeAnnotation =
}>
| ReservedPropTypeAnnotation
| ObjectTypeAnnotation<PropTypeAnnotation>
| $ReadOnly<{
type: 'ArrayTypeAnnotation',
elementType:
| BooleanTypeAnnotation
| StringTypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
| Int32TypeAnnotation
| $ReadOnly<{
type: 'StringEnumTypeAnnotation',
default: string,
options: $ReadOnlyArray<string>,
}>
| ObjectTypeAnnotation<PropTypeAnnotation>
| ReservedPropTypeAnnotation
| $ReadOnly<{
type: 'ArrayTypeAnnotation',
elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
}>,
}>
| ArrayTypeAnnotation
| MixedTypeAnnotation;

export type ReservedPropTypeAnnotation = $ReadOnly<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
Int32TypeAnnotation,
PropTypeAnnotation,
MixedTypeAnnotation,
ArrayTypeAnnotation,
} from '../../../CodegenSchema';

const {capitalize} = require('../../Utils');
Expand Down Expand Up @@ -110,11 +111,8 @@ class PojoCollector {
}
case 'ArrayTypeAnnotation': {
const arrayTypeAnnotation = typeAnnotation;
// TODO: Flow assumes elementType can be any. Fix this.
const elementType: $PropertyType<
typeof arrayTypeAnnotation,
'elementType',
> = arrayTypeAnnotation.elementType;
const elementType: $PropertyType<ArrayTypeAnnotation, 'elementType'> =
arrayTypeAnnotation.elementType;

const pojoElementType = (() => {
switch (elementType.type) {
Expand Down

0 comments on commit 0191d16

Please sign in to comment.