flow-api-translator 0.36.0 → 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", {
@@ -43,8 +34,7 @@ function constructFlowNode(node) {
43
34
  };
44
35
  }
45
36
 
46
- const makeCommentOwnLine = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
47
- _hermesTransform.makeCommentOwnLine;
37
+ const makeCommentOwnLine = _hermesTransform.makeCommentOwnLine;
48
38
 
49
39
  function TSDefToFlowDef(originalCode, ast, opts) {
50
40
  const flowBody = [];
@@ -66,10 +56,7 @@ function TSDefToFlowDef(originalCode, ast, opts) {
66
56
  }
67
57
 
68
58
  return [flowProgram, code];
69
- } // Note: The implementation here is still in early stage. If something is not supported, it doesn't
70
- // necessarily mean that it cannot be. It might just mean that it's not priortized yet. If something
71
- // is translated in way that is wrong, then it's likely wrong.
72
-
59
+ }
73
60
 
74
61
  const getTransforms = (originalCode, opts) => {
75
62
  let code = originalCode;
@@ -104,11 +91,8 @@ const getTransforms = (originalCode, opts) => {
104
91
  leading: true,
105
92
  printed: false
106
93
  };
107
- code = makeCommentOwnLine(code, comment); // $FlowExpectedError[prop-missing]
108
- // $FlowExpectedError[cannot-write]
109
-
110
- (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-type]
111
-
94
+ code = makeCommentOwnLine(code, comment);
95
+ (_node$comments = node.comments) != null ? _node$comments : node.comments = [];
112
96
  node.comments.push(comment);
113
97
  }
114
98
 
@@ -183,14 +167,12 @@ const getTransforms = (originalCode, opts) => {
183
167
 
184
168
  case 'TSAbstractPropertyDefinition':
185
169
  case 'PropertyDefinition':
186
- // $FlowFixMe[incompatible-type] ambiguous node
187
170
  Transform._translateIntoObjectProp(classItem, properties, indexers);
188
171
 
189
172
  break;
190
173
 
191
174
  case 'MethodDefinition':
192
175
  case 'TSAbstractMethodDefinition':
193
- // $FlowFixMe[incompatible-type] ambiguous node
194
176
  Transform._translateIntoObjectMethod(classItem, properties);
195
177
 
196
178
  break;
@@ -296,13 +278,11 @@ const getTransforms = (originalCode, opts) => {
296
278
 
297
279
  switch (node.declaration.type) {
298
280
  case 'ClassDeclaration':
299
- declaration = Transform.ClassDeclarationWithName( // possibly missing id
300
- node.declaration);
281
+ declaration = Transform.ClassDeclarationWithName(node.declaration);
301
282
  break;
302
283
 
303
284
  case 'FunctionDeclaration':
304
- declaration = Transform.FunctionDeclarationWithName( // possibly missing id
305
- node.declaration);
285
+ declaration = Transform.FunctionDeclarationWithName(node.declaration);
306
286
  break;
307
287
 
308
288
  case 'TSDeclareFunction':
@@ -355,8 +335,7 @@ const getTransforms = (originalCode, opts) => {
355
335
  case 'ClassDeclaration':
356
336
  return constructFlowNode({
357
337
  type: 'DeclareExportDeclaration',
358
- declaration: Transform.ClassDeclarationWithName( // possibly missing id
359
- node.declaration),
338
+ declaration: Transform.ClassDeclarationWithName(node.declaration),
360
339
  default: false,
361
340
  source: null,
362
341
  specifiers: []
@@ -365,8 +344,7 @@ const getTransforms = (originalCode, opts) => {
365
344
  case 'FunctionDeclaration':
366
345
  return constructFlowNode({
367
346
  type: 'DeclareExportDeclaration',
368
- declaration: Transform.FunctionDeclarationWithName( // possibly missing id
369
- node.declaration),
347
+ declaration: Transform.FunctionDeclarationWithName(node.declaration),
370
348
  default: false,
371
349
  source: null,
372
350
  specifiers: []
@@ -523,8 +501,7 @@ const getTransforms = (originalCode, opts) => {
523
501
  value: node.source.value,
524
502
  raw: node.source.raw
525
503
  }),
526
- importKind: // `import type React from 'react'` in TS means `import typeof React from react` in Flow
527
- specifiers.some(s => s.type === 'ImportDefaultSpecifier') && node.importKind === 'type' ? 'typeof' : node.importKind,
504
+ importKind: specifiers.some(s => s.type === 'ImportDefaultSpecifier') && node.importKind === 'type' ? 'typeof' : node.importKind,
528
505
  attributes: [],
529
506
  specifiers
530
507
  });
@@ -691,10 +668,6 @@ const getTransforms = (originalCode, opts) => {
691
668
  return Transform.TSModuleDeclaration(node);
692
669
 
693
670
  case 'TSNamespaceExportDeclaration':
694
- // Flow will never support `export as namespace` since we can't allow a normal file to
695
- // introduce a global out of nowhere, and because it's only useful for legacy module
696
- // system However, it's very reasonable to completely ignore it under some mode, so that
697
- // people using these libdefs won't have a lot of pain.
698
671
  return [];
699
672
 
700
673
  case 'TSTypeAliasDeclaration':
@@ -936,6 +909,18 @@ const getTransforms = (originalCode, opts) => {
936
909
  }
937
910
 
938
911
  static TSImportType(node) {
912
+ var _node$argument;
913
+
914
+ const source = (_node$argument = node.argument) != null ? _node$argument : node.source == null ? null : {
915
+ type: 'TSLiteralType',
916
+ loc: node.source.loc,
917
+ literal: node.source
918
+ };
919
+
920
+ if (source == null) {
921
+ return unsupportedAnnotation(node, 'import types without a source');
922
+ }
923
+
939
924
  let base = constructFlowNode({
940
925
  type: 'GenericTypeAnnotation',
941
926
  id: constructFlowNode({
@@ -946,16 +931,16 @@ const getTransforms = (originalCode, opts) => {
946
931
  }),
947
932
  typeParameters: constructFlowNode({
948
933
  type: 'TypeParameterInstantiation',
949
- params: [Transform.TSTypeAnnotation(node.argument)]
934
+ params: [Transform.TSTypeAnnotation(source)]
950
935
  })
951
936
  });
952
937
 
953
- if (node.qualifier == null) {
954
- return base;
938
+ if (node.typeArguments != null) {
939
+ return unsupportedAnnotation(node, 'import types with type arguments');
955
940
  }
956
941
 
957
- if (node.typeParameters != null) {
958
- return unsupportedAnnotation(node, 'import types with type parameters');
942
+ if (node.qualifier == null) {
943
+ return base;
959
944
  }
960
945
 
961
946
  let qualifier = Transform.EntityNameToTypeIdentifier(node.qualifier);
@@ -975,9 +960,7 @@ const getTransforms = (originalCode, opts) => {
975
960
  objectType: base,
976
961
  indexType: constructFlowNode({
977
962
  type: 'StringLiteralTypeAnnotation',
978
- // $FlowFixMe[incompatible-type]
979
963
  value: name,
980
- // $FlowFixMe[incompatible-type]
981
964
  raw: `'${name}'`
982
965
  })
983
966
  });
@@ -1051,8 +1034,7 @@ const getTransforms = (originalCode, opts) => {
1051
1034
  }
1052
1035
 
1053
1036
  static TSInterfaceDeclaration(node) {
1054
- const body = Transform.TSTypeLiteralOrInterfaceBody(node.body); // $FlowFixMe[cannot-write]
1055
-
1037
+ const body = Transform.TSTypeLiteralOrInterfaceBody(node.body);
1056
1038
  body.inexact = false;
1057
1039
  return constructFlowNode({
1058
1040
  type: 'InterfaceDeclaration',
@@ -1113,8 +1095,7 @@ const getTransforms = (originalCode, opts) => {
1113
1095
  var _keyTparam$bound;
1114
1096
 
1115
1097
  const keyTparam = Transform.TSTypeParameter(node.typeParameter);
1116
- const sourceType = (_keyTparam$bound = keyTparam.bound) == null ? void 0 : _keyTparam$bound.typeAnnotation; // $FlowFixMe[cannot-write]
1117
-
1098
+ const sourceType = (_keyTparam$bound = keyTparam.bound) == null ? void 0 : _keyTparam$bound.typeAnnotation;
1118
1099
  keyTparam.bound = null;
1119
1100
  const prop = constructFlowNode({
1120
1101
  type: 'ObjectTypeMappedTypeProperty',
@@ -1125,8 +1106,7 @@ const getTransforms = (originalCode, opts) => {
1125
1106
  type: 'Variance',
1126
1107
  kind: 'plus'
1127
1108
  }) : null,
1128
- optional: node.optional === '+' ? 'PlusOptional' : node.optional === '-' ? 'MinusOptional' : // eslint-disable-next-line no-extra-boolean-cast
1129
- Boolean(node.optional) ? 'Optional' : null
1109
+ optional: node.optional === '+' ? 'PlusOptional' : node.optional === '-' ? 'MinusOptional' : Boolean(node.optional) ? 'Optional' : null
1130
1110
  });
1131
1111
  return constructFlowNode({
1132
1112
  type: 'ObjectTypeAnnotation',
@@ -1425,8 +1405,6 @@ const getTransforms = (originalCode, opts) => {
1425
1405
  typeAnnotation: Transform.TSTypeAnnotation(node.typeAnnotation)
1426
1406
  });
1427
1407
  }
1428
- /** A very confusingly named object type */
1429
-
1430
1408
 
1431
1409
  static TSTypeLiteralOrInterfaceBody(node) {
1432
1410
  const properties = [];
@@ -1471,7 +1449,6 @@ const getTransforms = (originalCode, opts) => {
1471
1449
  {
1472
1450
  var _prop$typeAnnotation;
1473
1451
 
1474
- // eslint-disable-next-line no-extra-boolean-cast
1475
1452
  const variance = Boolean(prop.readonly) ? constructFlowNode({
1476
1453
  type: 'Variance',
1477
1454
  kind: 'plus'
@@ -1532,7 +1509,6 @@ const getTransforms = (originalCode, opts) => {
1532
1509
  }
1533
1510
 
1534
1511
  static _translateIntoObjectProp(prop, properties, indexers) {
1535
- // eslint-disable-next-line no-extra-boolean-cast
1536
1512
  const variance = Boolean(prop.readonly) ? constructFlowNode({
1537
1513
  type: 'Variance',
1538
1514
  kind: 'plus'
@@ -1741,10 +1717,18 @@ const getTransforms = (originalCode, opts) => {
1741
1717
  static TSTypeQuery(node) {
1742
1718
  var _Transform$TSTypePara;
1743
1719
 
1720
+ if (node.exprName.type === 'TSImportType') {
1721
+ if (node.typeArguments != null) {
1722
+ return unsupportedAnnotation(node, 'type query imports with type arguments');
1723
+ }
1724
+
1725
+ return Transform.TSImportType(node.exprName);
1726
+ }
1727
+
1744
1728
  return constructFlowNode({
1745
1729
  type: 'TypeofTypeAnnotation',
1746
1730
  argument: Transform.EntityNameToTypeofIdentifier(node.exprName),
1747
- typeArguments: (_Transform$TSTypePara = Transform.TSTypeParameterInstantiationOpt(node.typeParameters)) != null ? _Transform$TSTypePara : undefined
1731
+ typeArguments: (_Transform$TSTypePara = Transform.TSTypeParameterInstantiationOpt(node.typeArguments)) != null ? _Transform$TSTypePara : undefined
1748
1732
  });
1749
1733
  }
1750
1734
 
@@ -1784,7 +1768,6 @@ const getTransforms = (originalCode, opts) => {
1784
1768
  const id = Transform.Identifier(decl.id);
1785
1769
 
1786
1770
  if (id.typeAnnotation == null) {
1787
- // $FlowExpectedError[cannot-write]
1788
1771
  id.typeAnnotation = constructFlowNode({
1789
1772
  type: 'TypeAnnotation',
1790
1773
  typeAnnotation: constructFlowNode({
@@ -23,7 +23,7 @@ import {
23
23
  } from './utils/ErrorUtils';
24
24
  import {EOL} from 'os';
25
25
 
26
- const DUMMY_LOC: FlowESTree.SourceLocation = (null: $FlowFixMe);
26
+ const DUMMY_LOC: FlowESTree.SourceLocation = null as $FlowFixMe;
27
27
  const DUMMY_RANGE: [number, number] = [0, 0];
28
28
  const DUMMY_PARENT: $FlowFixMe = null;
29
29
  const DUMMY_COMMON = {
@@ -32,22 +32,22 @@ const DUMMY_COMMON = {
32
32
  parent: DUMMY_PARENT,
33
33
  };
34
34
 
35
- type LooseOmit<O: interface {}, K: $Keys<$FlowFixMe>> = Pick<
35
+ type LooseOmit<O extends interface {}, K extends keyof $FlowFixMe> = Pick<
36
36
  O,
37
- Exclude<$Keys<O>, K>,
37
+ Exclude<keyof O, K>,
38
38
  >;
39
- function constructFlowNode<T: FlowESTree.BaseNode>(
39
+ function constructFlowNode<T extends FlowESTree.BaseNode>(
40
40
  node: LooseOmit<NoInfer<T>, 'parent'>,
41
41
  ): T {
42
42
  return {
43
- ...(node: $FlowFixMe),
43
+ ...(node as $FlowFixMe),
44
44
  ...DUMMY_COMMON,
45
45
  };
46
46
  }
47
47
 
48
48
  const makeCommentOwnLine =
49
49
  // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
50
- (makeCommentOwnLineOriginal: (string, mixed) => string);
50
+ makeCommentOwnLineOriginal as (string, unknown) => string;
51
51
 
52
52
  export function TSDefToFlowDef(
53
53
  originalCode: string,
@@ -113,7 +113,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
113
113
  // $FlowExpectedError[cannot-write]
114
114
  node.comments ??= [];
115
115
  // $FlowExpectedError[incompatible-type]
116
- (node.comments: Array<TSESTree.Comment>).push(comment);
116
+ (node.comments as Array<TSESTree.Comment>).push(comment);
117
117
  }
118
118
  function unsupportedAnnotation(
119
119
  node: ObjectWithLoc,
@@ -330,13 +330,13 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
330
330
  case 'ClassDeclaration':
331
331
  declaration = Transform.ClassDeclarationWithName(
332
332
  // possibly missing id
333
- (node.declaration: $FlowFixMe),
333
+ node.declaration as $FlowFixMe,
334
334
  );
335
335
  break;
336
336
  case 'FunctionDeclaration':
337
337
  declaration = Transform.FunctionDeclarationWithName(
338
338
  // possibly missing id
339
- (node.declaration: $FlowFixMe),
339
+ node.declaration as $FlowFixMe,
340
340
  );
341
341
  break;
342
342
  case 'TSDeclareFunction':
@@ -369,7 +369,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
369
369
  | FlowESTree.ExportNamedDeclaration
370
370
  | FlowESTree.DeclareExportDeclarationNamedWithDeclaration
371
371
  | FlowESTree.DeclareExportDeclarationNamedWithSpecifiers
372
- | $ReadOnlyArray<
372
+ | ReadonlyArray<
373
373
  | FlowESTree.DeclareExportDeclarationNamedWithDeclaration
374
374
  | FlowESTree.TypeAlias
375
375
  | FlowESTree.DeclareNamespace
@@ -379,7 +379,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
379
379
  if (node.declaration == null) {
380
380
  const source: FlowESTree.StringLiteral =
381
381
  node.source == null
382
- ? (null: $FlowFixMe)
382
+ ? (null as $FlowFixMe)
383
383
  : constructFlowNode<FlowESTree.StringLiteral>({
384
384
  type: 'Literal',
385
385
  literalType: 'string',
@@ -410,7 +410,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
410
410
  type: 'DeclareExportDeclaration',
411
411
  declaration: Transform.ClassDeclarationWithName(
412
412
  // possibly missing id
413
- (node.declaration: $FlowFixMe),
413
+ node.declaration as $FlowFixMe,
414
414
  ),
415
415
  default: false,
416
416
  source: null,
@@ -423,7 +423,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
423
423
  type: 'DeclareExportDeclaration',
424
424
  declaration: Transform.FunctionDeclarationWithName(
425
425
  // possibly missing id
426
- (node.declaration: $FlowFixMe),
426
+ node.declaration as $FlowFixMe,
427
427
  ),
428
428
  default: false,
429
429
  source: null,
@@ -660,7 +660,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
660
660
  type: 'Literal',
661
661
  literalType: 'regexp',
662
662
  value: node.value,
663
- regex: (null: $FlowFixMe),
663
+ regex: null as $FlowFixMe,
664
664
  raw: node.raw,
665
665
  });
666
666
  } else if (node.value == null) {
@@ -715,7 +715,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
715
715
  case 'regexp':
716
716
  return unsupportedAnnotation(node, 'regexp literal type');
717
717
  default:
718
- (literal: empty);
718
+ literal as empty;
719
719
  throw 'unreachable';
720
720
  }
721
721
  }
@@ -725,7 +725,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
725
725
  ):
726
726
  | FlowESTree.Statement
727
727
  | FlowESTree.ModuleDeclaration
728
- | $ReadOnlyArray<FlowESTree.Statement | FlowESTree.ModuleDeclaration> {
728
+ | ReadonlyArray<FlowESTree.Statement | FlowESTree.ModuleDeclaration> {
729
729
  switch (node.type) {
730
730
  case 'BlockStatement':
731
731
  return Transform.BlockStatement(node);
@@ -789,8 +789,8 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
789
789
 
790
790
  static Statement(
791
791
  node: TSESTree.Statement,
792
- ): FlowESTree.Statement | $ReadOnlyArray<FlowESTree.Statement> {
793
- return (Transform.AllStatement(node): $FlowFixMe);
792
+ ): FlowESTree.Statement | ReadonlyArray<FlowESTree.Statement> {
793
+ return Transform.AllStatement(node) as $FlowFixMe;
794
794
  }
795
795
 
796
796
  static TSAnyType(): FlowESTree.AnyTypeAnnotation {
@@ -935,7 +935,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
935
935
  }
936
936
 
937
937
  static _partitionAndTranslateTSFunctionParams(
938
- tsParams: $ReadOnlyArray<TSESTree.Parameter>,
938
+ tsParams: ReadonlyArray<TSESTree.Parameter>,
939
939
  ): {
940
940
  thisParam: FlowESTree.FunctionTypeParam | null,
941
941
  restParam: FlowESTree.FunctionTypeParam | null,
@@ -1027,6 +1027,19 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1027
1027
  static TSImportType(
1028
1028
  node: TSESTree.TSImportType,
1029
1029
  ): FlowESTree.TypeAnnotationType {
1030
+ const source =
1031
+ node.argument ??
1032
+ (node.source == null
1033
+ ? null
1034
+ : ({
1035
+ type: 'TSLiteralType',
1036
+ loc: node.source.loc,
1037
+ literal: node.source,
1038
+ } as TSESTree.TSLiteralType));
1039
+ if (source == null) {
1040
+ return unsupportedAnnotation(node, 'import types without a source');
1041
+ }
1042
+
1030
1043
  let base: FlowESTree.TypeAnnotationType =
1031
1044
  constructFlowNode<FlowESTree.GenericTypeAnnotation>({
1032
1045
  type: 'GenericTypeAnnotation',
@@ -1039,15 +1052,15 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1039
1052
  typeParameters:
1040
1053
  constructFlowNode<FlowESTree.TypeParameterInstantiation>({
1041
1054
  type: 'TypeParameterInstantiation',
1042
- params: [Transform.TSTypeAnnotation(node.argument)],
1055
+ params: [Transform.TSTypeAnnotation(source)],
1043
1056
  }),
1044
1057
  });
1058
+ if (node.typeArguments != null) {
1059
+ return unsupportedAnnotation(node, 'import types with type arguments');
1060
+ }
1045
1061
  if (node.qualifier == null) {
1046
1062
  return base;
1047
1063
  }
1048
- if (node.typeParameters != null) {
1049
- return unsupportedAnnotation(node, 'import types with type parameters');
1050
- }
1051
1064
  let qualifier = Transform.EntityNameToTypeIdentifier(node.qualifier);
1052
1065
  const namesRev: Array<string> = [];
1053
1066
  while (qualifier.type !== 'Identifier') {
@@ -1243,8 +1256,8 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1243
1256
  node: TSESTree.TSMappedType,
1244
1257
  ): FlowESTree.ObjectTypeAnnotation {
1245
1258
  const keyTparam = Transform.TSTypeParameter(node.typeParameter);
1246
- const sourceType: FlowESTree.TypeAnnotationType = (keyTparam.bound
1247
- ?.typeAnnotation: $FlowFixMe);
1259
+ const sourceType: FlowESTree.TypeAnnotationType = keyTparam.bound
1260
+ ?.typeAnnotation as $FlowFixMe;
1248
1261
  // $FlowFixMe[cannot-write]
1249
1262
  keyTparam.bound = null;
1250
1263
  const prop = constructFlowNode<FlowESTree.ObjectTypeMappedTypeProperty>({
@@ -1303,7 +1316,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1303
1316
  if (node.id.type === 'Literal') {
1304
1317
  return constructFlowNode<FlowESTree.DeclareModule>({
1305
1318
  type: 'DeclareModule',
1306
- id: (Transform.Literal(node.id): $FlowFixMe),
1319
+ id: Transform.Literal(node.id) as $FlowFixMe,
1307
1320
  body,
1308
1321
  });
1309
1322
  }
@@ -1712,7 +1725,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1712
1725
  ? (constructFlowNode<FlowESTree.PrivateIdentifier>({
1713
1726
  type: 'PrivateIdentifier',
1714
1727
  name: key.name,
1715
- }): $FlowFixMe)
1728
+ }) as $FlowFixMe)
1716
1729
  : constructFlowNode<FlowESTree.StringLiteral>({
1717
1730
  type: 'Literal',
1718
1731
  literalType: 'string',
@@ -1767,7 +1780,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1767
1780
  ? (constructFlowNode<FlowESTree.PrivateIdentifier>({
1768
1781
  type: 'PrivateIdentifier',
1769
1782
  name: originalKey.name,
1770
- }): $FlowFixMe)
1783
+ }) as $FlowFixMe)
1771
1784
  : constructFlowNode<FlowESTree.StringLiteral>({
1772
1785
  type: 'Literal',
1773
1786
  literalType: 'string',
@@ -1960,12 +1973,22 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1960
1973
 
1961
1974
  static TSTypeQuery(
1962
1975
  node: TSESTree.TSTypeQuery,
1963
- ): FlowESTree.TypeofTypeAnnotation {
1976
+ ): FlowESTree.TypeAnnotationType {
1977
+ if (node.exprName.type === 'TSImportType') {
1978
+ if (node.typeArguments != null) {
1979
+ return unsupportedAnnotation(
1980
+ node,
1981
+ 'type query imports with type arguments',
1982
+ );
1983
+ }
1984
+ return Transform.TSImportType(node.exprName);
1985
+ }
1986
+
1964
1987
  return constructFlowNode<FlowESTree.TypeofTypeAnnotation>({
1965
1988
  type: 'TypeofTypeAnnotation',
1966
1989
  argument: Transform.EntityNameToTypeofIdentifier(node.exprName),
1967
1990
  typeArguments:
1968
- Transform.TSTypeParameterInstantiationOpt(node.typeParameters) ??
1991
+ Transform.TSTypeParameterInstantiationOpt(node.typeArguments) ??
1969
1992
  undefined,
1970
1993
  });
1971
1994
  }
@@ -2005,7 +2028,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
2005
2028
 
2006
2029
  static VariableDeclaration(
2007
2030
  node: TSESTree.VariableDeclaration,
2008
- ): $ReadOnlyArray<FlowESTree.DeclareVariable> {
2031
+ ): ReadonlyArray<FlowESTree.DeclareVariable> {
2009
2032
  return node.declarations.map(decl => {
2010
2033
  if (decl.id.type !== 'Identifier') {
2011
2034
  throw translationError(