Skip to content

Commit 26b22a6

Browse files
MaeIgfacebook-github-bot
authored andcommitted
Remove hardcoded language from modules/index.js (#36435)
Summary: This PR aims to remove the hardcoded language constants to use common parser instead. It is a task of #34872: > [Codegen 89 - Assigned to MaeIg] Remove the const language variable from flow/modules/index.js and replace its usage with parser.language() > [Codegen 90 - Assigned to MaeIg] Remove the const language variable from typescript/modules/index.js and replace its usage with parser.language() ## 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] [Changed] - Remove hardcoded language from modules/index.js to use common parser instead Pull Request resolved: #36435 Test Plan: yarn flow: <img width="145" alt="image" src="https://user-images.githubusercontent.com/40902940/224333480-600cefd0-9dc6-4142-8e88-db20785e49e6.png"> yarn lint: <img width="504" alt="image" src="https://user-images.githubusercontent.com/40902940/224333852-d510594f-053e-4866-8ceb-5e3e3d074bc2.png"> yarn test <img width="383" alt="image" src="https://user-images.githubusercontent.com/40902940/224333600-8c772829-2362-4943-895d-1949a0d88918.png"> Reviewed By: cortinico Differential Revision: D43979030 Pulled By: cipolleschi fbshipit-source-id: 39c5b99fc628620f1831ed8c4ee531eec0e866c4
1 parent d9f2cbe commit 26b22a6

File tree

4 files changed

+3
-13
lines changed

4 files changed

+3
-13
lines changed

packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ describe('typeEnumResolution', () => {
359359
{successful: true, type: 'enum', name: 'Foo'},
360360
true /* nullable */,
361361
'SomeModule' /* name */,
362-
'Flow',
363362
enumMap,
364363
parser,
365364
);
@@ -403,7 +402,6 @@ describe('typeEnumResolution', () => {
403402
{successful: true, type: 'enum', name: 'Foo'},
404403
true /* nullable */,
405404
'SomeModule' /* name */,
406-
'Flow',
407405
enumMap,
408406
parser,
409407
);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ const {
6060
throwIfPartialWithMoreParameter,
6161
} = require('../../error-utils');
6262

63-
const language = 'Flow';
64-
6563
function translateTypeAnnotation(
6664
hasteModuleName: string,
6765
/**
@@ -295,7 +293,6 @@ function translateTypeAnnotation(
295293
typeResolutionStatus,
296294
nullable,
297295
hasteModuleName,
298-
language,
299296
enumMap,
300297
parser,
301298
);
@@ -304,7 +301,7 @@ function translateTypeAnnotation(
304301
throw new UnsupportedTypeAnnotationParserError(
305302
hasteModuleName,
306303
typeAnnotation,
307-
language,
304+
parser.language(),
308305
);
309306
}
310307
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import type {
3434
NativeModuleObjectTypeAnnotation,
3535
NativeModuleEnumDeclaration,
3636
} from '../CodegenSchema';
37-
import type {ParserType} from './errors';
3837
import type {Parser} from './parser';
3938
import type {
4039
ParserErrorCapturer,
@@ -206,15 +205,14 @@ function typeEnumResolution(
206205
typeResolution: TypeResolutionStatus,
207206
nullable: boolean,
208207
hasteModuleName: string,
209-
language: ParserType,
210208
enumMap: {...NativeModuleEnumMap},
211209
parser: Parser,
212210
): Nullable<NativeModuleEnumDeclaration> {
213211
if (!typeResolution.successful || typeResolution.type !== 'enum') {
214212
throw new UnsupportedTypeAnnotationParserError(
215213
hasteModuleName,
216214
typeAnnotation,
217-
language,
215+
parser.language(),
218216
);
219217
}
220218

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ const {
6464
throwIfPartialWithMoreParameter,
6565
} = require('../../error-utils');
6666

67-
const language = 'TypeScript';
68-
6967
function translateObjectTypeAnnotation(
7068
hasteModuleName: string,
7169
/**
@@ -362,7 +360,6 @@ function translateTypeAnnotation(
362360
typeResolutionStatus,
363361
nullable,
364362
hasteModuleName,
365-
language,
366363
enumMap,
367364
parser,
368365
);
@@ -406,7 +403,7 @@ function translateTypeAnnotation(
406403
throw new UnsupportedTypeAnnotationParserError(
407404
hasteModuleName,
408405
typeAnnotation,
409-
language,
406+
parser.language(),
410407
);
411408
}
412409
}

0 commit comments

Comments
 (0)