Skip to content

Commit 3cd11c2

Browse files
Flow Parser Changes (facebook#54597)
Summary: Flow Parser changes to accomodate the new emitUnion Changelog: [Internal] Differential Revision: D87412532
1 parent b814347 commit 3cd11c2

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

packages/react-native-codegen/src/parsers/flow/components/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function extractArrayElementType(
115115
};
116116
case 'UnionTypeAnnotation':
117117
return {
118-
type: 'StringLiteralUnionTypeAnnotation',
118+
type: 'UnionTypeAnnotation',
119119
types: typeAnnotation.types.map(option => ({
120120
type: 'StringLiteralTypeAnnotation',
121121
value: parser.getLiteralValue(option),

packages/react-native-codegen/src/parsers/flow/modules/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,18 @@ function translateTypeAnnotation(
244244
);
245245
}
246246
case 'UnionTypeAnnotation': {
247-
return emitUnion(nullable, hasteModuleName, typeAnnotation, parser);
247+
return emitUnion(
248+
nullable,
249+
hasteModuleName,
250+
typeAnnotation,
251+
types,
252+
aliasMap,
253+
enumMap,
254+
tryParse,
255+
cxxOnly,
256+
translateTypeAnnotation,
257+
parser,
258+
);
248259
}
249260
case 'NumberLiteralTypeAnnotation': {
250261
return emitNumberLiteral(nullable, typeAnnotation.value);

packages/react-native-codegen/src/parsers/flow/parser.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import type {
1818
NativeModuleEnumMember,
1919
NativeModuleEnumMemberType,
2020
NativeModuleParamTypeAnnotation,
21+
NativeModuleUnionTypeAnnotationMemberType,
2122
Nullable,
2223
PropTypeAnnotation,
2324
SchemaType,
24-
UnionTypeAnnotationMemberType,
2525
} from '../../CodegenSchema';
2626
import type {ParserType} from '../errors';
2727
import type {
@@ -111,7 +111,7 @@ class FlowParser implements Parser {
111111

112112
remapUnionTypeAnnotationMemberNames(
113113
membersTypes: $FlowFixMe[],
114-
): UnionTypeAnnotationMemberType[] {
114+
): NativeModuleUnionTypeAnnotationMemberType[] {
115115
const remapLiteral = (item: $FlowFixMe) => {
116116
return item.type
117117
.replace('NumberLiteralTypeAnnotation', 'NumberTypeAnnotation')
@@ -121,12 +121,6 @@ class FlowParser implements Parser {
121121
return [...new Set(membersTypes.map(remapLiteral))];
122122
}
123123

124-
getStringLiteralUnionTypeAnnotationStringLiterals(
125-
membersTypes: $FlowFixMe[],
126-
): string[] {
127-
return membersTypes.map((item: $FlowFixMe) => item.value);
128-
}
129-
130124
parseFile(filename: string): SchemaType {
131125
const contents = fs.readFileSync(filename, 'utf8');
132126

0 commit comments

Comments
 (0)