@react-native/codegen 0.84.0-nightly-20251119-79b09ce9c → 0.84.0-nightly-20251121-2bbb104a4
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/CodegenSchema.d.ts +33 -8
- package/lib/CodegenSchema.js.flow +25 -0
- package/lib/generators/modules/GenerateModuleH.js +4 -0
- package/lib/generators/modules/GenerateModuleH.js.flow +4 -0
- package/lib/generators/modules/GenerateModuleJavaSpec.js +7 -0
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +7 -0
- package/lib/generators/modules/GenerateModuleJniCpp.js +6 -0
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +6 -0
- package/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js.flow +2 -0
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +4 -0
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js.flow +4 -0
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +4 -0
- package/lib/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js.flow +4 -0
- package/lib/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js +1 -0
- package/lib/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js +6 -0
- package/lib/generators/modules/GenerateModuleObjCpp/serializeMethod.js.flow +6 -0
- package/lib/parsers/flow/modules/index.js +4 -0
- package/lib/parsers/flow/modules/index.js.flow +4 -0
- package/lib/parsers/parsers-primitives.js +7 -0
- package/lib/parsers/parsers-primitives.js.flow +12 -0
- package/lib/parsers/typescript/modules/index.js +4 -0
- package/lib/parsers/typescript/modules/index.js.flow +4 -0
- package/package.json +1 -1
package/lib/CodegenSchema.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export interface FloatTypeAnnotation {
|
|
|
26
26
|
readonly type: 'FloatTypeAnnotation';
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export interface NumberTypeAnnotation {
|
|
30
|
+
readonly type: 'NumberTypeAnnotation';
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
export interface BooleanTypeAnnotation {
|
|
30
34
|
readonly type: 'BooleanTypeAnnotation';
|
|
31
35
|
}
|
|
@@ -42,6 +46,11 @@ export interface VoidTypeAnnotation {
|
|
|
42
46
|
readonly type: 'VoidTypeAnnotation';
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
export interface BooleanLiteralTypeAnnotation {
|
|
50
|
+
readonly type: 'BooleanLiteralTypeAnnotation';
|
|
51
|
+
readonly value: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
export interface ObjectTypeAnnotation<T> {
|
|
46
55
|
readonly type: 'ObjectTypeAnnotation';
|
|
47
56
|
readonly properties: readonly NamedShape<T>[];
|
|
@@ -49,6 +58,11 @@ export interface ObjectTypeAnnotation<T> {
|
|
|
49
58
|
readonly baseTypes?: readonly string[] | undefined;
|
|
50
59
|
}
|
|
51
60
|
|
|
61
|
+
export interface UnionTypeAnnotation<T> {
|
|
62
|
+
readonly type: 'UnionTypeAnnotation';
|
|
63
|
+
readonly types: readonly T[];
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
export interface MixedTypeAnnotation {
|
|
53
67
|
readonly type: 'MixedTypeAnnotation';
|
|
54
68
|
}
|
|
@@ -290,7 +304,7 @@ export interface UnsafeAnyTypeAnnotation {
|
|
|
290
304
|
readonly type: 'AnyTypeAnnotation',
|
|
291
305
|
}
|
|
292
306
|
|
|
293
|
-
export interface
|
|
307
|
+
export interface NumberLiteralTypeAnnotation {
|
|
294
308
|
readonly type: 'NumberLiteralTypeAnnotation';
|
|
295
309
|
readonly value: number;
|
|
296
310
|
}
|
|
@@ -299,14 +313,14 @@ export interface NativeModuleStringTypeAnnotation {
|
|
|
299
313
|
readonly type: 'StringTypeAnnotation';
|
|
300
314
|
}
|
|
301
315
|
|
|
302
|
-
export interface
|
|
316
|
+
export interface StringLiteralTypeAnnotation {
|
|
303
317
|
readonly type: 'StringLiteralTypeAnnotation';
|
|
304
318
|
readonly value: string;
|
|
305
319
|
}
|
|
306
320
|
|
|
307
321
|
export interface StringLiteralUnionTypeAnnotation {
|
|
308
322
|
readonly type: 'StringLiteralUnionTypeAnnotation';
|
|
309
|
-
readonly types:
|
|
323
|
+
readonly types: StringLiteralTypeAnnotation[];
|
|
310
324
|
}
|
|
311
325
|
|
|
312
326
|
export interface NativeModuleNumberTypeAnnotation {
|
|
@@ -331,7 +345,7 @@ export interface NativeModuleBooleanTypeAnnotation {
|
|
|
331
345
|
|
|
332
346
|
export type NativeModuleEnumMember = {
|
|
333
347
|
readonly name: string;
|
|
334
|
-
readonly value:
|
|
348
|
+
readonly value: StringLiteralTypeAnnotation | NumberLiteralTypeAnnotation,
|
|
335
349
|
};
|
|
336
350
|
|
|
337
351
|
export type NativeModuleEnumMemberType =
|
|
@@ -374,6 +388,15 @@ export type UnionTypeAnnotationMemberType =
|
|
|
374
388
|
| 'ObjectTypeAnnotation'
|
|
375
389
|
| 'StringTypeAnnotation';
|
|
376
390
|
|
|
391
|
+
export type NativeModuleUnionTypeAnnotationMemberType =
|
|
392
|
+
| NativeModuleObjectTypeAnnotation
|
|
393
|
+
| StringLiteralTypeAnnotation
|
|
394
|
+
| NumberLiteralTypeAnnotation
|
|
395
|
+
| BooleanLiteralTypeAnnotation
|
|
396
|
+
| BooleanTypeAnnotation
|
|
397
|
+
| StringTypeAnnotation
|
|
398
|
+
| NumberTypeAnnotation;
|
|
399
|
+
|
|
377
400
|
export interface NativeModuleUnionTypeAnnotation {
|
|
378
401
|
readonly type: 'UnionTypeAnnotation';
|
|
379
402
|
readonly memberType: UnionTypeAnnotationMemberType;
|
|
@@ -389,9 +412,10 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
|
|
|
389
412
|
| NativeModuleFloatTypeAnnotation
|
|
390
413
|
| NativeModuleInt32TypeAnnotation
|
|
391
414
|
| NativeModuleNumberTypeAnnotation
|
|
392
|
-
|
|
|
415
|
+
| NumberLiteralTypeAnnotation
|
|
416
|
+
| BooleanLiteralTypeAnnotation
|
|
393
417
|
| NativeModuleStringTypeAnnotation
|
|
394
|
-
|
|
|
418
|
+
| StringLiteralTypeAnnotation
|
|
395
419
|
| StringLiteralUnionTypeAnnotation
|
|
396
420
|
| NativeModuleTypeAliasTypeAnnotation
|
|
397
421
|
| NativeModuleGenericObjectTypeAnnotation
|
|
@@ -403,10 +427,11 @@ export type NativeModuleEventEmitterTypeAnnotation =
|
|
|
403
427
|
|
|
404
428
|
export type NativeModuleBaseTypeAnnotation =
|
|
405
429
|
NativeModuleStringTypeAnnotation
|
|
406
|
-
|
|
|
430
|
+
| StringLiteralTypeAnnotation
|
|
407
431
|
| StringLiteralUnionTypeAnnotation
|
|
408
432
|
| NativeModuleNumberTypeAnnotation
|
|
409
|
-
|
|
|
433
|
+
| NumberLiteralTypeAnnotation
|
|
434
|
+
| BooleanLiteralTypeAnnotation
|
|
410
435
|
| NativeModuleInt32TypeAnnotation
|
|
411
436
|
| NativeModuleDoubleTypeAnnotation
|
|
412
437
|
| NativeModuleFloatTypeAnnotation
|
|
@@ -30,6 +30,10 @@ export type FloatTypeAnnotation = $ReadOnly<{
|
|
|
30
30
|
type: 'FloatTypeAnnotation',
|
|
31
31
|
}>;
|
|
32
32
|
|
|
33
|
+
export type NumberTypeAnnotation = $ReadOnly<{
|
|
34
|
+
type: 'NumberTypeAnnotation',
|
|
35
|
+
}>;
|
|
36
|
+
|
|
33
37
|
export type BooleanTypeAnnotation = $ReadOnly<{
|
|
34
38
|
type: 'BooleanTypeAnnotation',
|
|
35
39
|
}>;
|
|
@@ -52,6 +56,11 @@ export type StringLiteralTypeAnnotation = $ReadOnly<{
|
|
|
52
56
|
value: string,
|
|
53
57
|
}>;
|
|
54
58
|
|
|
59
|
+
export type BooleanLiteralTypeAnnotation = $ReadOnly<{
|
|
60
|
+
type: 'BooleanLiteralTypeAnnotation',
|
|
61
|
+
value: boolean,
|
|
62
|
+
}>;
|
|
63
|
+
|
|
55
64
|
export type StringLiteralUnionTypeAnnotation = $ReadOnly<{
|
|
56
65
|
type: 'StringLiteralUnionTypeAnnotation',
|
|
57
66
|
types: $ReadOnlyArray<StringLiteralTypeAnnotation>,
|
|
@@ -68,6 +77,11 @@ export type ObjectTypeAnnotation<+T> = $ReadOnly<{
|
|
|
68
77
|
baseTypes?: $ReadOnlyArray<string>,
|
|
69
78
|
}>;
|
|
70
79
|
|
|
80
|
+
export type UnionTypeAnnotation<+T> = $ReadOnly<{
|
|
81
|
+
type: 'UnionTypeAnnotation',
|
|
82
|
+
types: $ReadOnlyArray<T>,
|
|
83
|
+
}>;
|
|
84
|
+
|
|
71
85
|
export type MixedTypeAnnotation = $ReadOnly<{
|
|
72
86
|
type: 'MixedTypeAnnotation',
|
|
73
87
|
}>;
|
|
@@ -363,6 +377,15 @@ export type UnionTypeAnnotationMemberType =
|
|
|
363
377
|
| 'ObjectTypeAnnotation'
|
|
364
378
|
| 'StringTypeAnnotation';
|
|
365
379
|
|
|
380
|
+
export type NativeModuleUnionTypeAnnotationMemberType =
|
|
381
|
+
| NativeModuleObjectTypeAnnotation
|
|
382
|
+
| StringLiteralTypeAnnotation
|
|
383
|
+
| NumberLiteralTypeAnnotation
|
|
384
|
+
| BooleanLiteralTypeAnnotation
|
|
385
|
+
| BooleanTypeAnnotation
|
|
386
|
+
| StringTypeAnnotation
|
|
387
|
+
| NumberTypeAnnotation;
|
|
388
|
+
|
|
366
389
|
export type NativeModuleUnionTypeAnnotation = $ReadOnly<{
|
|
367
390
|
type: 'UnionTypeAnnotation',
|
|
368
391
|
memberType: UnionTypeAnnotationMemberType,
|
|
@@ -379,6 +402,7 @@ type NativeModuleEventEmitterBaseTypeAnnotation =
|
|
|
379
402
|
| Int32TypeAnnotation
|
|
380
403
|
| NativeModuleNumberTypeAnnotation
|
|
381
404
|
| NumberLiteralTypeAnnotation
|
|
405
|
+
| BooleanLiteralTypeAnnotation
|
|
382
406
|
| StringTypeAnnotation
|
|
383
407
|
| StringLiteralTypeAnnotation
|
|
384
408
|
| StringLiteralUnionTypeAnnotation
|
|
@@ -396,6 +420,7 @@ export type NativeModuleBaseTypeAnnotation =
|
|
|
396
420
|
| StringLiteralUnionTypeAnnotation
|
|
397
421
|
| NativeModuleNumberTypeAnnotation
|
|
398
422
|
| NumberLiteralTypeAnnotation
|
|
423
|
+
| BooleanLiteralTypeAnnotation
|
|
399
424
|
| Int32TypeAnnotation
|
|
400
425
|
| DoubleTypeAnnotation
|
|
401
426
|
| FloatTypeAnnotation
|
|
@@ -64,6 +64,8 @@ function serializeArg(moduleName, arg, index, resolveAlias, enumMap) {
|
|
|
64
64
|
return wrap(val => `${val}.asString(rt)`);
|
|
65
65
|
case 'BooleanTypeAnnotation':
|
|
66
66
|
return wrap(val => `${val}.asBool()`);
|
|
67
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
68
|
+
return wrap(val => `${val}.asBool()`);
|
|
67
69
|
case 'EnumDeclaration':
|
|
68
70
|
switch (realTypeAnnotation.memberType) {
|
|
69
71
|
case 'NumberTypeAnnotation':
|
|
@@ -215,6 +217,8 @@ function translatePrimitiveJSTypeToCpp(
|
|
|
215
217
|
return wrapOptional('int', isRequired);
|
|
216
218
|
case 'BooleanTypeAnnotation':
|
|
217
219
|
return wrapOptional('bool', isRequired);
|
|
220
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
221
|
+
return wrapOptional('bool', isRequired);
|
|
218
222
|
case 'EnumDeclaration':
|
|
219
223
|
switch (realTypeAnnotation.memberType) {
|
|
220
224
|
case 'NumberTypeAnnotation':
|
|
@@ -96,6 +96,8 @@ function serializeArg(
|
|
|
96
96
|
return wrap(val => `${val}.asString(rt)`);
|
|
97
97
|
case 'BooleanTypeAnnotation':
|
|
98
98
|
return wrap(val => `${val}.asBool()`);
|
|
99
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
100
|
+
return wrap(val => `${val}.asBool()`);
|
|
99
101
|
case 'EnumDeclaration':
|
|
100
102
|
switch (realTypeAnnotation.memberType) {
|
|
101
103
|
case 'NumberTypeAnnotation':
|
|
@@ -265,6 +267,8 @@ function translatePrimitiveJSTypeToCpp(
|
|
|
265
267
|
return wrapOptional('int', isRequired);
|
|
266
268
|
case 'BooleanTypeAnnotation':
|
|
267
269
|
return wrapOptional('bool', isRequired);
|
|
270
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
271
|
+
return wrapOptional('bool', isRequired);
|
|
268
272
|
case 'EnumDeclaration':
|
|
269
273
|
switch (realTypeAnnotation.memberType) {
|
|
270
274
|
case 'NumberTypeAnnotation':
|
|
@@ -88,6 +88,7 @@ function translateEventEmitterTypeToJavaType(eventEmitter, imports) {
|
|
|
88
88
|
case 'Int32TypeAnnotation':
|
|
89
89
|
return 'double';
|
|
90
90
|
case 'BooleanTypeAnnotation':
|
|
91
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
91
92
|
return 'boolean';
|
|
92
93
|
case 'GenericObjectTypeAnnotation':
|
|
93
94
|
case 'ObjectTypeAnnotation':
|
|
@@ -157,6 +158,8 @@ function translateFunctionParamToJavaType(
|
|
|
157
158
|
return wrapOptional('double', isRequired);
|
|
158
159
|
case 'BooleanTypeAnnotation':
|
|
159
160
|
return wrapOptional('boolean', isRequired);
|
|
161
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
162
|
+
return wrapOptional('boolean', isRequired);
|
|
160
163
|
case 'EnumDeclaration':
|
|
161
164
|
switch (realTypeAnnotation.memberType) {
|
|
162
165
|
case 'NumberTypeAnnotation':
|
|
@@ -248,6 +251,8 @@ function translateFunctionReturnTypeToJavaType(
|
|
|
248
251
|
return wrapOptional('double', isRequired);
|
|
249
252
|
case 'BooleanTypeAnnotation':
|
|
250
253
|
return wrapOptional('boolean', isRequired);
|
|
254
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
255
|
+
return wrapOptional('boolean', isRequired);
|
|
251
256
|
case 'EnumDeclaration':
|
|
252
257
|
switch (realTypeAnnotation.memberType) {
|
|
253
258
|
case 'NumberTypeAnnotation':
|
|
@@ -322,6 +327,8 @@ function getFalsyReturnStatementFromReturnType(
|
|
|
322
327
|
return nullable ? 'return null;' : 'return 0;';
|
|
323
328
|
case 'BooleanTypeAnnotation':
|
|
324
329
|
return nullable ? 'return null;' : 'return false;';
|
|
330
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
331
|
+
return nullable ? 'return null;' : 'return false;';
|
|
325
332
|
case 'EnumDeclaration':
|
|
326
333
|
switch (realTypeAnnotation.memberType) {
|
|
327
334
|
case 'NumberTypeAnnotation':
|
|
@@ -142,6 +142,7 @@ function translateEventEmitterTypeToJavaType(
|
|
|
142
142
|
case 'Int32TypeAnnotation':
|
|
143
143
|
return 'double';
|
|
144
144
|
case 'BooleanTypeAnnotation':
|
|
145
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
145
146
|
return 'boolean';
|
|
146
147
|
case 'GenericObjectTypeAnnotation':
|
|
147
148
|
case 'ObjectTypeAnnotation':
|
|
@@ -214,6 +215,8 @@ function translateFunctionParamToJavaType(
|
|
|
214
215
|
return wrapOptional('double', isRequired);
|
|
215
216
|
case 'BooleanTypeAnnotation':
|
|
216
217
|
return wrapOptional('boolean', isRequired);
|
|
218
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
219
|
+
return wrapOptional('boolean', isRequired);
|
|
217
220
|
case 'EnumDeclaration':
|
|
218
221
|
switch (realTypeAnnotation.memberType) {
|
|
219
222
|
case 'NumberTypeAnnotation':
|
|
@@ -310,6 +313,8 @@ function translateFunctionReturnTypeToJavaType(
|
|
|
310
313
|
return wrapOptional('double', isRequired);
|
|
311
314
|
case 'BooleanTypeAnnotation':
|
|
312
315
|
return wrapOptional('boolean', isRequired);
|
|
316
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
317
|
+
return wrapOptional('boolean', isRequired);
|
|
313
318
|
case 'EnumDeclaration':
|
|
314
319
|
switch (realTypeAnnotation.memberType) {
|
|
315
320
|
case 'NumberTypeAnnotation':
|
|
@@ -388,6 +393,8 @@ function getFalsyReturnStatementFromReturnType(
|
|
|
388
393
|
return nullable ? 'return null;' : 'return 0;';
|
|
389
394
|
case 'BooleanTypeAnnotation':
|
|
390
395
|
return nullable ? 'return null;' : 'return false;';
|
|
396
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
397
|
+
return nullable ? 'return null;' : 'return false;';
|
|
391
398
|
case 'EnumDeclaration':
|
|
392
399
|
switch (realTypeAnnotation.memberType) {
|
|
393
400
|
case 'NumberTypeAnnotation':
|
|
@@ -109,6 +109,8 @@ function translateReturnTypeToKind(nullableTypeAnnotation, resolveAlias) {
|
|
|
109
109
|
return 'StringKind';
|
|
110
110
|
case 'BooleanTypeAnnotation':
|
|
111
111
|
return 'BooleanKind';
|
|
112
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
113
|
+
return 'BooleanKind';
|
|
112
114
|
case 'EnumDeclaration':
|
|
113
115
|
switch (typeAnnotation.memberType) {
|
|
114
116
|
case 'NumberTypeAnnotation':
|
|
@@ -185,6 +187,8 @@ function translateParamTypeToJniType(param, resolveAlias) {
|
|
|
185
187
|
return 'Ljava/lang/String;';
|
|
186
188
|
case 'BooleanTypeAnnotation':
|
|
187
189
|
return !isRequired ? 'Ljava/lang/Boolean;' : 'Z';
|
|
190
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
191
|
+
return !isRequired ? 'Ljava/lang/Boolean;' : 'Z';
|
|
188
192
|
case 'EnumDeclaration':
|
|
189
193
|
switch (typeAnnotation.memberType) {
|
|
190
194
|
case 'NumberTypeAnnotation':
|
|
@@ -261,6 +265,8 @@ function translateReturnTypeToJniType(nullableTypeAnnotation, resolveAlias) {
|
|
|
261
265
|
return 'Ljava/lang/String;';
|
|
262
266
|
case 'BooleanTypeAnnotation':
|
|
263
267
|
return nullable ? 'Ljava/lang/Boolean;' : 'Z';
|
|
268
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
269
|
+
return nullable ? 'Ljava/lang/Boolean;' : 'Z';
|
|
264
270
|
case 'EnumDeclaration':
|
|
265
271
|
switch (typeAnnotation.memberType) {
|
|
266
272
|
case 'NumberTypeAnnotation':
|
|
@@ -171,6 +171,8 @@ function translateReturnTypeToKind(
|
|
|
171
171
|
return 'StringKind';
|
|
172
172
|
case 'BooleanTypeAnnotation':
|
|
173
173
|
return 'BooleanKind';
|
|
174
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
175
|
+
return 'BooleanKind';
|
|
174
176
|
case 'EnumDeclaration':
|
|
175
177
|
switch (typeAnnotation.memberType) {
|
|
176
178
|
case 'NumberTypeAnnotation':
|
|
@@ -256,6 +258,8 @@ function translateParamTypeToJniType(
|
|
|
256
258
|
return 'Ljava/lang/String;';
|
|
257
259
|
case 'BooleanTypeAnnotation':
|
|
258
260
|
return !isRequired ? 'Ljava/lang/Boolean;' : 'Z';
|
|
261
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
262
|
+
return !isRequired ? 'Ljava/lang/Boolean;' : 'Z';
|
|
259
263
|
case 'EnumDeclaration':
|
|
260
264
|
switch (typeAnnotation.memberType) {
|
|
261
265
|
case 'NumberTypeAnnotation':
|
|
@@ -338,6 +342,8 @@ function translateReturnTypeToJniType(
|
|
|
338
342
|
return 'Ljava/lang/String;';
|
|
339
343
|
case 'BooleanTypeAnnotation':
|
|
340
344
|
return nullable ? 'Ljava/lang/Boolean;' : 'Z';
|
|
345
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
346
|
+
return nullable ? 'Ljava/lang/Boolean;' : 'Z';
|
|
341
347
|
case 'EnumDeclaration':
|
|
342
348
|
switch (typeAnnotation.memberType) {
|
|
343
349
|
case 'NumberTypeAnnotation':
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {
|
|
14
|
+
BooleanLiteralTypeAnnotation,
|
|
14
15
|
BooleanTypeAnnotation,
|
|
15
16
|
DoubleTypeAnnotation,
|
|
16
17
|
FloatTypeAnnotation,
|
|
@@ -65,6 +66,7 @@ export type StructTypeAnnotation =
|
|
|
65
66
|
| StringLiteralUnionTypeAnnotation
|
|
66
67
|
| NativeModuleNumberTypeAnnotation
|
|
67
68
|
| NumberLiteralTypeAnnotation
|
|
69
|
+
| BooleanLiteralTypeAnnotation
|
|
68
70
|
| Int32TypeAnnotation
|
|
69
71
|
| DoubleTypeAnnotation
|
|
70
72
|
| FloatTypeAnnotation
|
|
@@ -94,6 +94,8 @@ function toObjCType(
|
|
|
94
94
|
return wrapCxxOptional('double', isRequired);
|
|
95
95
|
case 'BooleanTypeAnnotation':
|
|
96
96
|
return wrapCxxOptional('bool', isRequired);
|
|
97
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
98
|
+
return wrapCxxOptional('bool', isRequired);
|
|
97
99
|
case 'EnumDeclaration':
|
|
98
100
|
switch (typeAnnotation.memberType) {
|
|
99
101
|
case 'NumberTypeAnnotation':
|
|
@@ -172,6 +174,8 @@ function toObjCValue(
|
|
|
172
174
|
return wrapPrimitive('double');
|
|
173
175
|
case 'BooleanTypeAnnotation':
|
|
174
176
|
return wrapPrimitive('BOOL');
|
|
177
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
178
|
+
return wrapPrimitive('BOOL');
|
|
175
179
|
case 'EnumDeclaration':
|
|
176
180
|
switch (typeAnnotation.memberType) {
|
|
177
181
|
case 'NumberTypeAnnotation':
|
|
@@ -110,6 +110,8 @@ function toObjCType(
|
|
|
110
110
|
return wrapCxxOptional('double', isRequired);
|
|
111
111
|
case 'BooleanTypeAnnotation':
|
|
112
112
|
return wrapCxxOptional('bool', isRequired);
|
|
113
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
114
|
+
return wrapCxxOptional('bool', isRequired);
|
|
113
115
|
case 'EnumDeclaration':
|
|
114
116
|
switch (typeAnnotation.memberType) {
|
|
115
117
|
case 'NumberTypeAnnotation':
|
|
@@ -195,6 +197,8 @@ function toObjCValue(
|
|
|
195
197
|
return wrapPrimitive('double');
|
|
196
198
|
case 'BooleanTypeAnnotation':
|
|
197
199
|
return wrapPrimitive('BOOL');
|
|
200
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
201
|
+
return wrapPrimitive('BOOL');
|
|
198
202
|
case 'EnumDeclaration':
|
|
199
203
|
switch (typeAnnotation.memberType) {
|
|
200
204
|
case 'NumberTypeAnnotation':
|
|
@@ -82,6 +82,8 @@ function toObjCType(
|
|
|
82
82
|
return wrapCxxOptional('double', isRequired);
|
|
83
83
|
case 'BooleanTypeAnnotation':
|
|
84
84
|
return wrapCxxOptional('bool', isRequired);
|
|
85
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
86
|
+
return wrapCxxOptional('bool', isRequired);
|
|
85
87
|
case 'EnumDeclaration':
|
|
86
88
|
switch (typeAnnotation.memberType) {
|
|
87
89
|
case 'NumberTypeAnnotation':
|
|
@@ -161,6 +163,8 @@ function toObjCValue(
|
|
|
161
163
|
return RCTBridgingTo('Double');
|
|
162
164
|
case 'BooleanTypeAnnotation':
|
|
163
165
|
return RCTBridgingTo('Bool');
|
|
166
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
167
|
+
return RCTBridgingTo('Bool');
|
|
164
168
|
case 'EnumDeclaration':
|
|
165
169
|
switch (typeAnnotation.memberType) {
|
|
166
170
|
case 'NumberTypeAnnotation':
|
|
@@ -101,6 +101,8 @@ function toObjCType(
|
|
|
101
101
|
return wrapCxxOptional('double', isRequired);
|
|
102
102
|
case 'BooleanTypeAnnotation':
|
|
103
103
|
return wrapCxxOptional('bool', isRequired);
|
|
104
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
105
|
+
return wrapCxxOptional('bool', isRequired);
|
|
104
106
|
case 'EnumDeclaration':
|
|
105
107
|
switch (typeAnnotation.memberType) {
|
|
106
108
|
case 'NumberTypeAnnotation':
|
|
@@ -185,6 +187,8 @@ function toObjCValue(
|
|
|
185
187
|
return RCTBridgingTo('Double');
|
|
186
188
|
case 'BooleanTypeAnnotation':
|
|
187
189
|
return RCTBridgingTo('Bool');
|
|
190
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
191
|
+
return RCTBridgingTo('Bool');
|
|
188
192
|
case 'EnumDeclaration':
|
|
189
193
|
switch (typeAnnotation.memberType) {
|
|
190
194
|
case 'NumberTypeAnnotation':
|
|
@@ -22,6 +22,7 @@ function getEventEmitterTypeObjCType(eventEmitter) {
|
|
|
22
22
|
case 'NumberLiteralTypeAnnotation':
|
|
23
23
|
return 'NSNumber *_Nonnull';
|
|
24
24
|
case 'BooleanTypeAnnotation':
|
|
25
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
25
26
|
return 'BOOL';
|
|
26
27
|
case 'GenericObjectTypeAnnotation':
|
|
27
28
|
case 'ObjectTypeAnnotation':
|
|
@@ -28,6 +28,7 @@ function getEventEmitterTypeObjCType(
|
|
|
28
28
|
case 'NumberLiteralTypeAnnotation':
|
|
29
29
|
return 'NSNumber *_Nonnull';
|
|
30
30
|
case 'BooleanTypeAnnotation':
|
|
31
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
31
32
|
return 'BOOL';
|
|
32
33
|
case 'GenericObjectTypeAnnotation':
|
|
33
34
|
case 'ObjectTypeAnnotation':
|
|
@@ -224,6 +224,8 @@ function getParamObjCType(
|
|
|
224
224
|
return notStruct(isRequired ? 'NSInteger' : 'NSNumber *');
|
|
225
225
|
case 'BooleanTypeAnnotation':
|
|
226
226
|
return notStruct(isRequired ? 'BOOL' : 'NSNumber *');
|
|
227
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
228
|
+
return notStruct(isRequired ? 'BOOL' : 'NSNumber *');
|
|
227
229
|
case 'EnumDeclaration':
|
|
228
230
|
switch (typeAnnotation.memberType) {
|
|
229
231
|
case 'NumberTypeAnnotation':
|
|
@@ -298,6 +300,8 @@ function getReturnObjCType(methodName, nullableTypeAnnotation) {
|
|
|
298
300
|
return wrapOptional('NSNumber *', isRequired);
|
|
299
301
|
case 'BooleanTypeAnnotation':
|
|
300
302
|
return wrapOptional('NSNumber *', isRequired);
|
|
303
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
304
|
+
return wrapOptional('NSNumber *', isRequired);
|
|
301
305
|
case 'EnumDeclaration':
|
|
302
306
|
switch (typeAnnotation.memberType) {
|
|
303
307
|
case 'NumberTypeAnnotation':
|
|
@@ -366,6 +370,8 @@ function getReturnJSType(methodName, nullableTypeAnnotation) {
|
|
|
366
370
|
return 'NumberKind';
|
|
367
371
|
case 'BooleanTypeAnnotation':
|
|
368
372
|
return 'BooleanKind';
|
|
373
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
374
|
+
return 'BooleanKind';
|
|
369
375
|
case 'GenericObjectTypeAnnotation':
|
|
370
376
|
return 'ObjectKind';
|
|
371
377
|
case 'EnumDeclaration':
|
|
@@ -273,6 +273,8 @@ function getParamObjCType(
|
|
|
273
273
|
return notStruct(isRequired ? 'NSInteger' : 'NSNumber *');
|
|
274
274
|
case 'BooleanTypeAnnotation':
|
|
275
275
|
return notStruct(isRequired ? 'BOOL' : 'NSNumber *');
|
|
276
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
277
|
+
return notStruct(isRequired ? 'BOOL' : 'NSNumber *');
|
|
276
278
|
case 'EnumDeclaration':
|
|
277
279
|
switch (typeAnnotation.memberType) {
|
|
278
280
|
case 'NumberTypeAnnotation':
|
|
@@ -356,6 +358,8 @@ function getReturnObjCType(
|
|
|
356
358
|
return wrapOptional('NSNumber *', isRequired);
|
|
357
359
|
case 'BooleanTypeAnnotation':
|
|
358
360
|
return wrapOptional('NSNumber *', isRequired);
|
|
361
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
362
|
+
return wrapOptional('NSNumber *', isRequired);
|
|
359
363
|
case 'EnumDeclaration':
|
|
360
364
|
switch (typeAnnotation.memberType) {
|
|
361
365
|
case 'NumberTypeAnnotation':
|
|
@@ -428,6 +432,8 @@ function getReturnJSType(
|
|
|
428
432
|
return 'NumberKind';
|
|
429
433
|
case 'BooleanTypeAnnotation':
|
|
430
434
|
return 'BooleanKind';
|
|
435
|
+
case 'BooleanLiteralTypeAnnotation':
|
|
436
|
+
return 'BooleanKind';
|
|
431
437
|
case 'GenericObjectTypeAnnotation':
|
|
432
438
|
return 'ObjectKind';
|
|
433
439
|
case 'EnumDeclaration':
|
|
@@ -24,6 +24,7 @@ const {
|
|
|
24
24
|
} = require('../../parsers-commons');
|
|
25
25
|
const {
|
|
26
26
|
emitArrayType,
|
|
27
|
+
emitBooleanLiteral,
|
|
27
28
|
emitCommonTypes,
|
|
28
29
|
emitDictionary,
|
|
29
30
|
emitFunction,
|
|
@@ -224,6 +225,9 @@ function translateTypeAnnotation(
|
|
|
224
225
|
case 'NumberLiteralTypeAnnotation': {
|
|
225
226
|
return emitNumberLiteral(nullable, typeAnnotation.value);
|
|
226
227
|
}
|
|
228
|
+
case 'BooleanLiteralTypeAnnotation': {
|
|
229
|
+
return emitBooleanLiteral(nullable, typeAnnotation.value);
|
|
230
|
+
}
|
|
227
231
|
case 'StringLiteralTypeAnnotation': {
|
|
228
232
|
return wrapNullable(nullable, {
|
|
229
233
|
type: 'StringLiteralTypeAnnotation',
|
|
@@ -35,6 +35,7 @@ const {
|
|
|
35
35
|
} = require('../../parsers-commons');
|
|
36
36
|
const {
|
|
37
37
|
emitArrayType,
|
|
38
|
+
emitBooleanLiteral,
|
|
38
39
|
emitCommonTypes,
|
|
39
40
|
emitDictionary,
|
|
40
41
|
emitFunction,
|
|
@@ -249,6 +250,9 @@ function translateTypeAnnotation(
|
|
|
249
250
|
case 'NumberLiteralTypeAnnotation': {
|
|
250
251
|
return emitNumberLiteral(nullable, typeAnnotation.value);
|
|
251
252
|
}
|
|
253
|
+
case 'BooleanLiteralTypeAnnotation': {
|
|
254
|
+
return emitBooleanLiteral(nullable, typeAnnotation.value);
|
|
255
|
+
}
|
|
252
256
|
case 'StringLiteralTypeAnnotation': {
|
|
253
257
|
return wrapNullable(nullable, {
|
|
254
258
|
type: 'StringLiteralTypeAnnotation',
|
|
@@ -118,6 +118,12 @@ function emitNumberLiteral(nullable, value) {
|
|
|
118
118
|
value,
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
+
function emitBooleanLiteral(nullable, value) {
|
|
122
|
+
return wrapNullable(nullable, {
|
|
123
|
+
type: 'BooleanLiteralTypeAnnotation',
|
|
124
|
+
value,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
121
127
|
function emitString(nullable) {
|
|
122
128
|
return wrapNullable(nullable, {
|
|
123
129
|
type: 'StringTypeAnnotation',
|
|
@@ -613,6 +619,7 @@ function emitUnionProp(name, optional, parser, typeAnnotation) {
|
|
|
613
619
|
module.exports = {
|
|
614
620
|
emitArrayType,
|
|
615
621
|
emitBoolean,
|
|
622
|
+
emitBooleanLiteral,
|
|
616
623
|
emitBoolProp,
|
|
617
624
|
emitDouble,
|
|
618
625
|
emitDoubleProp,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {
|
|
14
|
+
BooleanLiteralTypeAnnotation,
|
|
14
15
|
BooleanTypeAnnotation,
|
|
15
16
|
DoubleTypeAnnotation,
|
|
16
17
|
EventTypeAnnotation,
|
|
@@ -181,6 +182,16 @@ function emitNumberLiteral(
|
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
|
|
185
|
+
function emitBooleanLiteral(
|
|
186
|
+
nullable: boolean,
|
|
187
|
+
value: boolean,
|
|
188
|
+
): Nullable<BooleanLiteralTypeAnnotation> {
|
|
189
|
+
return wrapNullable(nullable, {
|
|
190
|
+
type: 'BooleanLiteralTypeAnnotation',
|
|
191
|
+
value,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
184
195
|
function emitString(nullable: boolean): Nullable<StringTypeAnnotation> {
|
|
185
196
|
return wrapNullable(nullable, {
|
|
186
197
|
type: 'StringTypeAnnotation',
|
|
@@ -764,6 +775,7 @@ function emitUnionProp(
|
|
|
764
775
|
module.exports = {
|
|
765
776
|
emitArrayType,
|
|
766
777
|
emitBoolean,
|
|
778
|
+
emitBooleanLiteral,
|
|
767
779
|
emitBoolProp,
|
|
768
780
|
emitDouble,
|
|
769
781
|
emitDoubleProp,
|
|
@@ -19,6 +19,7 @@ const {
|
|
|
19
19
|
const {parseObjectProperty} = require('../../parsers-commons');
|
|
20
20
|
const {
|
|
21
21
|
emitArrayType,
|
|
22
|
+
emitBooleanLiteral,
|
|
22
23
|
emitCommonTypes,
|
|
23
24
|
emitDictionary,
|
|
24
25
|
emitFunction,
|
|
@@ -390,6 +391,9 @@ function translateTypeAnnotation(
|
|
|
390
391
|
case 'NumericLiteral': {
|
|
391
392
|
return emitNumberLiteral(nullable, literal.value);
|
|
392
393
|
}
|
|
394
|
+
case 'BooleanLiteral': {
|
|
395
|
+
return emitBooleanLiteral(nullable, literal.value);
|
|
396
|
+
}
|
|
393
397
|
default: {
|
|
394
398
|
throw new UnsupportedTypeAnnotationParserError(
|
|
395
399
|
hasteModuleName,
|
|
@@ -34,6 +34,7 @@ const {
|
|
|
34
34
|
const {parseObjectProperty} = require('../../parsers-commons');
|
|
35
35
|
const {
|
|
36
36
|
emitArrayType,
|
|
37
|
+
emitBooleanLiteral,
|
|
37
38
|
emitCommonTypes,
|
|
38
39
|
emitDictionary,
|
|
39
40
|
emitFunction,
|
|
@@ -409,6 +410,9 @@ function translateTypeAnnotation(
|
|
|
409
410
|
case 'NumericLiteral': {
|
|
410
411
|
return emitNumberLiteral(nullable, literal.value);
|
|
411
412
|
}
|
|
413
|
+
case 'BooleanLiteral': {
|
|
414
|
+
return emitBooleanLiteral(nullable, literal.value);
|
|
415
|
+
}
|
|
412
416
|
default: {
|
|
413
417
|
throw new UnsupportedTypeAnnotationParserError(
|
|
414
418
|
hasteModuleName,
|