Fix bad utility type definitions (#37662)

Reviewed By: panagosg7

Differential Revision: D46364595

fbshipit-source-id: 5dcd484cd292d5b83b0b114675ec3c8059aefe6b
This commit is contained in:
Sam Zhou
2023-06-01 14:41:00 -07:00
committed by Facebook GitHub Bot
parent d9b3339ef8
commit 0191d16712
2 changed files with 25 additions and 25 deletions
+22 -20
View File
@@ -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',
@@ -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<{
@@ -21,6 +21,7 @@ import type {
Int32TypeAnnotation,
PropTypeAnnotation,
MixedTypeAnnotation,
ArrayTypeAnnotation,
} from '../../../CodegenSchema';
const {capitalize} = require('../../Utils');
@@ -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) {