Skip to content

Commit cf8184d

Browse files
Shubham-TJfacebook-github-bot
authored andcommitted
refactor(codegen): add undefinedLiteralTypeAnnotation prop in parsers (#37450)
Summary: part of codegen issue #34872 > Add an undefinedLiteralTypeAnnotation: string property into the Parser object and implement it in the FlowParser (returning VoidLiteralTypeAnnotation) and in the TypeScriptPArser(returning TSUndefinedKeyword). Replace them in and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L158). bypass-github-export-checks ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal][Added]: Add undefinedLiteralTypeAnnotation property in parsers Pull Request resolved: #37450 Test Plan: yarn test Reviewed By: dmytrorykun Differential Revision: D45904567 Pulled By: cipolleschi fbshipit-source-id: edd26198e4c8b191a473d5b0ff96a6dc1fec8576
1 parent fc927d1 commit cf8184d

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class FlowParser implements Parser {
7373
enumDeclaration: string = 'EnumDeclaration';
7474
interfaceDeclaration: string = 'InterfaceDeclaration';
7575
nullLiteralTypeAnnotation: string = 'NullLiteralTypeAnnotation';
76+
undefinedLiteralTypeAnnotation: string = 'VoidLiteralTypeAnnotation';
7677

7778
isProperty(property: $FlowFixMe): boolean {
7879
return property.type === 'ObjectTypeProperty';

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export interface Parser {
105105
*/
106106
nullLiteralTypeAnnotation: string;
107107

108+
/**
109+
* UndefinedLiteralTypeAnnotation property of the Parser
110+
*/
111+
undefinedLiteralTypeAnnotation: string;
112+
108113
/**
109114
* Given a declaration, it returns true if it is a property
110115
*/

packages/react-native-codegen/src/parsers/parserMock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export class MockedParser implements Parser {
7373
typeAlias: string = 'TypeAlias';
7474
enumDeclaration: string = 'EnumDeclaration';
7575
interfaceDeclaration: string = 'InterfaceDeclaration';
76-
7776
nullLiteralTypeAnnotation: string = 'NullLiteralTypeAnnotation';
77+
undefinedLiteralTypeAnnotation: string = 'VoidLiteralTypeAnnotation';
7878

7979
isProperty(property: $FlowFixMe): boolean {
8080
return property.type === 'ObjectTypeProperty';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function findEventArgumentsAndType(
239239

240240
switch (typeAnnotation.typeParameters.params[0].type) {
241241
case parser.nullLiteralTypeAnnotation:
242-
case 'TSUndefinedKeyword':
242+
case parser.undefinedLiteralTypeAnnotation:
243243
return {
244244
argumentProps: [],
245245
bubblingType: eventType,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class TypeScriptParser implements Parser {
7070
typeAlias: string = 'TSTypeAliasDeclaration';
7171
enumDeclaration: string = 'TSEnumDeclaration';
7272
interfaceDeclaration: string = 'TSInterfaceDeclaration';
73-
7473
nullLiteralTypeAnnotation: string = 'TSNullKeyword';
74+
undefinedLiteralTypeAnnotation: string = 'TSUndefinedKeyword';
7575

7676
isProperty(property: $FlowFixMe): boolean {
7777
return property.type === 'TSPropertySignature';

0 commit comments

Comments
 (0)