mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix bad utility type definitions (#37662)
Reviewed By: panagosg7 Differential Revision: D46364595 fbshipit-source-id: 5dcd484cd292d5b83b0b114675ec3c8059aefe6b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d9b3339ef8
commit
0191d16712
+22
-20
@@ -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<{
|
||||
|
||||
Vendored
+3
-5
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user