Skip to content

Commit 0b5aa39

Browse files
osdnkfacebook-github-bot
authored andcommitted
Minor fixes in Flow parser
Summary: This diff includes minor codestyle changes. All these fixes was discussed with Rick. Reviewed By: rickhanlonii Differential Revision: D16169332 fbshipit-source-id: e561e2f2b116b6fdf8434c3dfc20c3e610d7ecad
1 parent fb7b2d3 commit 0b5aa39

File tree

22 files changed

+1865
-1746
lines changed

22 files changed

+1865
-1746
lines changed

packages/react-native-codegen/src/CodegenSchema.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export type PrimitiveTypeAnnotationType =
134134
| 'StringTypeAnnotation'
135135
| 'NumberTypeAnnotation'
136136
| 'BooleanTypeAnnotation'
137-
| 'ObjectWithoutPropertiesTypeAnnotation';
137+
| 'GenericObjectTypeAnnotation';
138138

139139
export type PrimitiveTypeAnnotation = $ReadOnly<{|
140140
type: PrimitiveTypeAnnotationType,
@@ -174,7 +174,7 @@ export type FunctionTypeAnnotationReturn =
174174
elementType: FunctionTypeAnnotationReturnArrayElementType,
175175
|}>
176176
| $ReadOnly<{|
177-
type: 'PromiseTypeAnnotation',
177+
type: 'GenericPromiseTypeAnnotation',
178178
resolvedType: FunctionTypeAnnotationReturn,
179179
|}>
180180
| $ReadOnly<{|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
*/
10+
11+
'use strict';
12+
13+
const COMMANDS_DEFINED_INLINE = `
14+
/**
15+
* Copyright (c) Facebook, Inc. and its affiliates.
16+
*
17+
* This source code is licensed under the MIT license found in the
18+
* LICENSE file in the root directory of this source tree.
19+
*
20+
* @format
21+
* @flow
22+
*/
23+
24+
'use strict';
25+
26+
const codegenNativeComponent = require('codegenNativeComponent');
27+
const codegenNativeCommands = require('codegenNativeCommands');
28+
29+
import type {
30+
Int32,
31+
BubblingEvent,
32+
DirectEvent,
33+
} from 'CodegenTypes';
34+
35+
import type {ViewProps} from 'ViewPropTypes';
36+
37+
export type ModuleProps = $ReadOnly<{|
38+
...ViewProps,
39+
// No props
40+
|}>;
41+
42+
export const Commands = codegenNativeCommands<{
43+
+hotspotUpdate: (ref: React.Ref<'RCTView'>, x: Int32, y: Int32) => void;
44+
}>();
45+
46+
export default codegenNativeComponent<ModuleProps>('Module');
47+
`;
48+
49+
const COMMANDS_DEFINED_MULTIPLE_TIMES = `
50+
/**
51+
* Copyright (c) Facebook, Inc. and its affiliates.
52+
*
53+
* This source code is licensed under the MIT license found in the
54+
* LICENSE file in the root directory of this source tree.
55+
*
56+
* @format
57+
* @flow
58+
*/
59+
60+
'use strict';
61+
62+
const codegenNativeComponent = require('codegenNativeComponent');
63+
const codegenNativeCommands = require('codegenNativeCommands');
64+
65+
import type {
66+
Int32,
67+
BubblingEvent,
68+
DirectEvent,
69+
} from 'CodegenTypes';
70+
71+
import type {ViewProps} from 'ViewPropTypes';
72+
73+
interface NativeCommands {
74+
+hotspotUpdate: (x: Int32, y: Int32) => void;
75+
}
76+
77+
export type ModuleProps = $ReadOnly<{|
78+
...ViewProps,
79+
// No props or events
80+
|}>;
81+
82+
export const Commands = codegenNativeCommands<NativeCommands>();
83+
export const Commands2 = codegenNativeCommands<NativeCommands>();
84+
85+
export default codegenNativeComponent<ModuleProps>('Module');
86+
`;
87+
88+
const COMMANDS_DEFINED_WITHOUT_REF = `
89+
/**
90+
* Copyright (c) Facebook, Inc. and its affiliates.
91+
*
92+
* This source code is licensed under the MIT license found in the
93+
* LICENSE file in the root directory of this source tree.
94+
*
95+
* @format
96+
* @flow
97+
*/
98+
99+
'use strict';
100+
101+
const codegenNativeComponent = require('codegenNativeComponent');
102+
const codegenNativeCommands = require('codegenNativeCommands');
103+
104+
import type {
105+
Int32,
106+
BubblingEvent,
107+
DirectEvent,
108+
} from 'CodegenTypes';
109+
110+
import type {ViewProps} from 'ViewPropTypes';
111+
112+
interface NativeCommands {
113+
+hotspotUpdate: (x: Int32, y: Int32) => void;
114+
}
115+
116+
export type ModuleProps = $ReadOnly<{|
117+
...ViewProps,
118+
// No props or events
119+
|}>;
120+
121+
export const Commands = codegenNativeCommands<NativeCommands>();
122+
123+
export default codegenNativeComponent<ModuleProps>('Module');
124+
`;
125+
const NULLABLE_WITH_DEFAULT = `
126+
/**
127+
* Copyright (c) Facebook, Inc. and its affiliates.
128+
*
129+
* This source code is licensed under the MIT license found in the
130+
* LICENSE file in the root directory of this source tree.
131+
*
132+
* @format
133+
* @flow
134+
*/
135+
136+
'use strict';
137+
138+
const codegenNativeComponent = require('codegenNativeComponent');
139+
140+
import type {
141+
WithDefault,
142+
Float,
143+
} from 'CodegenTypes';
144+
145+
import type {ViewProps} from 'ViewPropTypes';
146+
147+
148+
export type ModuleProps = $ReadOnly<{|
149+
...ViewProps,
150+
nullable_with_default: ?WithDefault<Float, 1.0>,
151+
|}>;
152+
153+
export default codegenNativeComponent<ModuleProps>('Module');
154+
`;
155+
156+
const NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE = `
157+
/**
158+
* Copyright (c) Facebook, Inc. and its affiliates.
159+
*
160+
* This source code is licensed under the MIT license found in the
161+
* LICENSE file in the root directory of this source tree.
162+
*
163+
* @format
164+
* @flow
165+
*/
166+
167+
'use strict';
168+
169+
const codegenNativeComponent = require('codegenNativeComponent');
170+
171+
import type {
172+
WithDefault,
173+
Float,
174+
} from 'CodegenTypes';
175+
176+
import type {ViewProps} from 'ViewPropTypes';
177+
178+
179+
export type ModuleProps = $ReadOnly<{|
180+
...ViewProps,
181+
required_key_with_default: WithDefault<Float, 1.0>,
182+
|}>;
183+
184+
export default codegenNativeComponent<ModuleProps>('Module');
185+
`;
186+
module.exports = {
187+
COMMANDS_DEFINED_INLINE,
188+
COMMANDS_DEFINED_MULTIPLE_TIMES,
189+
COMMANDS_DEFINED_WITHOUT_REF,
190+
NULLABLE_WITH_DEFAULT,
191+
NON_OPTIONAL_KEY_WITH_DEFAULT_VALUE,
192+
};

0 commit comments

Comments
 (0)