Skip to content

Commit e7d9e4d

Browse files
gkzfacebook-github-bot
authored andcommitted
Collapse object initialization in Xplat
Summary: Collapse multiline object initialization into one single object literal (as much as possible). Run codemod (requires temporary xplat task runner config changes), then manual fixes. ``` ./scripts/typedjs/flow/runner codemod lti/collapseObjectInitialization ~/fbsource/xplat/js/ ``` - Announcement: [post](https://fb.workplace.com/groups/flowlang/posts/903386663600331) - Support group: [Flow Support](https://fb.workplace.com/groups/flow) drop-conflicts Format: ``` arc f ``` Sort imports ``` hg l -n | xargs js1 lint --fix --rule 'fb-tools/sort-requires' ``` Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D36112168 fbshipit-source-id: 23db87c3bd8ffe693019ffeb5ac8300ec46c8532
1 parent 0337a29 commit e7d9e4d

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎Libraries/Utilities/__tests__/stringifySafe-test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('stringifySafe', () => {
3333
});
3434

3535
it('stringifySafe stringifies circular objects with toString', () => {
36-
const arg = {};
36+
const arg: {arg?: {...}} = {...null};
3737
arg.arg = arg;
3838
const result = stringifySafe(arg);
3939
expect(result).toEqual('[object Object]');

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
*/
1010

1111
'use strict';
12-
import type {CommandOptions} from './options';
1312
import type {TypeDeclarationMap} from '../utils';
14-
13+
import type {CommandOptions} from './options';
1514
import type {ComponentSchemaBuilderConfig} from './schema.js';
15+
16+
const {getTypes} = require('../utils');
1617
const {getCommands} = require('./commands');
1718
const {getEvents} = require('./events');
18-
const {getProps, getPropProperties} = require('./props');
19-
const {getCommandOptions, getOptions} = require('./options');
2019
const {getExtendsProps, removeKnownExtends} = require('./extends');
21-
const {getTypes} = require('../utils');
20+
const {getCommandOptions, getOptions} = require('./options');
21+
const {getPropProperties, getProps} = require('./props');
2222

2323
function findComponentConfig(ast) {
2424
const foundConfigs = [];
@@ -41,9 +41,10 @@ function findComponentConfig(ast) {
4141
const typeArgumentParams = declaration.typeArguments.params;
4242
const funcArgumentParams = declaration.arguments;
4343

44-
const nativeComponentType = {};
45-
nativeComponentType.propsTypeName = typeArgumentParams[0].id.name;
46-
nativeComponentType.componentName = funcArgumentParams[0].value;
44+
const nativeComponentType: {[string]: string} = {
45+
propsTypeName: typeArgumentParams[0].id.name,
46+
componentName: funcArgumentParams[0].value,
47+
};
4748
if (funcArgumentParams.length > 1) {
4849
nativeComponentType.optionsExpression = funcArgumentParams[1];
4950
}

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
*/
1010

1111
'use strict';
12-
import type {CommandOptions} from './options';
1312
import type {TypeDeclarationMap} from '../utils';
14-
13+
import type {CommandOptions} from './options';
1514
import type {ComponentSchemaBuilderConfig} from './schema.js';
15+
16+
const {getTypes} = require('../utils');
1617
const {getCommands} = require('./commands');
1718
const {getEvents} = require('./events');
18-
const {getProps, getPropProperties} = require('./props');
19-
const {getCommandOptions, getOptions} = require('./options');
2019
const {getExtendsProps, removeKnownExtends} = require('./extends');
21-
const {getTypes} = require('../utils');
20+
const {getCommandOptions, getOptions} = require('./options');
21+
const {getPropProperties, getProps} = require('./props');
2222

2323
function findComponentConfig(ast) {
2424
const foundConfigs = [];
@@ -41,9 +41,10 @@ function findComponentConfig(ast) {
4141
const typeArgumentParams = declaration.typeParameters.params;
4242
const funcArgumentParams = declaration.arguments;
4343

44-
const nativeComponentType = {};
45-
nativeComponentType.propsTypeName = typeArgumentParams[0].typeName.name;
46-
nativeComponentType.componentName = funcArgumentParams[0].value;
44+
const nativeComponentType: {[string]: string} = {
45+
propsTypeName: typeArgumentParams[0].typeName.name,
46+
componentName: funcArgumentParams[0].value,
47+
};
4748
if (funcArgumentParams.length > 1) {
4849
nativeComponentType.optionsExpression = funcArgumentParams[1];
4950
}

0 commit comments

Comments
 (0)