@react-native/codegen 0.86.0-nightly-20260327-bfb6870f6 → 0.86.0-nightly-20260329-277d6f3a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/generators/components/ComponentsGeneratorUtils.js.flow +1 -1
- package/lib/generators/components/CppHelpers.js.flow +4 -4
- package/lib/generators/components/GenerateComponentHObjCpp.js.flow +8 -8
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +1 -1
- package/lib/generators/components/GenerateEventEmitterH.js.flow +2 -2
- package/lib/generators/components/GeneratePropsCpp.js.flow +3 -3
- package/lib/generators/components/GeneratePropsH.js.flow +5 -5
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +6 -6
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +6 -6
- package/lib/generators/components/GeneratePropsJavaPojo/serializePojo.js.flow +4 -4
- package/lib/generators/components/GenerateViewConfigJs.js.flow +4 -4
- package/lib/generators/components/JavaHelpers.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleH.js.flow +6 -6
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +11 -11
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +9 -9
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeStructUtils.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js.flow +2 -2
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +7 -7
- package/lib/parsers/flow/components/commands.js.flow +1 -1
- package/lib/parsers/flow/components/componentsUtils.js.flow +11 -11
- package/lib/parsers/flow/modules/index.js.flow +6 -4
- package/lib/parsers/parsers-commons.js.flow +3 -3
- package/lib/parsers/parsers-primitives.js.flow +1 -1
- package/lib/parsers/typescript/components/commands.js.flow +1 -1
- package/lib/parsers/typescript/components/componentsUtils.js.flow +12 -13
- package/package.json +1 -1
|
@@ -111,7 +111,7 @@ function getNativeTypeFromAnnotation(
|
|
|
111
111
|
case 'MixedTypeAnnotation':
|
|
112
112
|
return 'folly::dynamic';
|
|
113
113
|
default:
|
|
114
|
-
|
|
114
|
+
typeAnnotation as empty;
|
|
115
115
|
throw new Error(
|
|
116
116
|
`Received invalid typeAnnotation for ${componentName} prop ${prop.name}, received ${typeAnnotation.type}`,
|
|
117
117
|
);
|
|
@@ -47,7 +47,7 @@ function getCppTypeForAnnotation(
|
|
|
47
47
|
case 'MixedTypeAnnotation':
|
|
48
48
|
return 'folly::dynamic';
|
|
49
49
|
default:
|
|
50
|
-
(type
|
|
50
|
+
(type) as empty;
|
|
51
51
|
throw new Error(`Received invalid typeAnnotation ${type}`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -95,7 +95,7 @@ function getCppArrayTypeForAnnotation(
|
|
|
95
95
|
// Unions of strings and string literals are treated as just strings
|
|
96
96
|
return `std::vector<${getCppTypeForAnnotation('StringTypeAnnotation')}>`;
|
|
97
97
|
default:
|
|
98
|
-
|
|
98
|
+
validUnionType as empty;
|
|
99
99
|
throw new Error(`Unsupported union member type`);
|
|
100
100
|
}
|
|
101
101
|
case 'ObjectTypeAnnotation':
|
|
@@ -241,7 +241,7 @@ function convertDefaultTypeToString(
|
|
|
241
241
|
case 'DimensionPrimitive':
|
|
242
242
|
return '';
|
|
243
243
|
default:
|
|
244
|
-
|
|
244
|
+
typeAnnotation.name as empty;
|
|
245
245
|
throw new Error(
|
|
246
246
|
`Unsupported type annotation: ${typeAnnotation.name}`,
|
|
247
247
|
);
|
|
@@ -283,7 +283,7 @@ function convertDefaultTypeToString(
|
|
|
283
283
|
case 'MixedTypeAnnotation':
|
|
284
284
|
return '';
|
|
285
285
|
default:
|
|
286
|
-
|
|
286
|
+
typeAnnotation as empty;
|
|
287
287
|
throw new Error(`Unsupported type annotation: ${typeAnnotation.type}`);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
@@ -158,7 +158,7 @@ function getObjCParamType(param: Param): string {
|
|
|
158
158
|
case 'RootTag':
|
|
159
159
|
return 'double';
|
|
160
160
|
default:
|
|
161
|
-
|
|
161
|
+
typeAnnotation.name as empty;
|
|
162
162
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
163
163
|
}
|
|
164
164
|
case 'BooleanTypeAnnotation':
|
|
@@ -174,7 +174,7 @@ function getObjCParamType(param: Param): string {
|
|
|
174
174
|
case 'ArrayTypeAnnotation':
|
|
175
175
|
return 'const NSArray *';
|
|
176
176
|
default:
|
|
177
|
-
|
|
177
|
+
typeAnnotation.type as empty;
|
|
178
178
|
throw new Error('Received invalid param type annotation');
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -188,7 +188,7 @@ function getObjCExpectedKindParamType(param: Param): string {
|
|
|
188
188
|
case 'RootTag':
|
|
189
189
|
return '[NSNumber class]';
|
|
190
190
|
default:
|
|
191
|
-
|
|
191
|
+
typeAnnotation.name as empty;
|
|
192
192
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
193
193
|
}
|
|
194
194
|
case 'BooleanTypeAnnotation':
|
|
@@ -204,7 +204,7 @@ function getObjCExpectedKindParamType(param: Param): string {
|
|
|
204
204
|
case 'ArrayTypeAnnotation':
|
|
205
205
|
return '[NSArray class]';
|
|
206
206
|
default:
|
|
207
|
-
|
|
207
|
+
typeAnnotation.type as empty;
|
|
208
208
|
throw new Error('Received invalid param type annotation');
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -218,7 +218,7 @@ function getReadableExpectedKindParamType(param: Param): string {
|
|
|
218
218
|
case 'RootTag':
|
|
219
219
|
return 'double';
|
|
220
220
|
default:
|
|
221
|
-
|
|
221
|
+
typeAnnotation.name as empty;
|
|
222
222
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
223
223
|
}
|
|
224
224
|
case 'BooleanTypeAnnotation':
|
|
@@ -234,7 +234,7 @@ function getReadableExpectedKindParamType(param: Param): string {
|
|
|
234
234
|
case 'ArrayTypeAnnotation':
|
|
235
235
|
return 'array';
|
|
236
236
|
default:
|
|
237
|
-
|
|
237
|
+
typeAnnotation.type as empty;
|
|
238
238
|
throw new Error('Received invalid param type annotation');
|
|
239
239
|
}
|
|
240
240
|
}
|
|
@@ -251,7 +251,7 @@ function getObjCRightHandAssignmentParamType(
|
|
|
251
251
|
case 'RootTag':
|
|
252
252
|
return `[(NSNumber *)arg${index} doubleValue]`;
|
|
253
253
|
default:
|
|
254
|
-
|
|
254
|
+
typeAnnotation.name as empty;
|
|
255
255
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
256
256
|
}
|
|
257
257
|
case 'BooleanTypeAnnotation':
|
|
@@ -267,7 +267,7 @@ function getObjCRightHandAssignmentParamType(
|
|
|
267
267
|
case 'ArrayTypeAnnotation':
|
|
268
268
|
return `(NSArray *)arg${index}`;
|
|
269
269
|
default:
|
|
270
|
-
|
|
270
|
+
typeAnnotation.type as empty;
|
|
271
271
|
throw new Error('Received invalid param type annotation');
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -148,7 +148,7 @@ function getNativeTypeFromAnnotation(
|
|
|
148
148
|
eventProperty.name,
|
|
149
149
|
]);
|
|
150
150
|
default:
|
|
151
|
-
|
|
151
|
+
typeAnnotation.type as empty;
|
|
152
152
|
throw new Error(
|
|
153
153
|
`Received invalid event property type ${typeAnnotation.type}`,
|
|
154
154
|
);
|
|
@@ -274,7 +274,7 @@ function generateStruct(
|
|
|
274
274
|
);
|
|
275
275
|
return;
|
|
276
276
|
default:
|
|
277
|
-
|
|
277
|
+
typeAnnotation.type as empty;
|
|
278
278
|
throw new Error(
|
|
279
279
|
`Received invalid event property type ${typeAnnotation.type}`,
|
|
280
280
|
);
|
|
@@ -205,7 +205,7 @@ function generatePropsDiffString(
|
|
|
205
205
|
'ImageRequestPrimitive should not be used in Props',
|
|
206
206
|
);
|
|
207
207
|
default:
|
|
208
|
-
|
|
208
|
+
typeAnnotation.name as empty;
|
|
209
209
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
210
210
|
}
|
|
211
211
|
default:
|
|
@@ -288,11 +288,11 @@ function getClassExtendString(component: ComponentShape): string {
|
|
|
288
288
|
case 'ReactNativeCoreViewProps':
|
|
289
289
|
return 'ViewProps(context, sourceProps, rawProps)';
|
|
290
290
|
default:
|
|
291
|
-
|
|
291
|
+
extendProps.knownTypeName as empty;
|
|
292
292
|
throw new Error('Invalid knownTypeName');
|
|
293
293
|
}
|
|
294
294
|
default:
|
|
295
|
-
|
|
295
|
+
extendProps.type as empty;
|
|
296
296
|
throw new Error('Invalid extended type');
|
|
297
297
|
}
|
|
298
298
|
})
|
|
@@ -331,11 +331,11 @@ function getClassExtendString(component: ComponentShape): string {
|
|
|
331
331
|
case 'ReactNativeCoreViewProps':
|
|
332
332
|
return 'public ViewProps';
|
|
333
333
|
default:
|
|
334
|
-
|
|
334
|
+
extendProps.knownTypeName as empty;
|
|
335
335
|
throw new Error('Invalid knownTypeName');
|
|
336
336
|
}
|
|
337
337
|
default:
|
|
338
|
-
|
|
338
|
+
extendProps.type as empty;
|
|
339
339
|
throw new Error('Invalid extended type');
|
|
340
340
|
}
|
|
341
341
|
})
|
|
@@ -574,11 +574,11 @@ function getExtendsImports(
|
|
|
574
574
|
);
|
|
575
575
|
return;
|
|
576
576
|
default:
|
|
577
|
-
|
|
577
|
+
extendProps.knownTypeName as empty;
|
|
578
578
|
throw new Error('Invalid knownTypeName');
|
|
579
579
|
}
|
|
580
580
|
default:
|
|
581
|
-
|
|
581
|
+
extendProps.type as empty;
|
|
582
582
|
throw new Error('Invalid extended type');
|
|
583
583
|
}
|
|
584
584
|
});
|
|
@@ -778,7 +778,7 @@ function generateStruct(
|
|
|
778
778
|
case 'MixedTypeAnnotation':
|
|
779
779
|
return;
|
|
780
780
|
default:
|
|
781
|
-
|
|
781
|
+
property.typeAnnotation.type as empty;
|
|
782
782
|
throw new Error(
|
|
783
783
|
`Received invalid component property type ${property.typeAnnotation.type}`,
|
|
784
784
|
);
|
|
@@ -132,7 +132,7 @@ function getJavaValueForProp(
|
|
|
132
132
|
case 'DimensionPrimitive':
|
|
133
133
|
return 'DimensionPropConverter.getDimension(value)';
|
|
134
134
|
default:
|
|
135
|
-
|
|
135
|
+
typeAnnotation.name as empty;
|
|
136
136
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
137
137
|
}
|
|
138
138
|
case 'ArrayTypeAnnotation': {
|
|
@@ -148,7 +148,7 @@ function getJavaValueForProp(
|
|
|
148
148
|
case 'MixedTypeAnnotation':
|
|
149
149
|
return 'new DynamicFromObject(value)';
|
|
150
150
|
default:
|
|
151
|
-
|
|
151
|
+
typeAnnotation as empty;
|
|
152
152
|
throw new Error('Received invalid typeAnnotation');
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -190,7 +190,7 @@ function getCommandArgJavaType(
|
|
|
190
190
|
case 'RootTag':
|
|
191
191
|
return `args.getDouble(${index})`;
|
|
192
192
|
default:
|
|
193
|
-
|
|
193
|
+
typeAnnotation.name as empty;
|
|
194
194
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
195
195
|
}
|
|
196
196
|
case 'BooleanTypeAnnotation':
|
|
@@ -206,7 +206,7 @@ function getCommandArgJavaType(
|
|
|
206
206
|
case 'ArrayTypeAnnotation':
|
|
207
207
|
return `args.getArray(${index})`;
|
|
208
208
|
default:
|
|
209
|
-
|
|
209
|
+
typeAnnotation.type as empty;
|
|
210
210
|
throw new Error(`Receieved invalid type: ${typeAnnotation.type}`);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
@@ -251,11 +251,11 @@ function getClassExtendString(component: ComponentShape): string {
|
|
|
251
251
|
case 'ReactNativeCoreViewProps':
|
|
252
252
|
return 'View';
|
|
253
253
|
default:
|
|
254
|
-
|
|
254
|
+
extendProps.knownTypeName as empty;
|
|
255
255
|
throw new Error('Invalid knownTypeName');
|
|
256
256
|
}
|
|
257
257
|
default:
|
|
258
|
-
|
|
258
|
+
extendProps.type as empty;
|
|
259
259
|
throw new Error('Invalid extended type');
|
|
260
260
|
}
|
|
261
261
|
})
|
|
@@ -110,7 +110,7 @@ function getJavaValueForProp(
|
|
|
110
110
|
addNullable(imports);
|
|
111
111
|
return '@Nullable YogaValue value';
|
|
112
112
|
default:
|
|
113
|
-
|
|
113
|
+
typeAnnotation.name as empty;
|
|
114
114
|
throw new Error('Received unknown ReservedPropTypeAnnotation');
|
|
115
115
|
}
|
|
116
116
|
case 'ArrayTypeAnnotation': {
|
|
@@ -130,7 +130,7 @@ function getJavaValueForProp(
|
|
|
130
130
|
case 'MixedTypeAnnotation':
|
|
131
131
|
return 'Dynamic value';
|
|
132
132
|
default:
|
|
133
|
-
|
|
133
|
+
typeAnnotation as empty;
|
|
134
134
|
throw new Error('Received invalid typeAnnotation');
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -158,7 +158,7 @@ function getCommandArgJavaType(param: NamedShape<CommandParamTypeAnnotation>) {
|
|
|
158
158
|
case 'RootTag':
|
|
159
159
|
return 'double';
|
|
160
160
|
default:
|
|
161
|
-
|
|
161
|
+
typeAnnotation.name as empty;
|
|
162
162
|
throw new Error(`Receieved invalid type: ${typeAnnotation.name}`);
|
|
163
163
|
}
|
|
164
164
|
case 'BooleanTypeAnnotation':
|
|
@@ -174,7 +174,7 @@ function getCommandArgJavaType(param: NamedShape<CommandParamTypeAnnotation>) {
|
|
|
174
174
|
case 'ArrayTypeAnnotation':
|
|
175
175
|
return 'ReadableArray';
|
|
176
176
|
default:
|
|
177
|
-
|
|
177
|
+
typeAnnotation.type as empty;
|
|
178
178
|
throw new Error('Receieved invalid typeAnnotation');
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -218,11 +218,11 @@ function getClassExtendString(component: ComponentShape): string {
|
|
|
218
218
|
case 'ReactNativeCoreViewProps':
|
|
219
219
|
return 'View';
|
|
220
220
|
default:
|
|
221
|
-
|
|
221
|
+
extendProps.knownTypeName as empty;
|
|
222
222
|
throw new Error('Invalid knownTypeName');
|
|
223
223
|
}
|
|
224
224
|
default:
|
|
225
|
-
|
|
225
|
+
extendProps.type as empty;
|
|
226
226
|
throw new Error('Invalid extended type');
|
|
227
227
|
}
|
|
228
228
|
})
|
|
@@ -108,7 +108,7 @@ function toJavaType(
|
|
|
108
108
|
return '@Nullable YogaValue';
|
|
109
109
|
|
|
110
110
|
default:
|
|
111
|
-
|
|
111
|
+
typeAnnotation.name as empty;
|
|
112
112
|
throw new Error(
|
|
113
113
|
`Received unknown ReservedPropTypeAnnotation ${typeAnnotation.name}`,
|
|
114
114
|
);
|
|
@@ -201,7 +201,7 @@ function toJavaType(
|
|
|
201
201
|
return 'YogaValue';
|
|
202
202
|
|
|
203
203
|
default:
|
|
204
|
-
|
|
204
|
+
elementType.name as empty;
|
|
205
205
|
throw new Error(
|
|
206
206
|
`Received unknown ReservedPropTypeAnnotation ${elementType.name}`,
|
|
207
207
|
);
|
|
@@ -216,7 +216,7 @@ function toJavaType(
|
|
|
216
216
|
return `ArrayList<${pojoTypeAliasTypeAnnotation.name}>`;
|
|
217
217
|
}
|
|
218
218
|
default: {
|
|
219
|
-
|
|
219
|
+
elementType.type as empty;
|
|
220
220
|
throw new Error(
|
|
221
221
|
`Unrecognized PojoTypeAnnotation Array element type annotation '${elementType.type}'`,
|
|
222
222
|
);
|
|
@@ -234,7 +234,7 @@ function toJavaType(
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
default: {
|
|
237
|
-
|
|
237
|
+
typeAnnotation.type as empty;
|
|
238
238
|
throw new Error(
|
|
239
239
|
`Unrecognized PojoTypeAnnotation '${typeAnnotation.type}'`,
|
|
240
240
|
);
|
|
@@ -91,7 +91,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) {
|
|
|
91
91
|
case 'DimensionPrimitive':
|
|
92
92
|
return t.booleanLiteral(true);
|
|
93
93
|
default:
|
|
94
|
-
|
|
94
|
+
typeAnnotation.name as empty;
|
|
95
95
|
throw new Error(
|
|
96
96
|
`Received unknown native typeAnnotation: "${typeAnnotation.name}"`,
|
|
97
97
|
);
|
|
@@ -116,7 +116,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) {
|
|
|
116
116
|
}
|
|
117
117
|
return t.booleanLiteral(true);
|
|
118
118
|
default:
|
|
119
|
-
|
|
119
|
+
typeAnnotation as empty;
|
|
120
120
|
throw new Error(
|
|
121
121
|
`Received unknown typeAnnotation: "${typeAnnotation.type}"`,
|
|
122
122
|
);
|
|
@@ -264,11 +264,11 @@ function buildViewConfig(
|
|
|
264
264
|
|
|
265
265
|
return;
|
|
266
266
|
default:
|
|
267
|
-
|
|
267
|
+
extendProps.knownTypeName as empty;
|
|
268
268
|
throw new Error('Invalid knownTypeName');
|
|
269
269
|
}
|
|
270
270
|
default:
|
|
271
|
-
|
|
271
|
+
extendProps.type as empty;
|
|
272
272
|
throw new Error('Invalid extended type');
|
|
273
273
|
}
|
|
274
274
|
});
|
|
@@ -52,11 +52,11 @@ function getImports(
|
|
|
52
52
|
imports.add('import android.view.View;');
|
|
53
53
|
return;
|
|
54
54
|
default:
|
|
55
|
-
|
|
55
|
+
extendProps.knownTypeName as empty;
|
|
56
56
|
throw new Error('Invalid knownTypeName');
|
|
57
57
|
}
|
|
58
58
|
default:
|
|
59
|
-
|
|
59
|
+
extendProps.type as empty;
|
|
60
60
|
throw new Error('Invalid extended type');
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -87,7 +87,7 @@ function serializeArg(
|
|
|
87
87
|
case 'RootTag':
|
|
88
88
|
return wrap(val => `${val}.asNumber()`);
|
|
89
89
|
default:
|
|
90
|
-
|
|
90
|
+
realTypeAnnotation.name as empty;
|
|
91
91
|
throw new Error(
|
|
92
92
|
`Unknown prop type for "${arg.name}, found: ${realTypeAnnotation.name}"`,
|
|
93
93
|
);
|
|
@@ -139,7 +139,7 @@ function serializeArg(
|
|
|
139
139
|
case 'string':
|
|
140
140
|
return wrap(val => `${val}.asString(rt)`);
|
|
141
141
|
default:
|
|
142
|
-
|
|
142
|
+
validUnionType as empty;
|
|
143
143
|
throw new Error(`Unsupported union member type`);
|
|
144
144
|
}
|
|
145
145
|
case 'ObjectTypeAnnotation':
|
|
@@ -147,7 +147,7 @@ function serializeArg(
|
|
|
147
147
|
case 'MixedTypeAnnotation':
|
|
148
148
|
return wrap(val => `jsi::Value(rt, ${val})`);
|
|
149
149
|
default:
|
|
150
|
-
|
|
150
|
+
realTypeAnnotation.type as empty;
|
|
151
151
|
throw new Error(
|
|
152
152
|
`Unknown prop type for "${arg.name}, found: ${realTypeAnnotation.type}"`,
|
|
153
153
|
);
|
|
@@ -248,7 +248,7 @@ function translatePrimitiveJSTypeToCpp(
|
|
|
248
248
|
case 'RootTag':
|
|
249
249
|
return wrapOptional('double', isRequired);
|
|
250
250
|
default:
|
|
251
|
-
|
|
251
|
+
realTypeAnnotation.name as empty;
|
|
252
252
|
throw new Error(createErrorMessage(realTypeAnnotation.name));
|
|
253
253
|
}
|
|
254
254
|
case 'VoidTypeAnnotation':
|
|
@@ -294,7 +294,7 @@ function translatePrimitiveJSTypeToCpp(
|
|
|
294
294
|
case 'string':
|
|
295
295
|
return wrapOptional('jsi::String', isRequired);
|
|
296
296
|
default:
|
|
297
|
-
|
|
297
|
+
validUnionType as empty;
|
|
298
298
|
throw new Error(`Unsupported union member type`);
|
|
299
299
|
}
|
|
300
300
|
case 'ObjectTypeAnnotation':
|
|
@@ -308,7 +308,7 @@ function translatePrimitiveJSTypeToCpp(
|
|
|
308
308
|
case 'MixedTypeAnnotation':
|
|
309
309
|
return wrapOptional('jsi::Value', isRequired);
|
|
310
310
|
default:
|
|
311
|
-
|
|
311
|
+
realTypeAnnotation.type as empty;
|
|
312
312
|
throw new Error(createErrorMessage(realTypeAnnotation.type));
|
|
313
313
|
}
|
|
314
314
|
}
|
|
@@ -146,7 +146,7 @@ function translateEventEmitterTypeToJavaType(
|
|
|
146
146
|
case 'string':
|
|
147
147
|
return 'String';
|
|
148
148
|
default:
|
|
149
|
-
|
|
149
|
+
validUnionType as empty;
|
|
150
150
|
throw new Error(`Unsupported union member type`);
|
|
151
151
|
}
|
|
152
152
|
case 'NumberTypeAnnotation':
|
|
@@ -175,7 +175,7 @@ function translateEventEmitterTypeToJavaType(
|
|
|
175
175
|
`Unsupported eventType for ${eventEmitter.name}. Found: ${eventEmitter.typeAnnotation.typeAnnotation.type}`,
|
|
176
176
|
);
|
|
177
177
|
default:
|
|
178
|
-
|
|
178
|
+
typeAnnotation.type as empty;
|
|
179
179
|
throw new Error(
|
|
180
180
|
`Unsupported eventType for ${eventEmitter.name}. Found: ${eventEmitter.typeAnnotation.typeAnnotation.type}`,
|
|
181
181
|
);
|
|
@@ -208,7 +208,7 @@ function translateFunctionParamToJavaType(
|
|
|
208
208
|
case 'RootTag':
|
|
209
209
|
return wrapOptional('double', isRequired);
|
|
210
210
|
default:
|
|
211
|
-
|
|
211
|
+
realTypeAnnotation.name as empty;
|
|
212
212
|
throw new Error(createErrorMessage(realTypeAnnotation.name));
|
|
213
213
|
}
|
|
214
214
|
case 'StringTypeAnnotation':
|
|
@@ -251,7 +251,7 @@ function translateFunctionParamToJavaType(
|
|
|
251
251
|
case 'string':
|
|
252
252
|
return wrapOptional('String', isRequired);
|
|
253
253
|
default:
|
|
254
|
-
|
|
254
|
+
validUnionType as empty;
|
|
255
255
|
throw new Error(`Unsupported union member type`);
|
|
256
256
|
}
|
|
257
257
|
case 'ObjectTypeAnnotation':
|
|
@@ -268,7 +268,7 @@ function translateFunctionParamToJavaType(
|
|
|
268
268
|
imports.add('com.facebook.react.bridge.Callback');
|
|
269
269
|
return wrapOptional('Callback', isRequired);
|
|
270
270
|
default:
|
|
271
|
-
|
|
271
|
+
realTypeAnnotation.type as 'MixedTypeAnnotation';
|
|
272
272
|
throw new Error(createErrorMessage(realTypeAnnotation.type));
|
|
273
273
|
}
|
|
274
274
|
}
|
|
@@ -302,7 +302,7 @@ function translateFunctionReturnTypeToJavaType(
|
|
|
302
302
|
case 'RootTag':
|
|
303
303
|
return wrapOptional('double', isRequired);
|
|
304
304
|
default:
|
|
305
|
-
|
|
305
|
+
realTypeAnnotation.name as empty;
|
|
306
306
|
throw new Error(createErrorMessage(realTypeAnnotation.name));
|
|
307
307
|
}
|
|
308
308
|
case 'VoidTypeAnnotation':
|
|
@@ -349,7 +349,7 @@ function translateFunctionReturnTypeToJavaType(
|
|
|
349
349
|
case 'string':
|
|
350
350
|
return wrapOptional('String', isRequired);
|
|
351
351
|
default:
|
|
352
|
-
|
|
352
|
+
validUnionType as empty;
|
|
353
353
|
throw new Error(`Unsupported union member type`);
|
|
354
354
|
}
|
|
355
355
|
case 'ObjectTypeAnnotation':
|
|
@@ -362,7 +362,7 @@ function translateFunctionReturnTypeToJavaType(
|
|
|
362
362
|
imports.add('com.facebook.react.bridge.WritableArray');
|
|
363
363
|
return wrapOptional('WritableArray', isRequired);
|
|
364
364
|
default:
|
|
365
|
-
|
|
365
|
+
realTypeAnnotation.type as 'MixedTypeAnnotation';
|
|
366
366
|
throw new Error(createErrorMessage(realTypeAnnotation.type));
|
|
367
367
|
}
|
|
368
368
|
}
|
|
@@ -388,7 +388,7 @@ function getFalsyReturnStatementFromReturnType(
|
|
|
388
388
|
case 'RootTag':
|
|
389
389
|
return 'return 0.0;';
|
|
390
390
|
default:
|
|
391
|
-
|
|
391
|
+
realTypeAnnotation.name as empty;
|
|
392
392
|
throw new Error(createErrorMessage(realTypeAnnotation.name));
|
|
393
393
|
}
|
|
394
394
|
case 'VoidTypeAnnotation':
|
|
@@ -430,7 +430,7 @@ function getFalsyReturnStatementFromReturnType(
|
|
|
430
430
|
case 'string':
|
|
431
431
|
return nullable ? 'return null;' : 'return "";';
|
|
432
432
|
default:
|
|
433
|
-
|
|
433
|
+
validUnionType as empty;
|
|
434
434
|
throw new Error(`Unsupported union member type`);
|
|
435
435
|
}
|
|
436
436
|
case 'StringTypeAnnotation':
|
|
@@ -444,7 +444,7 @@ function getFalsyReturnStatementFromReturnType(
|
|
|
444
444
|
case 'ArrayTypeAnnotation':
|
|
445
445
|
return 'return null;';
|
|
446
446
|
default:
|
|
447
|
-
|
|
447
|
+
realTypeAnnotation.type as 'MixedTypeAnnotation';
|
|
448
448
|
throw new Error(createErrorMessage(realTypeAnnotation.type));
|
|
449
449
|
}
|
|
450
450
|
}
|
|
@@ -157,7 +157,7 @@ function translateReturnTypeToKind(
|
|
|
157
157
|
case 'RootTag':
|
|
158
158
|
return 'NumberKind';
|
|
159
159
|
default:
|
|
160
|
-
|
|
160
|
+
realTypeAnnotation.name as empty;
|
|
161
161
|
throw new Error(
|
|
162
162
|
`Invalid ReservedFunctionValueTypeName name, got ${realTypeAnnotation.name}`,
|
|
163
163
|
);
|
|
@@ -195,7 +195,7 @@ function translateReturnTypeToKind(
|
|
|
195
195
|
case 'string':
|
|
196
196
|
return 'StringKind';
|
|
197
197
|
default:
|
|
198
|
-
|
|
198
|
+
validUnionType as empty;
|
|
199
199
|
throw new Error(`Unsupported union member type`);
|
|
200
200
|
}
|
|
201
201
|
case 'NumberTypeAnnotation':
|
|
@@ -217,7 +217,7 @@ function translateReturnTypeToKind(
|
|
|
217
217
|
case 'ArrayTypeAnnotation':
|
|
218
218
|
return 'ArrayKind';
|
|
219
219
|
default:
|
|
220
|
-
|
|
220
|
+
realTypeAnnotation.type as 'MixedTypeAnnotation';
|
|
221
221
|
throw new Error(
|
|
222
222
|
`Unknown prop type for returning value, found: ${realTypeAnnotation.type}"`,
|
|
223
223
|
);
|
|
@@ -246,7 +246,7 @@ function translateParamTypeToJniType(
|
|
|
246
246
|
case 'RootTag':
|
|
247
247
|
return !isRequired ? 'Ljava/lang/Double;' : 'D';
|
|
248
248
|
default:
|
|
249
|
-
|
|
249
|
+
realTypeAnnotation.name as empty;
|
|
250
250
|
throw new Error(
|
|
251
251
|
`Invalid ReservedFunctionValueTypeName name, got ${realTypeAnnotation.name}`,
|
|
252
252
|
);
|
|
@@ -282,7 +282,7 @@ function translateParamTypeToJniType(
|
|
|
282
282
|
case 'string':
|
|
283
283
|
return 'Ljava/lang/String;';
|
|
284
284
|
default:
|
|
285
|
-
|
|
285
|
+
validUnionType as empty;
|
|
286
286
|
throw new Error(`Unsupported union member type`);
|
|
287
287
|
}
|
|
288
288
|
case 'NumberTypeAnnotation':
|
|
@@ -304,7 +304,7 @@ function translateParamTypeToJniType(
|
|
|
304
304
|
case 'FunctionTypeAnnotation':
|
|
305
305
|
return 'Lcom/facebook/react/bridge/Callback;';
|
|
306
306
|
default:
|
|
307
|
-
|
|
307
|
+
realTypeAnnotation.type as 'MixedTypeAnnotation';
|
|
308
308
|
throw new Error(
|
|
309
309
|
`Unknown prop type for method arg, found: ${realTypeAnnotation.type}"`,
|
|
310
310
|
);
|
|
@@ -328,7 +328,7 @@ function translateReturnTypeToJniType(
|
|
|
328
328
|
case 'RootTag':
|
|
329
329
|
return nullable ? 'Ljava/lang/Double;' : 'D';
|
|
330
330
|
default:
|
|
331
|
-
|
|
331
|
+
realTypeAnnotation.name as empty;
|
|
332
332
|
throw new Error(
|
|
333
333
|
`Invalid ReservedFunctionValueTypeName name, got ${realTypeAnnotation.name}`,
|
|
334
334
|
);
|
|
@@ -366,7 +366,7 @@ function translateReturnTypeToJniType(
|
|
|
366
366
|
case 'string':
|
|
367
367
|
return 'Ljava/lang/String;';
|
|
368
368
|
default:
|
|
369
|
-
|
|
369
|
+
validUnionType as empty;
|
|
370
370
|
throw new Error(`Unsupported union member type`);
|
|
371
371
|
}
|
|
372
372
|
case 'NumberTypeAnnotation':
|
|
@@ -388,7 +388,7 @@ function translateReturnTypeToJniType(
|
|
|
388
388
|
case 'ArrayTypeAnnotation':
|
|
389
389
|
return 'Lcom/facebook/react/bridge/WritableArray;';
|
|
390
390
|
default:
|
|
391
|
-
|
|
391
|
+
realTypeAnnotation.type as 'MixedTypeAnnotation';
|
|
392
392
|
throw new Error(
|
|
393
393
|
`Unknown prop type for method return type, found: ${realTypeAnnotation.type}"`,
|
|
394
394
|
);
|
|
@@ -155,7 +155,7 @@ class StructCollector {
|
|
|
155
155
|
type: 'StringTypeAnnotation',
|
|
156
156
|
});
|
|
157
157
|
default:
|
|
158
|
-
|
|
158
|
+
validUnionType as empty;
|
|
159
159
|
throw new Error(`Unsupported union member types`);
|
|
160
160
|
}
|
|
161
161
|
} catch (ex) {
|
|
@@ -235,7 +235,7 @@ class StructCollector {
|
|
|
235
235
|
});
|
|
236
236
|
break;
|
|
237
237
|
default:
|
|
238
|
-
|
|
238
|
+
structContext as empty;
|
|
239
239
|
throw new Error(`Detected an invalid struct context: ${structContext}`);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -96,7 +96,7 @@ function toObjCValue(
|
|
|
96
96
|
case 'RootTag':
|
|
97
97
|
return wrapPrimitive('double');
|
|
98
98
|
default:
|
|
99
|
-
|
|
99
|
+
typeAnnotation.name as empty;
|
|
100
100
|
throw new Error(
|
|
101
101
|
`Couldn't convert into ObjC type: ${typeAnnotation.type}"`,
|
|
102
102
|
);
|
|
@@ -167,7 +167,7 @@ function toObjCValue(
|
|
|
167
167
|
? `${value}.has_value() ? ${value}.value().buildUnsafeRawValue() : nil`
|
|
168
168
|
: `${value}.buildUnsafeRawValue()`;
|
|
169
169
|
default:
|
|
170
|
-
|
|
170
|
+
typeAnnotation.type as empty;
|
|
171
171
|
throw new Error(
|
|
172
172
|
`Couldn't convert into ObjC value: ${typeAnnotation.type}"`,
|
|
173
173
|
);
|
|
@@ -85,7 +85,7 @@ function toObjCValue(
|
|
|
85
85
|
case 'RootTag':
|
|
86
86
|
return RCTBridgingTo('Double');
|
|
87
87
|
default:
|
|
88
|
-
|
|
88
|
+
typeAnnotation.name as empty;
|
|
89
89
|
throw new Error(
|
|
90
90
|
`Couldn't convert into ObjC type: ${typeAnnotation.type}"`,
|
|
91
91
|
);
|
|
@@ -159,7 +159,7 @@ function toObjCValue(
|
|
|
159
159
|
? `(${value} == nil ? std::nullopt : std::make_optional(${namespacedStructName}(${value})))`
|
|
160
160
|
: `${namespacedStructName}(${value})`;
|
|
161
161
|
default:
|
|
162
|
-
|
|
162
|
+
typeAnnotation.type as empty;
|
|
163
163
|
throw new Error(
|
|
164
164
|
`Couldn't convert into ObjC value: ${typeAnnotation.type}"`,
|
|
165
165
|
);
|
|
@@ -36,7 +36,7 @@ function toObjCType(
|
|
|
36
36
|
case 'RootTag':
|
|
37
37
|
return wrapCxxOptional('double', isRequired);
|
|
38
38
|
default:
|
|
39
|
-
|
|
39
|
+
typeAnnotation.name as empty;
|
|
40
40
|
throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`);
|
|
41
41
|
}
|
|
42
42
|
case 'StringTypeAnnotation':
|
|
@@ -105,7 +105,7 @@ function toObjCType(
|
|
|
105
105
|
isRequired,
|
|
106
106
|
);
|
|
107
107
|
default:
|
|
108
|
-
|
|
108
|
+
typeAnnotation.type as empty;
|
|
109
109
|
throw new Error(
|
|
110
110
|
`Couldn't convert into ObjC type: ${typeAnnotation.type}"`,
|
|
111
111
|
);
|
|
@@ -34,7 +34,7 @@ function getEventEmitterTypeObjCType(
|
|
|
34
34
|
case 'string':
|
|
35
35
|
return 'NSString *_Nonnull';
|
|
36
36
|
default:
|
|
37
|
-
|
|
37
|
+
validUnionType as empty;
|
|
38
38
|
throw new Error(`Unsupported union member type`);
|
|
39
39
|
}
|
|
40
40
|
case 'NumberTypeAnnotation':
|
|
@@ -58,7 +58,7 @@ function getEventEmitterTypeObjCType(
|
|
|
58
58
|
`Unsupported eventType for ${eventEmitter.name}. Found: ${eventEmitter.typeAnnotation.typeAnnotation.type}`,
|
|
59
59
|
);
|
|
60
60
|
default:
|
|
61
|
-
|
|
61
|
+
typeAnnotation.type as empty;
|
|
62
62
|
throw new Error(
|
|
63
63
|
`Unsupported eventType for ${eventEmitter.name}. Found: ${eventEmitter.typeAnnotation.typeAnnotation.type}`,
|
|
64
64
|
);
|
|
@@ -250,7 +250,7 @@ function getParamObjCType(
|
|
|
250
250
|
case 'RootTag':
|
|
251
251
|
return notStruct(isRequired ? 'double' : 'NSNumber *');
|
|
252
252
|
default:
|
|
253
|
-
|
|
253
|
+
structTypeAnnotation.name as empty;
|
|
254
254
|
throw new Error(
|
|
255
255
|
`Unsupported type for param "${paramName}" in ${methodName}. Found: ${structTypeAnnotation.type}`,
|
|
256
256
|
);
|
|
@@ -290,7 +290,7 @@ function getParamObjCType(
|
|
|
290
290
|
case 'GenericObjectTypeAnnotation':
|
|
291
291
|
return notStruct(wrapOptional('NSDictionary *', !nullable));
|
|
292
292
|
default:
|
|
293
|
-
|
|
293
|
+
structTypeAnnotation.type as empty;
|
|
294
294
|
throw new Error(
|
|
295
295
|
`Unsupported type for param "${paramName}" in ${methodName}. Found: ${typeAnnotation.type}`,
|
|
296
296
|
);
|
|
@@ -330,7 +330,7 @@ function getReturnObjCType(
|
|
|
330
330
|
case 'RootTag':
|
|
331
331
|
return wrapOptional('NSNumber *', isRequired);
|
|
332
332
|
default:
|
|
333
|
-
|
|
333
|
+
typeAnnotation.name as empty;
|
|
334
334
|
throw new Error(
|
|
335
335
|
`Unsupported return type for ${methodName}. Found: ${typeAnnotation.name}`,
|
|
336
336
|
);
|
|
@@ -382,13 +382,13 @@ function getReturnObjCType(
|
|
|
382
382
|
// In the legacy codegen, we don't surround NSSTring * with _Nullable
|
|
383
383
|
return wrapOptional('NSString *', isRequired);
|
|
384
384
|
default:
|
|
385
|
-
|
|
385
|
+
validUnionType as empty;
|
|
386
386
|
throw new Error(`Unsupported union member type`);
|
|
387
387
|
}
|
|
388
388
|
case 'GenericObjectTypeAnnotation':
|
|
389
389
|
return wrapOptional('NSDictionary *', isRequired);
|
|
390
390
|
default:
|
|
391
|
-
|
|
391
|
+
typeAnnotation.type as 'MixedTypeAnnotation';
|
|
392
392
|
throw new Error(
|
|
393
393
|
`Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`,
|
|
394
394
|
);
|
|
@@ -456,11 +456,11 @@ function getReturnJSType(
|
|
|
456
456
|
case 'string':
|
|
457
457
|
return 'StringKind';
|
|
458
458
|
default:
|
|
459
|
-
|
|
459
|
+
validUnionType as empty;
|
|
460
460
|
throw new Error(`Unsupported union member types`);
|
|
461
461
|
}
|
|
462
462
|
default:
|
|
463
|
-
|
|
463
|
+
typeAnnotation.type as 'MixedTypeAnnotation';
|
|
464
464
|
throw new Error(
|
|
465
465
|
`Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`,
|
|
466
466
|
);
|
|
@@ -169,7 +169,7 @@ function getTypeAnnotationForArray<+T>(
|
|
|
169
169
|
if (unionType === 'StringLiteralTypeAnnotation') {
|
|
170
170
|
return {
|
|
171
171
|
type: 'StringEnumTypeAnnotation',
|
|
172
|
-
default:
|
|
172
|
+
default: defaultValue as string,
|
|
173
173
|
options: typeAnnotation.types.map(option => option.value),
|
|
174
174
|
};
|
|
175
175
|
} else if (unionType === 'NumberLiteralTypeAnnotation') {
|
|
@@ -313,32 +313,32 @@ function getTypeAnnotation<+T>(
|
|
|
313
313
|
case 'Int32':
|
|
314
314
|
return {
|
|
315
315
|
type: 'Int32TypeAnnotation',
|
|
316
|
-
default: (
|
|
316
|
+
default: (defaultValue ? defaultValue : 0) as number,
|
|
317
317
|
};
|
|
318
318
|
case 'Double':
|
|
319
319
|
return {
|
|
320
320
|
type: 'DoubleTypeAnnotation',
|
|
321
|
-
default: (
|
|
321
|
+
default: (defaultValue ? defaultValue : 0) as number,
|
|
322
322
|
};
|
|
323
323
|
case 'Float':
|
|
324
324
|
return {
|
|
325
325
|
type: 'FloatTypeAnnotation',
|
|
326
326
|
default: withNullDefault
|
|
327
|
-
? (defaultValue
|
|
328
|
-
: ((defaultValue ? defaultValue : 0)
|
|
327
|
+
? (defaultValue as number | null)
|
|
328
|
+
: ((defaultValue ? defaultValue : 0) as number),
|
|
329
329
|
};
|
|
330
330
|
case 'BooleanTypeAnnotation':
|
|
331
331
|
return {
|
|
332
332
|
type: 'BooleanTypeAnnotation',
|
|
333
333
|
default: withNullDefault
|
|
334
|
-
? (defaultValue
|
|
335
|
-
: ((defaultValue == null ? false : defaultValue)
|
|
334
|
+
? (defaultValue as boolean | null)
|
|
335
|
+
: ((defaultValue == null ? false : defaultValue) as boolean),
|
|
336
336
|
};
|
|
337
337
|
case 'StringTypeAnnotation':
|
|
338
338
|
if (typeof defaultValue !== 'undefined') {
|
|
339
339
|
return {
|
|
340
340
|
type: 'StringTypeAnnotation',
|
|
341
|
-
default:
|
|
341
|
+
default: defaultValue as string | null,
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
throw new Error(`A default string (or null) is required for "${name}"`);
|
|
@@ -346,7 +346,7 @@ function getTypeAnnotation<+T>(
|
|
|
346
346
|
if (typeof defaultValue !== 'undefined') {
|
|
347
347
|
return {
|
|
348
348
|
type: 'StringTypeAnnotation',
|
|
349
|
-
default:
|
|
349
|
+
default: defaultValue as string | null,
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
352
|
throw new Error(`A default string (or null) is required for "${name}"`);
|
|
@@ -366,13 +366,13 @@ function getTypeAnnotation<+T>(
|
|
|
366
366
|
if (unionType === 'StringLiteralTypeAnnotation') {
|
|
367
367
|
return {
|
|
368
368
|
type: 'StringEnumTypeAnnotation',
|
|
369
|
-
default:
|
|
369
|
+
default: defaultValue as string,
|
|
370
370
|
options: typeAnnotation.types.map(option => option.value),
|
|
371
371
|
};
|
|
372
372
|
} else if (unionType === 'NumberLiteralTypeAnnotation') {
|
|
373
373
|
return {
|
|
374
374
|
type: 'Int32EnumTypeAnnotation',
|
|
375
|
-
default:
|
|
375
|
+
default: defaultValue as number,
|
|
376
376
|
options: typeAnnotation.types.map(option => option.value),
|
|
377
377
|
};
|
|
378
378
|
} else {
|
|
@@ -197,10 +197,12 @@ function translateTypeAnnotation(
|
|
|
197
197
|
const objectTypeAnnotation = {
|
|
198
198
|
type: 'ObjectTypeAnnotation',
|
|
199
199
|
// $FlowFixMe[missing-type-arg]
|
|
200
|
-
properties: (
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
properties: (
|
|
201
|
+
[
|
|
202
|
+
...typeAnnotation.properties,
|
|
203
|
+
...typeAnnotation.indexers,
|
|
204
|
+
] as Array<$FlowFixMe>
|
|
205
|
+
)
|
|
204
206
|
.map<?NamedShape<Nullable<NativeModuleBaseTypeAnnotation>>>(
|
|
205
207
|
property => {
|
|
206
208
|
return tryParse(() => {
|
|
@@ -763,9 +763,9 @@ const buildModuleSchema = (
|
|
|
763
763
|
): NativeModuleSchema => {
|
|
764
764
|
const language = parser.language();
|
|
765
765
|
const types = parser.getTypes(ast);
|
|
766
|
-
const moduleSpecs = (
|
|
767
|
-
|
|
768
|
-
);
|
|
766
|
+
const moduleSpecs = (
|
|
767
|
+
Object.values(types) as ReadonlyArray<$FlowFixMe>
|
|
768
|
+
).filter(t => parser.isModuleInterface(t));
|
|
769
769
|
|
|
770
770
|
throwIfModuleInterfaceNotFound(
|
|
771
771
|
moduleSpecs.length,
|
|
@@ -436,7 +436,7 @@ function emitUnion(
|
|
|
436
436
|
parser: Parser,
|
|
437
437
|
): Nullable<NativeModuleUnionTypeAnnotation> {
|
|
438
438
|
const unparsedMemberTypes: ReadonlyArray<$FlowFixMe> =
|
|
439
|
-
|
|
439
|
+
typeAnnotation.types as ReadonlyArray<$FlowFixMe>;
|
|
440
440
|
|
|
441
441
|
const memberTypes = unparsedMemberTypes.map(
|
|
442
442
|
(memberType: $FlowFixMe): NativeModuleUnionTypeAnnotationMemberType => {
|
|
@@ -51,7 +51,7 @@ function getUnionOfLiterals(
|
|
|
51
51
|
) {
|
|
52
52
|
return {
|
|
53
53
|
type: 'StringEnumTypeAnnotation',
|
|
54
|
-
default:
|
|
54
|
+
default: defaultValue as string,
|
|
55
55
|
options: elementTypes.map(option => option.literal.value),
|
|
56
56
|
};
|
|
57
57
|
} else if (
|
|
@@ -63,7 +63,7 @@ function getUnionOfLiterals(
|
|
|
63
63
|
} else {
|
|
64
64
|
return {
|
|
65
65
|
type: 'Int32EnumTypeAnnotation',
|
|
66
|
-
default:
|
|
66
|
+
default: defaultValue as number,
|
|
67
67
|
options: elementTypes.map(option => option.literal.value),
|
|
68
68
|
};
|
|
69
69
|
}
|
|
@@ -335,7 +335,7 @@ function getTypeAnnotationForArray<T>(
|
|
|
335
335
|
type: 'FloatTypeAnnotation',
|
|
336
336
|
};
|
|
337
337
|
default:
|
|
338
|
-
(type
|
|
338
|
+
(type) as unknown;
|
|
339
339
|
throw new Error(`Unknown prop type for "${name}": ${type}`);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
@@ -347,16 +347,15 @@ function setDefaultValue(
|
|
|
347
347
|
switch (common.type) {
|
|
348
348
|
case 'Int32TypeAnnotation':
|
|
349
349
|
case 'DoubleTypeAnnotation':
|
|
350
|
-
common.default = (
|
|
350
|
+
common.default = (defaultValue ? defaultValue : 0) as number;
|
|
351
351
|
break;
|
|
352
352
|
case 'FloatTypeAnnotation':
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
? null
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
: 0): number | null);
|
|
353
|
+
common.default =
|
|
354
|
+
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
|
|
355
|
+
* roll out. See https://fburl.com/workplace/5whu3i34. */
|
|
356
|
+
(defaultValue === null ? null : defaultValue ? defaultValue : 0) as
|
|
357
|
+
| number
|
|
358
|
+
| null;
|
|
360
359
|
break;
|
|
361
360
|
case 'BooleanTypeAnnotation':
|
|
362
361
|
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
|
|
@@ -364,9 +363,9 @@ function setDefaultValue(
|
|
|
364
363
|
common.default = defaultValue === null ? null : !!defaultValue;
|
|
365
364
|
break;
|
|
366
365
|
case 'StringTypeAnnotation':
|
|
367
|
-
common.default = (
|
|
366
|
+
common.default = (defaultValue === undefined ? null : defaultValue) as
|
|
368
367
|
| string
|
|
369
|
-
| null
|
|
368
|
+
| null;
|
|
370
369
|
break;
|
|
371
370
|
}
|
|
372
371
|
}
|