@react-native/codegen 0.72.5 → 0.73.0-nightly-20230605-5062553c6

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.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/lib/CodegenSchema.d.ts +15 -4
  3. package/lib/CodegenSchema.js.flow +33 -21
  4. package/lib/generators/components/CppHelpers.js +39 -2
  5. package/lib/generators/components/CppHelpers.js.flow +54 -5
  6. package/lib/generators/components/GenerateEventEmitterCpp.js +238 -55
  7. package/lib/generators/components/GenerateEventEmitterCpp.js.flow +233 -55
  8. package/lib/generators/components/GenerateEventEmitterH.js +77 -28
  9. package/lib/generators/components/GenerateEventEmitterH.js.flow +87 -32
  10. package/lib/generators/components/GeneratePropsH.js +1 -2
  11. package/lib/generators/components/GeneratePropsH.js.flow +1 -2
  12. package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js +0 -1
  13. package/lib/generators/components/GeneratePropsJavaPojo/PojoCollector.js.flow +3 -5
  14. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js +4 -0
  15. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderH.js.flow +4 -0
  16. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js +2 -0
  17. package/lib/generators/components/GenerateThirdPartyFabricComponentsProviderObjCpp.js.flow +2 -0
  18. package/lib/generators/components/__test_fixtures__/fixtures.js +114 -1
  19. package/lib/generators/components/__test_fixtures__/fixtures.js.flow +114 -1
  20. package/lib/generators/modules/GenerateModuleCpp.js +3 -3
  21. package/lib/generators/modules/GenerateModuleCpp.js.flow +3 -3
  22. package/lib/generators/modules/GenerateModuleJavaSpec.js +1 -2
  23. package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +1 -2
  24. package/lib/parsers/error-utils.js +44 -0
  25. package/lib/parsers/error-utils.js.flow +59 -0
  26. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js +51 -0
  27. package/lib/parsers/flow/components/__test_fixtures__/fixtures.js.flow +51 -0
  28. package/lib/parsers/flow/components/componentsUtils.js +12 -19
  29. package/lib/parsers/flow/components/componentsUtils.js.flow +16 -27
  30. package/lib/parsers/flow/components/events.js +157 -83
  31. package/lib/parsers/flow/components/events.js.flow +158 -82
  32. package/lib/parsers/flow/components/index.js +10 -129
  33. package/lib/parsers/flow/components/index.js.flow +10 -150
  34. package/lib/parsers/flow/modules/index.js +39 -49
  35. package/lib/parsers/flow/modules/index.js.flow +22 -31
  36. package/lib/parsers/flow/parser.d.ts +9 -2
  37. package/lib/parsers/flow/parser.js +177 -16
  38. package/lib/parsers/flow/parser.js.flow +220 -6
  39. package/lib/parsers/flow/utils.js +0 -63
  40. package/lib/parsers/flow/utils.js.flow +1 -77
  41. package/lib/parsers/parser.js.flow +143 -1
  42. package/lib/parsers/parserMock.js +175 -2
  43. package/lib/parsers/parserMock.js.flow +227 -2
  44. package/lib/parsers/parsers-commons.js +169 -9
  45. package/lib/parsers/parsers-commons.js.flow +233 -12
  46. package/lib/parsers/parsers-primitives.js +94 -35
  47. package/lib/parsers/parsers-primitives.js.flow +124 -35
  48. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js +51 -0
  49. package/lib/parsers/typescript/components/__test_fixtures__/fixtures.js.flow +51 -0
  50. package/lib/parsers/typescript/components/componentsUtils.js +44 -46
  51. package/lib/parsers/typescript/components/componentsUtils.js.flow +44 -51
  52. package/lib/parsers/typescript/components/events.js +142 -72
  53. package/lib/parsers/typescript/components/events.js.flow +149 -73
  54. package/lib/parsers/typescript/components/extends.js +2 -49
  55. package/lib/parsers/typescript/components/extends.js.flow +1 -55
  56. package/lib/parsers/typescript/components/index.js +11 -134
  57. package/lib/parsers/typescript/components/index.js.flow +11 -156
  58. package/lib/parsers/typescript/modules/index.js +43 -51
  59. package/lib/parsers/typescript/modules/index.js.flow +25 -32
  60. package/lib/parsers/typescript/parser.d.ts +9 -2
  61. package/lib/parsers/typescript/parser.js +224 -7
  62. package/lib/parsers/typescript/parser.js.flow +262 -6
  63. package/lib/parsers/utils.js.flow +6 -0
  64. package/package.json +16 -5
  65. package/lib/parsers/flow/components/extends.js +0 -52
  66. package/lib/parsers/flow/components/extends.js.flow +0 -66
  67. package/lib/parsers/flow/components/props.js +0 -47
  68. package/lib/parsers/flow/components/props.js.flow +0 -60
  69. package/lib/parsers/typescript/components/props.js +0 -39
  70. package/lib/parsers/typescript/components/props.js.flow +0 -48
  71. package/lib/parsers/typescript/utils.js +0 -90
  72. package/lib/parsers/typescript/utils.js.flow +0 -104
@@ -23,11 +23,14 @@ import type {
23
23
  SchemaType,
24
24
  NativeModuleEnumMap,
25
25
  OptionsShape,
26
+ PropTypeAnnotation,
27
+ EventTypeAnnotation,
28
+ ObjectTypeAnnotation,
26
29
  } from '../CodegenSchema.js';
27
30
 
28
31
  import type {Parser} from './parser';
29
32
  import type {ParserType} from './errors';
30
- import type {ParserErrorCapturer, TypeDeclarationMap} from './utils';
33
+ import type {ParserErrorCapturer, TypeDeclarationMap, PropAST} from './utils';
31
34
  import type {ComponentSchemaBuilderConfig} from './schema.js';
32
35
 
33
36
  const {
@@ -38,6 +41,7 @@ const {
38
41
  isModuleRegistryCall,
39
42
  verifyPlatforms,
40
43
  } = require('./utils');
44
+
41
45
  const {
42
46
  throwIfPropertyValueTypeIsUnsupported,
43
47
  throwIfUnsupportedFunctionParamTypeAnnotationParserError,
@@ -52,6 +56,10 @@ const {
52
56
  throwIfModuleInterfaceNotFound,
53
57
  throwIfMoreThanOneModuleInterfaceParserError,
54
58
  throwIfModuleInterfaceIsMisnamed,
59
+ throwIfMoreThanOneCodegenNativecommands,
60
+ throwIfConfigNotfound,
61
+ throwIfMoreThanOneConfig,
62
+ throwIfTypeAliasIsNotInterface,
55
63
  } = require('./error-utils');
56
64
 
57
65
  const {
@@ -69,6 +77,11 @@ export type CommandOptions = $ReadOnly<{
69
77
  // $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
70
78
  type OptionsAST = Object;
71
79
 
80
+ type ExtendedPropResult = {
81
+ type: 'ReactNativeBuiltInType',
82
+ knownTypeName: 'ReactNativeCoreViewProps',
83
+ } | null;
84
+
72
85
  function wrapModuleSchema(
73
86
  nativeModuleSchema: NativeModuleSchema,
74
87
  hasteModuleName: string,
@@ -314,7 +327,6 @@ function buildPropertySchema(
314
327
  enumMap: {...NativeModuleEnumMap},
315
328
  tryParse: ParserErrorCapturer,
316
329
  cxxOnly: boolean,
317
- resolveTypeAnnotation: $FlowFixMe,
318
330
  translateTypeAnnotation: $FlowFixMe,
319
331
  parser: Parser,
320
332
  ): NativeModulePropertyShape {
@@ -329,7 +341,12 @@ function buildPropertySchema(
329
341
  : property.typeAnnotation;
330
342
  }
331
343
 
332
- ({nullable, typeAnnotation: value} = resolveTypeAnnotation(value, types));
344
+ const resolveTypeAnnotationFN = parser.getResolveTypeAnnotationFN();
345
+ ({nullable, typeAnnotation: value} = resolveTypeAnnotationFN(
346
+ value,
347
+ types,
348
+ parser,
349
+ ));
333
350
 
334
351
  throwIfModuleTypeIsUnsupported(
335
352
  hasteModuleName,
@@ -373,11 +390,9 @@ function buildSchemaFromConfigType(
373
390
  ast: $FlowFixMe,
374
391
  tryParse: ParserErrorCapturer,
375
392
  parser: Parser,
376
- resolveTypeAnnotation: $FlowFixMe,
377
393
  translateTypeAnnotation: $FlowFixMe,
378
394
  ) => NativeModuleSchema,
379
395
  parser: Parser,
380
- resolveTypeAnnotation: $FlowFixMe,
381
396
  translateTypeAnnotation: $FlowFixMe,
382
397
  ): SchemaType {
383
398
  switch (configType) {
@@ -398,7 +413,6 @@ function buildSchemaFromConfigType(
398
413
  ast,
399
414
  tryParse,
400
415
  parser,
401
- resolveTypeAnnotation,
402
416
  translateTypeAnnotation,
403
417
  ),
404
418
  );
@@ -440,14 +454,12 @@ function buildSchema(
440
454
  ast: $FlowFixMe,
441
455
  tryParse: ParserErrorCapturer,
442
456
  parser: Parser,
443
- resolveTypeAnnotation: $FlowFixMe,
444
457
  translateTypeAnnotation: $FlowFixMe,
445
458
  ) => NativeModuleSchema,
446
459
  Visitor: ({isComponent: boolean, isModule: boolean}) => {
447
460
  [type: string]: (node: $FlowFixMe) => void,
448
461
  },
449
462
  parser: Parser,
450
- resolveTypeAnnotation: $FlowFixMe,
451
463
  translateTypeAnnotation: $FlowFixMe,
452
464
  ): SchemaType {
453
465
  // Early return for non-Spec JavaScript files
@@ -469,7 +481,6 @@ function buildSchema(
469
481
  buildComponentSchema,
470
482
  buildModuleSchema,
471
483
  parser,
472
- resolveTypeAnnotation,
473
484
  translateTypeAnnotation,
474
485
  );
475
486
  }
@@ -564,7 +575,6 @@ const buildModuleSchema = (
564
575
  ast: $FlowFixMe,
565
576
  tryParse: ParserErrorCapturer,
566
577
  parser: Parser,
567
- resolveTypeAnnotation: $FlowFixMe,
568
578
  translateTypeAnnotation: $FlowFixMe,
569
579
  ): NativeModuleSchema => {
570
580
  const language = parser.language();
@@ -632,7 +642,6 @@ const buildModuleSchema = (
632
642
  enumMap,
633
643
  tryParse,
634
644
  cxxOnly,
635
- resolveTypeAnnotation,
636
645
  translateTypeAnnotation,
637
646
  parser,
638
647
  ),
@@ -765,10 +774,215 @@ function getOptions(optionsExpression: OptionsAST): ?OptionsShape {
765
774
  'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated',
766
775
  );
767
776
  }
768
-
769
777
  return foundOptions;
770
778
  }
771
779
 
780
+ function getCommandTypeNameAndOptionsExpression(
781
+ namedExport: $FlowFixMe,
782
+ parser: Parser,
783
+ ): {
784
+ commandOptionsExpression: OptionsAST,
785
+ commandTypeName: string,
786
+ } | void {
787
+ let callExpression;
788
+ let calleeName;
789
+ try {
790
+ callExpression = namedExport.declaration.declarations[0].init;
791
+ calleeName = callExpression.callee.name;
792
+ } catch (e) {
793
+ return;
794
+ }
795
+
796
+ if (calleeName !== 'codegenNativeCommands') {
797
+ return;
798
+ }
799
+
800
+ if (callExpression.arguments.length !== 1) {
801
+ throw new Error(
802
+ 'codegenNativeCommands must be passed options including the supported commands',
803
+ );
804
+ }
805
+
806
+ const typeArgumentParam =
807
+ parser.getTypeArgumentParamsFromDeclaration(callExpression)[0];
808
+
809
+ if (!parser.isGenericTypeAnnotation(typeArgumentParam.type)) {
810
+ throw new Error(
811
+ "codegenNativeCommands doesn't support inline definitions. Specify a file local type alias",
812
+ );
813
+ }
814
+
815
+ return {
816
+ commandTypeName: parser.nameForGenericTypeAnnotation(typeArgumentParam),
817
+ commandOptionsExpression: callExpression.arguments[0],
818
+ };
819
+ }
820
+
821
+ function propertyNames(
822
+ properties: $ReadOnlyArray<$FlowFixMe>,
823
+ ): $ReadOnlyArray<$FlowFixMe> {
824
+ return properties
825
+ .map(property => property && property.key && property.key.name)
826
+ .filter(Boolean);
827
+ }
828
+
829
+ function extendsForProp(
830
+ prop: PropAST,
831
+ types: TypeDeclarationMap,
832
+ parser: Parser,
833
+ ): ExtendedPropResult {
834
+ const argument = parser.argumentForProp(prop);
835
+
836
+ if (!argument) {
837
+ console.log('null', prop);
838
+ }
839
+
840
+ const name = parser.nameForArgument(prop);
841
+
842
+ if (types[name] != null) {
843
+ // This type is locally defined in the file
844
+ return null;
845
+ }
846
+
847
+ switch (name) {
848
+ case 'ViewProps':
849
+ return {
850
+ type: 'ReactNativeBuiltInType',
851
+ knownTypeName: 'ReactNativeCoreViewProps',
852
+ };
853
+ default: {
854
+ throw new Error(`Unable to handle prop spread: ${name}`);
855
+ }
856
+ }
857
+ }
858
+
859
+ function buildPropSchema(
860
+ property: PropAST,
861
+ types: TypeDeclarationMap,
862
+ parser: Parser,
863
+ ): ?NamedShape<PropTypeAnnotation> {
864
+ const getSchemaInfoFN = parser.getGetSchemaInfoFN();
865
+ const info = getSchemaInfoFN(property, types);
866
+ if (info == null) {
867
+ return null;
868
+ }
869
+ const {name, optional, typeAnnotation, defaultValue, withNullDefault} = info;
870
+
871
+ const getTypeAnnotationFN = parser.getGetTypeAnnotationFN();
872
+
873
+ return {
874
+ name,
875
+ optional,
876
+ typeAnnotation: getTypeAnnotationFN(
877
+ name,
878
+ typeAnnotation,
879
+ defaultValue,
880
+ withNullDefault,
881
+ types,
882
+ parser,
883
+ buildPropSchema,
884
+ ),
885
+ };
886
+ }
887
+
888
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
889
+ * LTI update could not be added via codemod */
890
+ function getEventArgument(
891
+ argumentProps: PropAST,
892
+ buildPropertiesForEvent: (
893
+ property: PropAST,
894
+ parser: Parser,
895
+ ) => NamedShape<EventTypeAnnotation>,
896
+ parser: Parser,
897
+ ): ObjectTypeAnnotation<EventTypeAnnotation> {
898
+ return {
899
+ type: 'ObjectTypeAnnotation',
900
+ properties: argumentProps.map(member =>
901
+ buildPropertiesForEvent(member, parser),
902
+ ),
903
+ };
904
+ }
905
+
906
+ /* $FlowFixMe[signature-verification-failure] there's no flowtype for AST.
907
+ * TODO(T108222691): Use flow-types for @babel/parser */
908
+ function findComponentConfig(ast: $FlowFixMe, parser: Parser) {
909
+ const foundConfigs: Array<{[string]: string}> = [];
910
+
911
+ const defaultExports = ast.body.filter(
912
+ node => node.type === 'ExportDefaultDeclaration',
913
+ );
914
+
915
+ defaultExports.forEach(statement => {
916
+ findNativeComponentType(statement, foundConfigs, parser);
917
+ });
918
+
919
+ throwIfConfigNotfound(foundConfigs);
920
+ throwIfMoreThanOneConfig(foundConfigs);
921
+
922
+ const foundConfig = foundConfigs[0];
923
+
924
+ const namedExports = ast.body.filter(
925
+ node => node.type === 'ExportNamedDeclaration',
926
+ );
927
+
928
+ const commandsTypeNames = namedExports
929
+ .map(statement => getCommandTypeNameAndOptionsExpression(statement, parser))
930
+ .filter(Boolean);
931
+
932
+ throwIfMoreThanOneCodegenNativecommands(commandsTypeNames);
933
+
934
+ return createComponentConfig(foundConfig, commandsTypeNames);
935
+ }
936
+
937
+ // $FlowFixMe[signature-verification-failure] there's no flowtype for AST
938
+ function getCommandProperties(ast: $FlowFixMe, parser: Parser) {
939
+ const {commandTypeName, commandOptionsExpression} = findComponentConfig(
940
+ ast,
941
+ parser,
942
+ );
943
+
944
+ if (commandTypeName == null) {
945
+ return [];
946
+ }
947
+ const types = parser.getTypes(ast);
948
+
949
+ const typeAlias = types[commandTypeName];
950
+
951
+ throwIfTypeAliasIsNotInterface(typeAlias, parser);
952
+
953
+ const properties = parser.bodyProperties(typeAlias);
954
+ if (!properties) {
955
+ throw new Error(
956
+ `Failed to find type definition for "${commandTypeName}", please check that you have a valid codegen file`,
957
+ );
958
+ }
959
+
960
+ const commandPropertyNames = propertyNames(properties);
961
+
962
+ const commandOptions = getCommandOptions(commandOptionsExpression);
963
+
964
+ if (commandOptions == null || commandOptions.supportedCommands == null) {
965
+ throw new Error(
966
+ 'codegenNativeCommands must be given an options object with supportedCommands array',
967
+ );
968
+ }
969
+
970
+ if (
971
+ commandOptions.supportedCommands.length !== commandPropertyNames.length ||
972
+ !commandOptions.supportedCommands.every(supportedCommand =>
973
+ commandPropertyNames.includes(supportedCommand),
974
+ )
975
+ ) {
976
+ throw new Error(
977
+ `codegenNativeCommands expected the same supportedCommands specified in the ${commandTypeName} interface: ${commandPropertyNames.join(
978
+ ', ',
979
+ )}`,
980
+ );
981
+ }
982
+
983
+ return properties;
984
+ }
985
+
772
986
  module.exports = {
773
987
  wrapModuleSchema,
774
988
  unwrapNullable,
@@ -784,6 +998,13 @@ module.exports = {
784
998
  parseModuleName,
785
999
  buildModuleSchema,
786
1000
  findNativeComponentType,
1001
+ propertyNames,
787
1002
  getCommandOptions,
788
1003
  getOptions,
1004
+ getCommandTypeNameAndOptionsExpression,
1005
+ extendsForProp,
1006
+ buildPropSchema,
1007
+ getEventArgument,
1008
+ findComponentConfig,
1009
+ getCommandProperties,
789
1010
  };
@@ -110,6 +110,15 @@ function emitInt32(nullable) {
110
110
  type: 'Int32TypeAnnotation',
111
111
  });
112
112
  }
113
+ function emitInt32Prop(name, optional) {
114
+ return {
115
+ name,
116
+ optional,
117
+ typeAnnotation: {
118
+ type: 'Int32TypeAnnotation',
119
+ },
120
+ };
121
+ }
113
122
  function emitNumber(nullable) {
114
123
  return wrapNullable(nullable, {
115
124
  type: 'NumberTypeAnnotation',
@@ -126,6 +135,15 @@ function emitDouble(nullable) {
126
135
  type: 'DoubleTypeAnnotation',
127
136
  });
128
137
  }
138
+ function emitDoubleProp(name, optional) {
139
+ return {
140
+ name,
141
+ optional,
142
+ typeAnnotation: {
143
+ type: 'DoubleTypeAnnotation',
144
+ },
145
+ };
146
+ }
129
147
  function emitVoid(nullable) {
130
148
  return wrapNullable(nullable, {
131
149
  type: 'VoidTypeAnnotation',
@@ -171,6 +189,15 @@ function emitString(nullable) {
171
189
  type: 'StringTypeAnnotation',
172
190
  });
173
191
  }
192
+ function emitStringProp(name, optional) {
193
+ return {
194
+ name,
195
+ optional,
196
+ typeAnnotation: {
197
+ type: 'StringTypeAnnotation',
198
+ },
199
+ };
200
+ }
174
201
  function typeAliasResolution(
175
202
  typeResolution,
176
203
  objectTypeAnnotation,
@@ -315,6 +342,12 @@ function emitGenericObject(nullable) {
315
342
  type: 'GenericObjectTypeAnnotation',
316
343
  });
317
344
  }
345
+ function emitDictionary(nullable, valueType) {
346
+ return wrapNullable(nullable, {
347
+ type: 'GenericObjectTypeAnnotation',
348
+ dictionaryValueType: valueType,
349
+ });
350
+ }
318
351
  function emitObject(nullable, properties) {
319
352
  return wrapNullable(nullable, {
320
353
  type: 'ObjectTypeAnnotation',
@@ -326,6 +359,15 @@ function emitFloat(nullable) {
326
359
  type: 'FloatTypeAnnotation',
327
360
  });
328
361
  }
362
+ function emitFloatProp(name, optional) {
363
+ return {
364
+ name,
365
+ optional,
366
+ typeAnnotation: {
367
+ type: 'FloatTypeAnnotation',
368
+ },
369
+ };
370
+ }
329
371
  function emitUnion(nullable, hasteModuleName, typeAnnotation, parser) {
330
372
  const unionTypes = parser.remapUnionTypeAnnotationMemberNames(
331
373
  typeAnnotation.types,
@@ -462,6 +504,7 @@ function Visitor(infoMap) {
462
504
  };
463
505
  }
464
506
  function emitPartial(
507
+ nullable,
465
508
  hasteModuleName,
466
509
  typeAnnotation,
467
510
  types,
@@ -469,7 +512,6 @@ function emitPartial(
469
512
  enumMap,
470
513
  tryParse,
471
514
  cxxOnly,
472
- nullable,
473
515
  parser,
474
516
  ) {
475
517
  throwIfPartialWithMoreParameter(typeAnnotation);
@@ -502,59 +544,76 @@ function emitCommonTypes(
502
544
  nullable,
503
545
  parser,
504
546
  ) {
547
+ const typeMap = {
548
+ Stringish: emitStringish,
549
+ Int32: emitInt32,
550
+ Double: emitDouble,
551
+ Float: emitFloat,
552
+ UnsafeObject: emitGenericObject,
553
+ Object: emitGenericObject,
554
+ $Partial: emitPartial,
555
+ Partial: emitPartial,
556
+ BooleanTypeAnnotation: emitBoolean,
557
+ NumberTypeAnnotation: emitNumber,
558
+ VoidTypeAnnotation: emitVoid,
559
+ StringTypeAnnotation: emitString,
560
+ MixedTypeAnnotation: cxxOnly ? emitMixed : emitGenericObject,
561
+ };
562
+ const typeAnnotationName = parser.convertKeywordToTypeAnnotation(
563
+ typeAnnotation.type,
564
+ );
565
+ const simpleEmitter = typeMap[typeAnnotationName];
566
+ if (simpleEmitter) {
567
+ return simpleEmitter(nullable);
568
+ }
505
569
  const genericTypeAnnotationName =
506
570
  parser.nameForGenericTypeAnnotation(typeAnnotation);
507
- switch (genericTypeAnnotationName) {
508
- case 'Stringish': {
509
- return emitStringish(nullable);
510
- }
511
- case 'Int32': {
512
- return emitInt32(nullable);
513
- }
514
- case 'Double': {
515
- return emitDouble(nullable);
516
- }
517
- case 'Float': {
518
- return emitFloat(nullable);
519
- }
520
- case 'UnsafeObject':
521
- case 'Object': {
522
- return emitGenericObject(nullable);
523
- }
524
- case '$Partial':
525
- case 'Partial': {
526
- return emitPartial(
527
- hasteModuleName,
528
- typeAnnotation,
529
- types,
530
- aliasMap,
531
- enumMap,
532
- tryParse,
533
- cxxOnly,
534
- nullable,
535
- parser,
536
- );
537
- }
538
- default: {
539
- return null;
540
- }
571
+ const emitter = typeMap[genericTypeAnnotationName];
572
+ if (!emitter) {
573
+ return null;
541
574
  }
575
+ return emitter(
576
+ nullable,
577
+ hasteModuleName,
578
+ typeAnnotation,
579
+ types,
580
+ aliasMap,
581
+ enumMap,
582
+ tryParse,
583
+ cxxOnly,
584
+ parser,
585
+ );
586
+ }
587
+ function emitBoolProp(name, optional) {
588
+ return {
589
+ name,
590
+ optional,
591
+ typeAnnotation: {
592
+ type: 'BooleanTypeAnnotation',
593
+ },
594
+ };
542
595
  }
543
596
  module.exports = {
544
597
  emitArrayType,
545
598
  emitBoolean,
599
+ emitBoolProp,
546
600
  emitDouble,
601
+ emitDoubleProp,
547
602
  emitFloat,
603
+ emitFloatProp,
548
604
  emitFunction,
549
605
  emitInt32,
606
+ emitInt32Prop,
550
607
  emitNumber,
551
608
  emitGenericObject,
609
+ emitDictionary,
552
610
  emitObject,
553
611
  emitPromise,
554
612
  emitRootTag,
555
613
  emitVoid,
556
614
  emitString,
557
615
  emitStringish,
616
+ emitStringProp,
558
617
  emitMixed,
559
618
  emitUnion,
560
619
  emitPartial,