Skip to content

Commit 2934399

Browse files
Vinay Harwanifacebook-github-bot
authored andcommitted
Extracted TypeDeclarationMap from flow and typescript to a common file parsers/utils.js (#34951)
Summary: This PR is a part of #34872. This PR extracts TypeDeclarationMap type from flow and typescript to a common file parsers/utils.js and updates all imports. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Extracted TypeDeclarationMap from flow and typescript to a common file parsers/utils.js. Pull Request resolved: #34951 Test Plan: yarn jest react-native-codegen <img width="1129" alt="Screenshot 2022-10-12 at 12 13 48 PM" src="https://user-images.githubusercontent.com/87412080/195270569-fc077863-7e51-49e8-92ef-f3991f838d6a.png"> Reviewed By: NickGerleman Differential Revision: D40296917 Pulled By: cipolleschi fbshipit-source-id: d073daf0aadc291d5f9d00c003f0161af9e11319
1 parent 96027f7 commit 2934399

File tree

19 files changed

+20
-22
lines changed

19 files changed

+20
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
NamedShape,
1515
CommandTypeAnnotation,
1616
} from '../../../CodegenSchema.js';
17-
import type {TypeDeclarationMap} from '../utils.js';
17+
import type {TypeDeclarationMap} from '../../utils';
1818

1919
const {getValueFromTypes} = require('../utils.js');
2020

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
'use strict';
1212

1313
import type {ASTNode} from '../utils';
14-
import type {TypeDeclarationMap} from '../utils.js';
1514
import type {NamedShape} from '../../../CodegenSchema.js';
1615
const {getValueFromTypes} = require('../utils.js');
16+
import type {TypeDeclarationMap} from '../../utils';
1717

1818
function getProperties(
1919
typeName: string,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'use strict';
1212

1313
import type {ExtendsPropsShape} from '../../../CodegenSchema.js';
14-
import type {TypeDeclarationMap} from '../utils.js';
14+
import type {TypeDeclarationMap} from '../../utils';
1515

1616
function extendsForProp(prop: PropsAST, types: TypeDeclarationMap) {
1717
if (!prop.argument) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
'use strict';
12-
import type {TypeDeclarationMap} from '../utils';
12+
import type {TypeDeclarationMap} from '../../utils';
1313
import type {CommandOptions} from './options';
1414
import type {ComponentSchemaBuilderConfig} from './schema.js';
1515

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const {
1717
} = require('./componentsUtils.js');
1818

1919
import type {NamedShape, PropTypeAnnotation} from '../../../CodegenSchema.js';
20-
import type {TypeDeclarationMap} from '../utils.js';
20+
import type {TypeDeclarationMap} from '../../utils';
2121

2222
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
2323
type PropAST = Object;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const {
1717
} = require('./componentsUtils.js');
1818

1919
import type {StateTypeAnnotation, NamedShape} from '../../../CodegenSchema.js';
20-
import type {TypeDeclarationMap} from '../utils.js';
20+
import type {TypeDeclarationMap} from '../../utils';
2121

2222
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
2323
type PropAST = Object;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import type {
2222
Nullable,
2323
} from '../../../CodegenSchema.js';
2424

25-
import type {TypeDeclarationMap} from '../utils.js';
26-
import type {ParserErrorCapturer} from '../../utils';
25+
import type {ParserErrorCapturer, TypeDeclarationMap} from '../../utils';
2726
import type {NativeModuleTypeAnnotation} from '../../../CodegenSchema.js';
2827

2928
const {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
import type {TypeAliasResolutionStatus} from '../utils';
13+
import type {TypeAliasResolutionStatus, TypeDeclarationMap} from '../utils';
1414

1515
/**
1616
* This FlowFixMe is supposed to refer to an InterfaceDeclaration or TypeAlias
@@ -20,7 +20,6 @@ import type {TypeAliasResolutionStatus} from '../utils';
2020
*
2121
* TODO(T71778680): Flow type AST Nodes
2222
*/
23-
export type TypeDeclarationMap = {[declarationName: string]: $FlowFixMe};
2423

2524
function getTypes(ast: $FlowFixMe): TypeDeclarationMap {
2625
return ast.body.reduce((types, node) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
NamedShape,
1515
CommandTypeAnnotation,
1616
} from '../../../CodegenSchema.js';
17-
import type {TypeDeclarationMap} from '../utils.js';
17+
import type {TypeDeclarationMap} from '../../utils';
1818
const {parseTopLevelType} = require('../parseTopLevelType');
1919

2020
type EventTypeAST = Object;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
'use strict';
1212
import type {ASTNode} from '../utils';
13-
import type {TypeDeclarationMap} from '../utils.js';
1413
import type {NamedShape} from '../../../CodegenSchema.js';
1514
const {parseTopLevelType} = require('../parseTopLevelType');
15+
import type {TypeDeclarationMap} from '../../utils';
1616

1717
function getProperties(
1818
typeName: string,

0 commit comments

Comments
 (0)