flow-api-translator 0.36.1 → 0.37.0

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.
@@ -1,12 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and 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
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  Object.defineProperty(exports, "__esModule", {
@@ -49,7 +40,6 @@ function getTopLevelStatement(node, context) {
49
40
  var _currentNode$parent;
50
41
 
51
42
  if (((_currentNode$parent = currentNode.parent) == null ? void 0 : _currentNode$parent.type) === 'Program') {
52
- // $FlowFixMe[incompatible-type]
53
43
  return currentNode;
54
44
  }
55
45
 
@@ -60,20 +50,10 @@ function getTopLevelStatement(node, context) {
60
50
  }
61
51
 
62
52
  function transferProgramStatementProperties(stmt, orgStmt) {
63
- // $FlowExpectedError[prop-missing]
64
- // $FlowExpectedError[incompatible-use]
65
- stmt.comments = orgStmt.comments; // $FlowExpectedError[incompatible-use]
66
-
67
- stmt.range = orgStmt.range; // $FlowExpectedError[incompatible-use]
68
-
53
+ stmt.comments = orgStmt.comments;
54
+ stmt.range = orgStmt.range;
69
55
  stmt.loc = orgStmt.loc;
70
56
  }
71
- /**
72
- * Consume an arbitrary Flow AST and convert it into a type definition file.
73
- *
74
- * To do this all runtime logic will be stripped and only types that describe the module boundary will remain.
75
- */
76
-
77
57
 
78
58
  function flowToFlowDef(ast, code, scopeManager, opts) {
79
59
  var _ast$interpreter$valu, _ast$interpreter;
@@ -123,8 +103,7 @@ function flowToFlowDef(ast, code, scopeManager, opts) {
123
103
  function updateProcessedStatement(stmt) {
124
104
  processedStatements.add(stmt);
125
105
  pendingStatements.delete(stmt);
126
- } // Process all export statements
127
-
106
+ }
128
107
 
129
108
  for (const stmt of ast.body) {
130
109
  const resultExport = convertExport(stmt, context);
@@ -203,14 +182,11 @@ function convertExport(stmt, context) {
203
182
  if (expr.type === 'AssignmentExpression' && expr.left.type === 'MemberExpression') {
204
183
  const member = expr.left;
205
184
 
206
- if ( // exports.A = 1;
207
- member.object.type === 'Identifier' && member.object.name === 'exports' || // module.exports.A = 1;
208
- member.object.type === 'MemberExpression' && member.object.object.type === 'Identifier' && member.object.object.name === 'module' && member.object.property.type === 'Identifier' && member.object.property.name === 'exports') {
185
+ if (member.object.type === 'Identifier' && member.object.name === 'exports' || member.object.type === 'MemberExpression' && member.object.object.type === 'Identifier' && member.object.object.name === 'module' && member.object.property.type === 'Identifier' && member.object.property.name === 'exports') {
209
186
  throw (0, _ErrorUtils.translationError)(stmt, `convertExport: Named CommonJS exports not supported. Use either \`module.exports = {...}\` or ES6 exports.`, context);
210
187
  }
211
188
 
212
- if ( // exports.A = 1;
213
- member.object.type === 'Identifier' && member.object.name === 'module' && member.property.type === 'Identifier' && member.property.name === 'exports') {
189
+ if (member.object.type === 'Identifier' && member.object.name === 'module' && member.property.type === 'Identifier' && member.property.name === 'exports') {
214
190
  const [typeAnnotation, deps] = convertExpressionToTypeAnnotation(expr.right, context);
215
191
  return [_hermesTransform.t.DeclareModuleExports({
216
192
  typeAnnotation: _hermesTransform.t.TypeAnnotation({
@@ -225,14 +201,12 @@ function convertExport(stmt, context) {
225
201
 
226
202
  default:
227
203
  {
228
- // Skip non exported functions
229
204
  return null;
230
205
  }
231
206
  }
232
207
  }
233
208
 
234
209
  function stripUnusedDefs(detachedStmt, usedDeps, context) {
235
- // $FlowExpectedError[incompatible-type]
236
210
  const stmt = detachedStmt;
237
211
 
238
212
  switch (stmt.type) {
@@ -315,6 +289,12 @@ function convertStatement(stmt, context) {
315
289
 
316
290
  case 'VariableDeclaration':
317
291
  {
292
+ const requireImport = convertRequireToImport(stmt);
293
+
294
+ if (requireImport != null) {
295
+ return requireImport;
296
+ }
297
+
318
298
  const [result, deps] = convertVariableDeclaration(stmt, context);
319
299
  return [result, deps];
320
300
  }
@@ -396,7 +376,6 @@ function convertExpressionToTypeAnnotation(expr, context) {
396
376
  }
397
377
 
398
378
  function inheritComments(fromNode, toNode) {
399
- // $FlowFixMe[unclear-type]
400
379
  toNode.comments = fromNode.comments;
401
380
  return toNode;
402
381
  }
@@ -425,7 +404,6 @@ function convertObjectExpression(expr, context) {
425
404
 
426
405
  const [resultExpr, deps] = convertAFunction(prop.value, context);
427
406
  return [inheritComments(prop, _hermesTransform.t.ObjectTypeMethodSignature({
428
- // $FlowFixMe[incompatible-type]
429
407
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
430
408
  value: resultExpr
431
409
  })), deps];
@@ -439,7 +417,6 @@ function convertObjectExpression(expr, context) {
439
417
  const kind = prop.kind;
440
418
  const [resultExpr, deps] = convertAFunction(prop.value, context);
441
419
  return [inheritComments(prop, _hermesTransform.t.ObjectTypeAccessorSignature({
442
- // $FlowFixMe[incompatible-type]
443
420
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
444
421
  kind,
445
422
  value: resultExpr
@@ -448,7 +425,6 @@ function convertObjectExpression(expr, context) {
448
425
 
449
426
  const [resultExpr, deps] = convertExpressionToTypeAnnotation(prop.value, context);
450
427
  return [inheritComments(prop, _hermesTransform.t.ObjectTypePropertySignature({
451
- // $FlowFixMe[incompatible-type]
452
428
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
453
429
  value: resultExpr,
454
430
  optional: false,
@@ -726,6 +702,76 @@ function convertVariableDeclaration(stmt, context) {
726
702
  }), annotDeps];
727
703
  }
728
704
 
705
+ function convertRequireToImport(stmt) {
706
+ if (stmt.declarations.length !== 1) {
707
+ return null;
708
+ }
709
+
710
+ const decl = stmt.declarations[0];
711
+ const init = decl.init;
712
+
713
+ if (init == null || init.type !== 'CallExpression' || init.callee.type !== 'Identifier' || init.callee.name !== 'require' || init.arguments.length !== 1) {
714
+ return null;
715
+ }
716
+
717
+ const sourceArg = init.arguments[0];
718
+
719
+ if (!(0, _hermesEstree.isStringLiteral)(sourceArg)) {
720
+ return null;
721
+ }
722
+
723
+ const id = decl.id;
724
+
725
+ if (id.type === 'Identifier') {
726
+ return [_hermesTransform.t.ImportDeclaration({
727
+ importKind: 'value',
728
+ source: (0, _hermesTransform.asDetachedNode)(sourceArg),
729
+ specifiers: [_hermesTransform.t.ImportDefaultSpecifier({
730
+ local: _hermesTransform.t.Identifier({
731
+ name: id.name
732
+ })
733
+ })],
734
+ attributes: []
735
+ }), []];
736
+ }
737
+
738
+ if (id.type === 'ObjectPattern') {
739
+ const specifiers = [];
740
+
741
+ for (const prop of id.properties) {
742
+ if (prop.type === 'RestElement') {
743
+ return null;
744
+ }
745
+
746
+ const key = prop.key;
747
+ const value = prop.value;
748
+
749
+ if (key.type !== 'Identifier' || value.type !== 'Identifier') {
750
+ return null;
751
+ }
752
+
753
+ specifiers.push(_hermesTransform.t.ImportSpecifier({
754
+ imported: _hermesTransform.t.Identifier({
755
+ name: key.name
756
+ }),
757
+ local: _hermesTransform.t.Identifier({
758
+ name: value.name
759
+ }),
760
+ importKind: null
761
+ }));
762
+ }
763
+
764
+ return [_hermesTransform.t.ImportDeclaration({
765
+ importKind: 'value',
766
+ source: (0, _hermesTransform.asDetachedNode)(sourceArg),
767
+ specifiers,
768
+ attributes: []
769
+ }), []];
770
+ }
771
+
772
+ return null;
773
+ }
774
+
729
775
  function convertImportDeclaration(stmt, context) {
730
776
  if (stmt.attributes.length > 0) {
731
777
  throw (0, _ErrorUtils.translationError)(stmt, 'ImportDeclaration: attributes not supported', context);
@@ -754,7 +800,6 @@ function convertClassDeclaration(class_, context) {
754
800
  }
755
801
 
756
802
  return [_hermesTransform.t.DeclareClass({
757
- // $FlowFixMe[incompatible-type]
758
803
  id: (0, _hermesTransform.asDetachedNode)(class_.id),
759
804
  typeParameters: resultTypeParams,
760
805
  implements: class_.implements.map(impl => (0, _hermesTransform.asDetachedNode)(impl)),
@@ -886,7 +931,6 @@ function convertClassMember(member, context) {
886
931
  {
887
932
  var _member$value;
888
933
 
889
- // PrivateIdentifier's are not exposed so can be stripped.
890
934
  if (member.key.type === 'PrivateIdentifier') {
891
935
  return EMPTY_TRANSLATION_RESULT;
892
936
  }
@@ -902,7 +946,6 @@ function convertClassMember(member, context) {
902
946
  if (((_member$value = member.value) == null ? void 0 : _member$value.type) === 'ArrowFunctionExpression' && member.typeAnnotation == null) {
903
947
  const [resultTypeAnnotation, deps] = convertAFunction(member.value, context);
904
948
  return [inheritComments(member, _hermesTransform.t.ObjectTypePropertySignature({
905
- // $FlowFixMe[incompatible-type]
906
949
  key: (0, _hermesTransform.asDetachedNode)(member.key),
907
950
  value: resultTypeAnnotation,
908
951
  optional: member.optional,
@@ -913,7 +956,6 @@ function convertClassMember(member, context) {
913
956
 
914
957
  const [resultTypeAnnotation, deps] = convertTypeAnnotation(member.typeAnnotation, member, context);
915
958
  return [inheritComments(member, _hermesTransform.t.ObjectTypePropertySignature({
916
- // $FlowFixMe[incompatible-type]
917
959
  key: (0, _hermesTransform.asDetachedNode)(member.key),
918
960
  value: resultTypeAnnotation,
919
961
  optional: member.optional,
@@ -924,7 +966,6 @@ function convertClassMember(member, context) {
924
966
 
925
967
  case 'MethodDefinition':
926
968
  {
927
- // PrivateIdentifier's are not exposed so can be stripped.
928
969
  if (member.key.type === 'PrivateIdentifier') {
929
970
  return EMPTY_TRANSLATION_RESULT;
930
971
  }
@@ -943,10 +984,8 @@ function convertClassMember(member, context) {
943
984
  }) : member.key;
944
985
 
945
986
  if (member.kind === 'get' || member.kind === 'set') {
946
- // accessors are methods - but flow accessor signatures are properties
947
987
  const kind = member.kind;
948
988
  return [inheritComments(member, _hermesTransform.t.ObjectTypeAccessorSignature({
949
- // $FlowFixMe[incompatible-type]
950
989
  key: (0, _hermesTransform.asDetachedNode)(newKey),
951
990
  value: resultValue,
952
991
  static: member.static,
@@ -955,7 +994,6 @@ function convertClassMember(member, context) {
955
994
  }
956
995
 
957
996
  return [inheritComments(member, _hermesTransform.t.ObjectTypeMethodSignature({
958
- // $FlowFixMe[incompatible-type]
959
997
  key: (0, _hermesTransform.asDetachedNode)(newKey),
960
998
  value: resultValue,
961
999
  static: member.static
@@ -1115,8 +1153,7 @@ function convertHookDeclaration(hook, context) {
1115
1153
  var _hook$returnType;
1116
1154
 
1117
1155
  const id = hook.id;
1118
- const returnType = (_hook$returnType = hook.returnType) != null ? _hook$returnType : // $FlowFixMe[incompatible-type]
1119
- _hermesTransform.t.TypeAnnotation({
1156
+ const returnType = (_hook$returnType = hook.returnType) != null ? _hook$returnType : _hermesTransform.t.TypeAnnotation({
1120
1157
  typeAnnotation: _hermesTransform.t.VoidTypeAnnotation()
1121
1158
  });
1122
1159
  const [resultReturnType, returnDeps] = convertTypeAnnotation(returnType, hook, context);
@@ -1206,8 +1243,7 @@ function convertFunctionParameters(params, context) {
1206
1243
  throw (0, _ErrorUtils.translationError)(param, `FunctionParameter: Multiple rest elements found`, context);
1207
1244
  }
1208
1245
 
1209
- const [resultParam, deps] = convertBindingNameToFunctionTypeParam( // $FlowFixMe[incompatible-type] I dont think these other cases are possible
1210
- param.argument, context, index, false);
1246
+ const [resultParam, deps] = convertBindingNameToFunctionTypeParam(param.argument, context, index, false);
1211
1247
  return [resultParams, resultParam, [...paramsDeps, ...deps]];
1212
1248
  }
1213
1249
  }
@@ -91,12 +91,12 @@ import {
91
91
 
92
92
  const EMPTY_TRANSLATION_RESULT: TranslatedResultOrNull<empty> = [null, []];
93
93
 
94
- type TranslatedDeps = $ReadOnlyArray<Dep>;
95
- type TranslatedResultOrNull<+T> = Readonly<
94
+ type TranslatedDeps = ReadonlyArray<Dep>;
95
+ type TranslatedResultOrNull<out T> = Readonly<
96
96
  [DetachedNode<T> | null, TranslatedDeps],
97
97
  >;
98
98
  type TranslatedResultArray<T> = [
99
- $ReadOnlyArray<DetachedNode<T>>,
99
+ ReadonlyArray<DetachedNode<T>>,
100
100
  TranslatedDeps,
101
101
  ];
102
102
  type TranslatedResult<T> = [DetachedNode<T>, TranslatedDeps];
@@ -104,7 +104,7 @@ type TranslatedResult<T> = [DetachedNode<T>, TranslatedDeps];
104
104
  type ProgramStatement = Statement | ModuleDeclaration;
105
105
 
106
106
  function convertArray<TIn, TOut>(
107
- items: $ReadOnlyArray<TIn>,
107
+ items: ReadonlyArray<TIn>,
108
108
  convert: TIn => TranslatedResultOrNull<TOut>,
109
109
  ): TranslatedResultArray<TOut> {
110
110
  const resultItems: Array<DetachedNode<TOut>> = [];
@@ -409,6 +409,10 @@ function convertStatement(
409
409
  return [result, deps];
410
410
  }
411
411
  case 'VariableDeclaration': {
412
+ const requireImport = convertRequireToImport(stmt);
413
+ if (requireImport != null) {
414
+ return requireImport;
415
+ }
412
416
  const [result, deps] = convertVariableDeclaration(stmt, context);
413
417
  return [result, deps];
414
418
  }
@@ -486,12 +490,12 @@ function convertExpressionToTypeAnnotation(
486
490
  }
487
491
  }
488
492
 
489
- function inheritComments<T: DetachedNode<ESNode>>(
493
+ function inheritComments<T extends DetachedNode<ESNode>>(
490
494
  fromNode: ESNode,
491
495
  toNode: T,
492
496
  ): T {
493
497
  // $FlowFixMe[unclear-type]
494
- (toNode: any).comments = (fromNode: any).comments;
498
+ (toNode as any).comments = (fromNode as any).comments;
495
499
  return toNode;
496
500
  }
497
501
 
@@ -663,7 +667,7 @@ function convertLiteral(
663
667
  function convertExportDeclaration(
664
668
  decl:
665
669
  | ExportDefaultDeclaration['declaration']
666
- | $NonMaybeType<ExportNamedDeclaration['declaration']>,
670
+ | NonNullable<ExportNamedDeclaration['declaration']>,
667
671
  opts: {default: boolean},
668
672
  context: TranslationContext,
669
673
  ): TranslatedResult<ProgramStatement> {
@@ -831,8 +835,8 @@ function convertExportDefaultDeclaration(
831
835
  context: TranslationContext,
832
836
  ): TranslatedResult<ProgramStatement> {
833
837
  const expr = stmt.declaration;
834
- if (isExpression(expr) && (expr: $FlowFixMe).type === 'Identifier') {
835
- const name = ((expr: $FlowFixMe): Identifier).name;
838
+ if (isExpression(expr) && (expr as $FlowFixMe).type === 'Identifier') {
839
+ const name = (expr as $FlowFixMe as Identifier).name;
836
840
  const [declDecl, deps] = [
837
841
  t.TypeofTypeAnnotation({argument: t.Identifier({name})}),
838
842
  analyzeTypeDependencies(expr, context),
@@ -939,6 +943,78 @@ function convertVariableDeclaration(
939
943
  ];
940
944
  }
941
945
 
946
+ function convertRequireToImport(
947
+ stmt: VariableDeclaration,
948
+ ): ?TranslatedResult<ProgramStatement> {
949
+ if (stmt.declarations.length !== 1) {
950
+ return null;
951
+ }
952
+ const decl = stmt.declarations[0];
953
+ const init = decl.init;
954
+ if (
955
+ init == null ||
956
+ init.type !== 'CallExpression' ||
957
+ init.callee.type !== 'Identifier' ||
958
+ init.callee.name !== 'require' ||
959
+ init.arguments.length !== 1
960
+ ) {
961
+ return null;
962
+ }
963
+ const sourceArg = init.arguments[0];
964
+ if (!isStringLiteral(sourceArg)) {
965
+ return null;
966
+ }
967
+ const id = decl.id;
968
+
969
+ if (id.type === 'Identifier') {
970
+ return [
971
+ t.ImportDeclaration({
972
+ importKind: 'value',
973
+ source: asDetachedNode(sourceArg),
974
+ specifiers: [
975
+ t.ImportDefaultSpecifier({
976
+ local: t.Identifier({name: id.name}),
977
+ }),
978
+ ],
979
+ attributes: [],
980
+ }),
981
+ [],
982
+ ];
983
+ }
984
+
985
+ if (id.type === 'ObjectPattern') {
986
+ const specifiers = [];
987
+ for (const prop of id.properties) {
988
+ if (prop.type === 'RestElement') {
989
+ return null;
990
+ }
991
+ const key = prop.key;
992
+ const value = prop.value;
993
+ if (key.type !== 'Identifier' || value.type !== 'Identifier') {
994
+ return null;
995
+ }
996
+ specifiers.push(
997
+ t.ImportSpecifier({
998
+ imported: t.Identifier({name: key.name}),
999
+ local: t.Identifier({name: value.name}),
1000
+ importKind: null,
1001
+ }),
1002
+ );
1003
+ }
1004
+ return [
1005
+ t.ImportDeclaration({
1006
+ importKind: 'value',
1007
+ source: asDetachedNode(sourceArg),
1008
+ specifiers,
1009
+ attributes: [],
1010
+ }),
1011
+ [],
1012
+ ];
1013
+ }
1014
+
1015
+ return null;
1016
+ }
1017
+
942
1018
  function convertImportDeclaration(
943
1019
  stmt: ImportDeclaration,
944
1020
  context: TranslationContext,
@@ -1371,13 +1447,13 @@ function convertComponentDeclaration(
1371
1447
  }
1372
1448
 
1373
1449
  type TranslatedComponentParametersResults = [
1374
- $ReadOnlyArray<DetachedNode<ComponentTypeParameter>>,
1450
+ ReadonlyArray<DetachedNode<ComponentTypeParameter>>,
1375
1451
  ?DetachedNode<ComponentTypeParameter>,
1376
1452
  TranslatedDeps,
1377
1453
  ];
1378
1454
 
1379
1455
  function hasNonIdentifierStringLiteralParam(
1380
- params: $ReadOnlyArray<ComponentParameter | RestElement>,
1456
+ params: ReadonlyArray<ComponentParameter | RestElement>,
1381
1457
  ): boolean {
1382
1458
  return params.some(
1383
1459
  param =>
@@ -1408,7 +1484,7 @@ function extractParamTypeInfo(
1408
1484
  }
1409
1485
 
1410
1486
  function convertComponentParameters(
1411
- params: $ReadOnlyArray<ComponentParameter | RestElement>,
1487
+ params: ReadonlyArray<ComponentParameter | RestElement>,
1412
1488
  context: TranslationContext,
1413
1489
  ): TranslatedComponentParametersResults {
1414
1490
  if (hasNonIdentifierStringLiteralParam(params)) {
@@ -1490,7 +1566,7 @@ function convertComponentParameters(
1490
1566
  }
1491
1567
 
1492
1568
  function convertComponentParametersToPropsObject(
1493
- params: $ReadOnlyArray<ComponentParameter | RestElement>,
1569
+ params: ReadonlyArray<ComponentParameter | RestElement>,
1494
1570
  context: TranslationContext,
1495
1571
  ): TranslatedComponentParametersResults {
1496
1572
  const properties: Array<
@@ -1673,12 +1749,12 @@ function convertAFunction(
1673
1749
  }
1674
1750
 
1675
1751
  type TranslatedFunctionParametersResults = [
1676
- $ReadOnlyArray<DetachedNode<FunctionTypeParam>>,
1752
+ ReadonlyArray<DetachedNode<FunctionTypeParam>>,
1677
1753
  ?DetachedNode<FunctionTypeParam>,
1678
1754
  TranslatedDeps,
1679
1755
  ];
1680
1756
  function convertFunctionParameters(
1681
- params: $ReadOnlyArray<FunctionParameter>,
1757
+ params: ReadonlyArray<FunctionParameter>,
1682
1758
  context: TranslationContext,
1683
1759
  ): TranslatedFunctionParametersResults {
1684
1760
  return params.reduce<TranslatedFunctionParametersResults>(
package/dist/flowToJS.js CHANGED
@@ -1,12 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and 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
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  Object.defineProperty(exports, "__esModule", {
package/dist/index.js CHANGED
@@ -1,12 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and 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
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  Object.defineProperty(exports, "__esModule", {
@@ -62,8 +53,7 @@ async function translateFlowDefToTSDef(code, prettierOptions = {}) {
62
53
  const [tsAST, mutatedCode] = (0, _flowDefToTSDef.flowDefToTSDef)(code, ast, scopeManager, {
63
54
  recoverFromErrors: true
64
55
  });
65
- return (0, _hermesTransform.print)( // $FlowExpectedError[incompatible-type] - this is fine as we're providing the visitor keys
66
- tsAST, mutatedCode, { ...prettierOptions
56
+ return (0, _hermesTransform.print)(tsAST, mutatedCode, { ...prettierOptions
67
57
  }, _visitorKeys.visitorKeys);
68
58
  }
69
59
 
@@ -75,18 +65,6 @@ async function translateFlowToJS(code, prettierOptions = {}) {
75
65
  const jsAST = (0, _flowToJS.flowToJS)(ast, code, scopeManager);
76
66
  return (0, _hermesTransform.print)(jsAST, code, prettierOptions);
77
67
  }
78
- /**
79
- * This translator is very experimental and unstable.
80
- *
81
- * It is not written with productionizing it in mind, but instead used to evaluate how close Flow
82
- * is to TypeScript.
83
- *
84
- * If you are going to use it anyways, you agree that you are calling a potentially broken function
85
- * without any guarantee.
86
- *
87
- * @deprecated
88
- */
89
-
90
68
 
91
69
  async function unstable_translateTSDefToFlowDef(code, prettierOptions = {}) {
92
70
  const ast = (0, _parser.parse)(code, {