Skip to content

Commit b5c01ee

Browse files
kyawthura-ggfacebook-github-bot
authored andcommitted
Add a nullLiteralTypeAnnotation: string property into the Parser object (#37387)
Summary: Part of #34872 > [Codegen 110] Add a nullLiteralTypeAnnotation: string property into the Parser object and implement it in the FlowParser (returning NullLiteralTypeAnnotation) and in the TypeScriptParser(returning TSNullKeyword). Replace them in the [parsers/flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L137-L138) and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L157). bypass-github-export-checks ## Changelog: [Internal][Added]: Add nullLiteralTypeAnnotation property in Parser object Pull Request resolved: #37387 Test Plan: `yarn test react-native-codegen` Reviewed By: dmytrorykun Differential Revision: D45779075 Pulled By: cipolleschi fbshipit-source-id: 4ebcf8e1039d7e9188fdfe811fae1720fcba1994
1 parent 9301c8f commit b5c01ee

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
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
@@ -223,7 +223,7 @@ function findEventArgumentsAndType(
223223
: null;
224224
if (
225225
typeAnnotation.typeParameters.params[0].type ===
226-
'NullLiteralTypeAnnotation'
226+
parser.nullLiteralTypeAnnotation
227227
) {
228228
return {
229229
argumentProps: [],

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class FlowParser implements Parser {
6666
enumDeclaration: string = 'EnumDeclaration';
6767
interfaceDelcaration: string = 'InterfaceDeclaration';
6868

69+
nullLiteralTypeAnnotation: string = 'NullLiteralTypeAnnotation';
70+
6971
isProperty(property: $FlowFixMe): boolean {
7072
return property.type === 'ObjectTypeProperty';
7173
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export interface Parser {
9898
*/
9999
interfaceDelcaration: string;
100100

101+
/**
102+
* This is the NullLiteralTypeAnnotation value
103+
*/
104+
nullLiteralTypeAnnotation: string;
105+
101106
/**
102107
* Given a declaration, it returns true if it is a property
103108
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export class MockedParser implements Parser {
6464
enumDeclaration: string = 'EnumDeclaration';
6565
interfaceDelcaration: string = 'InterfaceDelcaration';
6666

67+
nullLiteralTypeAnnotation: string = 'NullLiteralTypeAnnotation';
68+
6769
isProperty(property: $FlowFixMe): boolean {
6870
return property.type === 'ObjectTypeProperty';
6971
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function findEventArgumentsAndType(
237237
: null;
238238

239239
switch (typeAnnotation.typeParameters.params[0].type) {
240-
case 'TSNullKeyword':
240+
case parser.nullLiteralTypeAnnotation:
241241
case 'TSUndefinedKeyword':
242242
return {
243243
argumentProps: [],

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class TypeScriptParser implements Parser {
6464
enumDeclaration: string = 'TSEnumDeclaration';
6565
interfaceDelcaration: string = 'TSInterfaceDeclaration';
6666

67+
nullLiteralTypeAnnotation: string = 'TSNullKeyword';
68+
6769
isProperty(property: $FlowFixMe): boolean {
6870
return property.type === 'TSPropertySignature';
6971
}

0 commit comments

Comments
 (0)