flow-api-translator 0.20.0 → 0.21.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.
@@ -30,6 +30,11 @@ import {EOL} from 'os';
30
30
 
31
31
  type DeclarationOrUnsupported<T> = T | TSESTree.TSTypeAliasDeclaration;
32
32
 
33
+ const DUMMY_LOC: FlowESTree.SourceLocation = {
34
+ start: {line: 1, column: 0},
35
+ end: {line: 1, column: 0},
36
+ };
37
+
33
38
  function constructFlowNode<T: FlowESTree.BaseNode>(
34
39
  node: $Diff<T, FlowESTree.BaseNode>,
35
40
  ): T {
@@ -62,6 +67,7 @@ function getReactIdentifier(hasReactImport: boolean) {
62
67
 
63
68
  return {
64
69
  type: 'Identifier',
70
+ loc: DUMMY_LOC,
65
71
  name: `React`,
66
72
  };
67
73
  }
@@ -77,6 +83,7 @@ export function flowDefToTSDef(
77
83
  type: 'Program',
78
84
  body: tsBody,
79
85
  sourceType: ast.sourceType,
86
+ loc: ast.loc,
80
87
  docblock:
81
88
  ast.docblock == null ? null : removeAtFlowFromDocblock(ast.docblock),
82
89
  };
@@ -110,16 +117,20 @@ export function flowDefToTSDef(
110
117
  tsBody.unshift({
111
118
  type: 'ImportDeclaration',
112
119
  assertions: [],
120
+ loc: DUMMY_LOC,
113
121
  source: {
114
122
  type: 'Literal',
123
+ loc: DUMMY_LOC,
115
124
  value: 'react',
116
125
  raw: "'react'",
117
126
  },
118
127
  specifiers: [
119
128
  {
120
129
  type: 'ImportNamespaceSpecifier',
130
+ loc: DUMMY_LOC,
121
131
  local: {
122
132
  type: 'Identifier',
133
+ loc: DUMMY_LOC,
123
134
  name: 'React',
124
135
  },
125
136
  },
@@ -150,8 +161,9 @@ const getTransforms = (
150
161
  return buildCodeFrame(node, message, code, false);
151
162
  }
152
163
  function addErrorComment(node: TSESTree.Node, message: string): void {
153
- const comment = {
164
+ const comment: TSESTree.Comment = {
154
165
  type: 'Block',
166
+ loc: DUMMY_LOC,
155
167
  value: `*${EOL} * ${message.replace(
156
168
  new RegExp(EOL, 'g'),
157
169
  `${EOL} * `,
@@ -165,7 +177,6 @@ const getTransforms = (
165
177
  // $FlowExpectedError[prop-missing]
166
178
  // $FlowExpectedError[cannot-write]
167
179
  node.comments ??= [];
168
- // $FlowExpectedError[prop-missing]
169
180
  // $FlowExpectedError[incompatible-cast]
170
181
  (node.comments: Array<TSESTree.Comment>).push(comment);
171
182
  }
@@ -176,8 +187,9 @@ const getTransforms = (
176
187
  const message = unsupportedFeatureMessage(thing);
177
188
  if (opts.recoverFromErrors) {
178
189
  const codeFrame = buildCodeFrameForComment(node, message);
179
- const newNode = {
190
+ const newNode: TSESTree.TSAnyKeyword = {
180
191
  type: 'TSAnyKeyword',
192
+ loc: DUMMY_LOC,
181
193
  };
182
194
  addErrorComment(newNode, codeFrame);
183
195
  return newNode;
@@ -195,12 +207,14 @@ const getTransforms = (
195
207
  const message = unsupportedFeatureMessage(thing);
196
208
  if (opts.recoverFromErrors) {
197
209
  const codeFrame = buildCodeFrameForComment(node, message);
198
- const newNode = {
210
+ const newNode: TSESTree.TSTypeAliasDeclaration = {
199
211
  type: 'TSTypeAliasDeclaration',
212
+ loc: DUMMY_LOC,
200
213
  declare,
201
214
  id: transform.Identifier(id, false),
202
215
  typeAnnotation: {
203
216
  type: 'TSAnyKeyword',
217
+ loc: DUMMY_LOC,
204
218
  },
205
219
  typeParameters:
206
220
  typeParameters == null
@@ -366,10 +380,12 @@ const getTransforms = (
366
380
  }
367
381
  members.push({
368
382
  type: 'TSEnumMember',
383
+ loc: DUMMY_LOC,
369
384
  computed: false,
370
385
  id: transform.Identifier(member.id, false),
371
386
  initializer: ({
372
387
  type: 'Literal',
388
+ loc: DUMMY_LOC,
373
389
  raw: `"${member.id.name}"`,
374
390
  value: member.id.name,
375
391
  }: TSESTree.StringLiteral),
@@ -381,6 +397,7 @@ const getTransforms = (
381
397
  case 'EnumStringMember':
382
398
  members.push({
383
399
  type: 'TSEnumMember',
400
+ loc: DUMMY_LOC,
384
401
  computed: false,
385
402
  id: transform.Identifier(member.id, false),
386
403
  initializer:
@@ -393,13 +410,14 @@ const getTransforms = (
393
410
 
394
411
  const bodyRepresentationType =
395
412
  body.type === 'EnumNumberBody'
396
- ? {type: 'TSNumberKeyword'}
397
- : {type: 'TSStringKeyword'};
413
+ ? {type: 'TSNumberKeyword', loc: DUMMY_LOC}
414
+ : {type: 'TSStringKeyword', loc: DUMMY_LOC};
398
415
 
399
416
  const enumName = transform.Identifier(node.id, false);
400
417
  return [
401
418
  {
402
419
  type: 'TSEnumDeclaration',
420
+ loc: DUMMY_LOC,
403
421
  const: false,
404
422
  declare: true,
405
423
  id: enumName,
@@ -421,18 +439,23 @@ const getTransforms = (
421
439
  */
422
440
  {
423
441
  type: 'TSModuleDeclaration',
442
+ loc: DUMMY_LOC,
424
443
  declare: true,
425
444
  id: enumName,
426
445
  body: {
427
446
  type: 'TSModuleBlock',
447
+ loc: DUMMY_LOC,
428
448
  body: [
429
449
  // export function cast(value: number | null | undefined): Foo
430
450
  {
431
451
  type: 'ExportNamedDeclaration',
452
+ loc: DUMMY_LOC,
432
453
  declaration: {
433
454
  type: 'TSDeclareFunction',
455
+ loc: DUMMY_LOC,
434
456
  id: {
435
457
  type: 'Identifier',
458
+ loc: DUMMY_LOC,
436
459
  name: 'cast',
437
460
  },
438
461
  generator: false,
@@ -441,18 +464,23 @@ const getTransforms = (
441
464
  params: [
442
465
  {
443
466
  type: 'Identifier',
467
+ loc: DUMMY_LOC,
444
468
  name: 'value',
445
469
  typeAnnotation: {
446
470
  type: 'TSTypeAnnotation',
471
+ loc: DUMMY_LOC,
447
472
  typeAnnotation: {
448
473
  type: 'TSUnionType',
474
+ loc: DUMMY_LOC,
449
475
  types: [
450
476
  bodyRepresentationType,
451
477
  {
452
478
  type: 'TSNullKeyword',
479
+ loc: DUMMY_LOC,
453
480
  },
454
481
  {
455
482
  type: 'TSUndefinedKeyword',
483
+ loc: DUMMY_LOC,
456
484
  },
457
485
  ],
458
486
  },
@@ -461,8 +489,10 @@ const getTransforms = (
461
489
  ],
462
490
  returnType: {
463
491
  type: 'TSTypeAnnotation',
492
+ loc: DUMMY_LOC,
464
493
  typeAnnotation: {
465
494
  type: 'TSTypeReference',
495
+ loc: DUMMY_LOC,
466
496
  typeName: enumName,
467
497
  },
468
498
  },
@@ -475,10 +505,13 @@ const getTransforms = (
475
505
  // export function isValid(value: number | null | undefined): value is Foo;
476
506
  {
477
507
  type: 'ExportNamedDeclaration',
508
+ loc: DUMMY_LOC,
478
509
  declaration: {
479
510
  type: 'TSDeclareFunction',
511
+ loc: DUMMY_LOC,
480
512
  id: {
481
513
  type: 'Identifier',
514
+ loc: DUMMY_LOC,
482
515
  name: 'isValid',
483
516
  },
484
517
  generator: false,
@@ -487,18 +520,23 @@ const getTransforms = (
487
520
  params: [
488
521
  {
489
522
  type: 'Identifier',
523
+ loc: DUMMY_LOC,
490
524
  name: 'value',
491
525
  typeAnnotation: {
492
526
  type: 'TSTypeAnnotation',
527
+ loc: DUMMY_LOC,
493
528
  typeAnnotation: {
494
529
  type: 'TSUnionType',
530
+ loc: DUMMY_LOC,
495
531
  types: [
496
532
  bodyRepresentationType,
497
533
  {
498
534
  type: 'TSNullKeyword',
535
+ loc: DUMMY_LOC,
499
536
  },
500
537
  {
501
538
  type: 'TSUndefinedKeyword',
539
+ loc: DUMMY_LOC,
502
540
  },
503
541
  ],
504
542
  },
@@ -507,17 +545,22 @@ const getTransforms = (
507
545
  ],
508
546
  returnType: {
509
547
  type: 'TSTypeAnnotation',
548
+ loc: DUMMY_LOC,
510
549
  typeAnnotation: {
511
550
  type: 'TSTypePredicate',
551
+ loc: DUMMY_LOC,
512
552
  asserts: false,
513
553
  parameterName: {
514
554
  type: 'Identifier',
555
+ loc: DUMMY_LOC,
515
556
  name: 'value',
516
557
  },
517
558
  typeAnnotation: {
518
559
  type: 'TSTypeAnnotation',
560
+ loc: DUMMY_LOC,
519
561
  typeAnnotation: {
520
562
  type: 'TSTypeReference',
563
+ loc: DUMMY_LOC,
521
564
  typeName: enumName,
522
565
  },
523
566
  },
@@ -532,10 +575,13 @@ const getTransforms = (
532
575
  // export function members(): IterableIterator<Foo>;
533
576
  {
534
577
  type: 'ExportNamedDeclaration',
578
+ loc: DUMMY_LOC,
535
579
  declaration: {
536
580
  type: 'TSDeclareFunction',
581
+ loc: DUMMY_LOC,
537
582
  id: {
538
583
  type: 'Identifier',
584
+ loc: DUMMY_LOC,
539
585
  name: 'members',
540
586
  },
541
587
  generator: false,
@@ -544,17 +590,22 @@ const getTransforms = (
544
590
  params: [],
545
591
  returnType: {
546
592
  type: 'TSTypeAnnotation',
593
+ loc: DUMMY_LOC,
547
594
  typeAnnotation: {
548
595
  type: 'TSTypeReference',
596
+ loc: DUMMY_LOC,
549
597
  typeName: {
550
598
  type: 'Identifier',
599
+ loc: DUMMY_LOC,
551
600
  name: 'IterableIterator',
552
601
  },
553
602
  typeParameters: {
554
603
  type: 'TSTypeParameterInstantiation',
604
+ loc: DUMMY_LOC,
555
605
  params: [
556
606
  {
557
607
  type: 'TSTypeReference',
608
+ loc: DUMMY_LOC,
558
609
  typeName: enumName,
559
610
  },
560
611
  ],
@@ -570,10 +621,13 @@ const getTransforms = (
570
621
  // export function getName(value: Foo): string;
571
622
  {
572
623
  type: 'ExportNamedDeclaration',
624
+ loc: DUMMY_LOC,
573
625
  declaration: {
574
626
  type: 'TSDeclareFunction',
627
+ loc: DUMMY_LOC,
575
628
  id: {
576
629
  type: 'Identifier',
630
+ loc: DUMMY_LOC,
577
631
  name: 'getName',
578
632
  },
579
633
  generator: false,
@@ -582,11 +636,14 @@ const getTransforms = (
582
636
  params: [
583
637
  {
584
638
  type: 'Identifier',
639
+ loc: DUMMY_LOC,
585
640
  name: 'value',
586
641
  typeAnnotation: {
587
642
  type: 'TSTypeAnnotation',
643
+ loc: DUMMY_LOC,
588
644
  typeAnnotation: {
589
645
  type: 'TSTypeReference',
646
+ loc: DUMMY_LOC,
590
647
  typeName: enumName,
591
648
  },
592
649
  },
@@ -594,8 +651,10 @@ const getTransforms = (
594
651
  ],
595
652
  returnType: {
596
653
  type: 'TSTypeAnnotation',
654
+ loc: DUMMY_LOC,
597
655
  typeAnnotation: {
598
656
  type: 'TSStringKeyword',
657
+ loc: DUMMY_LOC,
599
658
  },
600
659
  },
601
660
  },
@@ -700,6 +759,7 @@ const getTransforms = (
700
759
  ): TSESTree.TSAnyKeyword {
701
760
  return {
702
761
  type: 'TSAnyKeyword',
762
+ loc: DUMMY_LOC,
703
763
  };
704
764
  },
705
765
  ArrayTypeAnnotation(
@@ -707,12 +767,14 @@ const getTransforms = (
707
767
  ): TSESTree.TSArrayType {
708
768
  return {
709
769
  type: 'TSArrayType',
770
+ loc: DUMMY_LOC,
710
771
  elementType: transformTypeAnnotationType(node.elementType),
711
772
  };
712
773
  },
713
774
  BigIntLiteral(node: FlowESTree.BigIntLiteral): TSESTree.BigIntLiteral {
714
775
  return {
715
776
  type: 'Literal',
777
+ loc: DUMMY_LOC,
716
778
  bigint: node.bigint,
717
779
  raw: node.raw,
718
780
  value: node.value,
@@ -734,8 +796,10 @@ const getTransforms = (
734
796
  .replace(/_/, '');
735
797
  return {
736
798
  type: 'TSLiteralType',
799
+ loc: DUMMY_LOC,
737
800
  literal: ({
738
801
  type: 'Literal',
802
+ loc: DUMMY_LOC,
739
803
  value: node.value,
740
804
  raw: node.raw,
741
805
  bigint,
@@ -747,11 +811,13 @@ const getTransforms = (
747
811
  ): TSESTree.TSBigIntKeyword {
748
812
  return {
749
813
  type: 'TSBigIntKeyword',
814
+ loc: DUMMY_LOC,
750
815
  };
751
816
  },
752
817
  BooleanLiteral(node: FlowESTree.BooleanLiteral): TSESTree.BooleanLiteral {
753
818
  return {
754
819
  type: 'Literal',
820
+ loc: DUMMY_LOC,
755
821
  raw: node.raw,
756
822
  value: node.value,
757
823
  };
@@ -761,8 +827,10 @@ const getTransforms = (
761
827
  ): TSESTree.TSLiteralType {
762
828
  return {
763
829
  type: 'TSLiteralType',
830
+ loc: DUMMY_LOC,
764
831
  literal: ({
765
832
  type: 'Literal',
833
+ loc: DUMMY_LOC,
766
834
  value: node.value,
767
835
  raw: node.raw,
768
836
  }: TSESTree.BooleanLiteral),
@@ -773,6 +841,7 @@ const getTransforms = (
773
841
  ): TSESTree.TSBooleanKeyword {
774
842
  return {
775
843
  type: 'TSBooleanKeyword',
844
+ loc: DUMMY_LOC,
776
845
  };
777
846
  },
778
847
  ClassImplements(
@@ -780,6 +849,7 @@ const getTransforms = (
780
849
  ): TSESTree.TSClassImplements {
781
850
  return {
782
851
  type: 'TSClassImplements',
852
+ loc: DUMMY_LOC,
783
853
  expression: transform.Identifier(node.id, false),
784
854
  typeParameters:
785
855
  node.typeParameters == null
@@ -828,10 +898,12 @@ const getTransforms = (
828
898
  if (isConstructor) {
829
899
  const newNode: TSESTree.MethodDefinitionAmbiguous = {
830
900
  type: 'MethodDefinition',
901
+ loc: DUMMY_LOC,
831
902
  accessibility: undefined,
832
903
  computed: false,
833
904
  key: {
834
905
  type: 'Identifier',
906
+ loc: DUMMY_LOC,
835
907
  name: 'constructor',
836
908
  },
837
909
  kind: 'constructor',
@@ -840,6 +912,7 @@ const getTransforms = (
840
912
  static: false,
841
913
  value: {
842
914
  type: 'TSEmptyBodyFunctionExpression',
915
+ loc: DUMMY_LOC,
843
916
  async: false,
844
917
  body: null,
845
918
  declare: false,
@@ -857,6 +930,7 @@ const getTransforms = (
857
930
  } else {
858
931
  const newNode: TSESTree.MethodDefinitionAmbiguous = {
859
932
  type: 'MethodDefinition',
933
+ loc: DUMMY_LOC,
860
934
  accessibility: member.accessibility,
861
935
  computed: member.computed ?? false,
862
936
  key: member.key,
@@ -866,6 +940,7 @@ const getTransforms = (
866
940
  static: member.static ?? false,
867
941
  value: {
868
942
  type: 'TSEmptyBodyFunctionExpression',
943
+ loc: DUMMY_LOC,
869
944
  async: false,
870
945
  body: null,
871
946
  declare: false,
@@ -886,6 +961,7 @@ const getTransforms = (
886
961
  case 'TSPropertySignature': {
887
962
  const newNode: TSESTree.PropertyDefinitionAmbiguous = {
888
963
  type: 'PropertyDefinition',
964
+ loc: DUMMY_LOC,
889
965
  accessibility: member.accessibility,
890
966
  computed: member.computed ?? false,
891
967
  declare: false,
@@ -939,8 +1015,10 @@ const getTransforms = (
939
1015
 
940
1016
  return {
941
1017
  type: 'ClassDeclaration',
1018
+ loc: DUMMY_LOC,
942
1019
  body: {
943
1020
  type: 'ClassBody',
1021
+ loc: DUMMY_LOC,
944
1022
  body: classMembers,
945
1023
  },
946
1024
  declare: true,
@@ -952,7 +1030,8 @@ const getTransforms = (
952
1030
  superClass:
953
1031
  superClass == null
954
1032
  ? null
955
- : transform.Identifier(superClass.id, false),
1033
+ : // Bug: superclass.id can be qualified
1034
+ transform.Identifier((superClass.id: $FlowFixMe), false),
956
1035
  superTypeParameters:
957
1036
  superClass?.typeParameters == null
958
1037
  ? undefined
@@ -991,8 +1070,10 @@ const getTransforms = (
991
1070
  classDecl,
992
1071
  {
993
1072
  type: 'ExportDefaultDeclaration',
1073
+ loc: DUMMY_LOC,
994
1074
  declaration: {
995
1075
  type: 'Identifier',
1076
+ loc: DUMMY_LOC,
996
1077
  name,
997
1078
  },
998
1079
  exportKind: 'value',
@@ -1008,8 +1089,10 @@ const getTransforms = (
1008
1089
  functionDecl,
1009
1090
  {
1010
1091
  type: 'ExportDefaultDeclaration',
1092
+ loc: DUMMY_LOC,
1011
1093
  declaration: {
1012
1094
  type: 'Identifier',
1095
+ loc: DUMMY_LOC,
1013
1096
  name,
1014
1097
  },
1015
1098
  exportKind: 'value',
@@ -1025,8 +1108,10 @@ const getTransforms = (
1025
1108
  functionDecl,
1026
1109
  {
1027
1110
  type: 'ExportDefaultDeclaration',
1111
+ loc: DUMMY_LOC,
1028
1112
  declaration: {
1029
1113
  type: 'Identifier',
1114
+ loc: DUMMY_LOC,
1030
1115
  name,
1031
1116
  },
1032
1117
  exportKind: 'value',
@@ -1042,8 +1127,10 @@ const getTransforms = (
1042
1127
  functionDecl,
1043
1128
  {
1044
1129
  type: 'ExportDefaultDeclaration',
1130
+ loc: DUMMY_LOC,
1045
1131
  declaration: {
1046
1132
  type: 'Identifier',
1133
+ loc: DUMMY_LOC,
1047
1134
  name,
1048
1135
  },
1049
1136
  exportKind: 'value',
@@ -1090,8 +1177,10 @@ const getTransforms = (
1090
1177
  // there's already a variable defined to hold the type
1091
1178
  return {
1092
1179
  type: 'ExportDefaultDeclaration',
1180
+ loc: DUMMY_LOC,
1093
1181
  declaration: {
1094
1182
  type: 'Identifier',
1183
+ loc: DUMMY_LOC,
1095
1184
  name: referencedId.name,
1096
1185
  },
1097
1186
  exportKind: 'value',
@@ -1132,14 +1221,18 @@ const getTransforms = (
1132
1221
  return [
1133
1222
  {
1134
1223
  type: 'VariableDeclaration',
1224
+ loc: DUMMY_LOC,
1135
1225
  declarations: [
1136
1226
  {
1137
1227
  type: 'VariableDeclarator',
1228
+ loc: DUMMY_LOC,
1138
1229
  id: {
1139
1230
  type: 'Identifier',
1231
+ loc: DUMMY_LOC,
1140
1232
  name: SPECIFIER,
1141
1233
  typeAnnotation: {
1142
1234
  type: 'TSTypeAnnotation',
1235
+ loc: DUMMY_LOC,
1143
1236
  typeAnnotation:
1144
1237
  transformTypeAnnotationType(declaration),
1145
1238
  },
@@ -1152,8 +1245,10 @@ const getTransforms = (
1152
1245
  },
1153
1246
  {
1154
1247
  type: 'ExportDefaultDeclaration',
1248
+ loc: DUMMY_LOC,
1155
1249
  declaration: {
1156
1250
  type: 'Identifier',
1251
+ loc: DUMMY_LOC,
1157
1252
  name: SPECIFIER,
1158
1253
  },
1159
1254
  exportKind: 'value',
@@ -1168,6 +1263,7 @@ const getTransforms = (
1168
1263
  if (node.declaration === null) {
1169
1264
  return ({
1170
1265
  type: 'ExportNamedDeclaration',
1266
+ loc: DUMMY_LOC,
1171
1267
  // flow does not currently support assertions
1172
1268
  assertions: [],
1173
1269
  declaration: null,
@@ -1251,6 +1347,7 @@ const getTransforms = (
1251
1347
  ({declaration, exportKind}) =>
1252
1348
  ({
1253
1349
  type: 'ExportNamedDeclaration',
1350
+ loc: DUMMY_LOC,
1254
1351
  // flow does not currently support assertions
1255
1352
  assertions: [],
1256
1353
  declaration,
@@ -1262,6 +1359,7 @@ const getTransforms = (
1262
1359
  } else {
1263
1360
  return ({
1264
1361
  type: 'ExportNamedDeclaration',
1362
+ loc: DUMMY_LOC,
1265
1363
  // flow does not currently support assertions
1266
1364
  assertions: [],
1267
1365
  declaration: null,
@@ -1287,16 +1385,20 @@ const getTransforms = (
1287
1385
 
1288
1386
  // TS cannot support `renderType` so we always use ReactNode as the return type.
1289
1387
  const hasReactImport = isReactImport(node, 'React');
1290
- const returnType = {
1388
+ const returnType: TSESTree.TSTypeAnnotation = {
1291
1389
  type: 'TSTypeAnnotation',
1390
+ loc: DUMMY_LOC,
1292
1391
  // If no rendersType we assume its ReactNode type.
1293
1392
  typeAnnotation: {
1294
1393
  type: 'TSTypeReference',
1394
+ loc: DUMMY_LOC,
1295
1395
  typeName: {
1296
1396
  type: 'TSQualifiedName',
1397
+ loc: DUMMY_LOC,
1297
1398
  left: getReactIdentifier(hasReactImport),
1298
1399
  right: {
1299
1400
  type: 'Identifier',
1401
+ loc: DUMMY_LOC,
1300
1402
  name: `ReactNode`,
1301
1403
  },
1302
1404
  },
@@ -1306,6 +1408,7 @@ const getTransforms = (
1306
1408
 
1307
1409
  return {
1308
1410
  type: 'TSDeclareFunction',
1411
+ loc: DUMMY_LOC,
1309
1412
  async: false,
1310
1413
  body: undefined,
1311
1414
  declare: true,
@@ -1313,6 +1416,7 @@ const getTransforms = (
1313
1416
  generator: false,
1314
1417
  id: {
1315
1418
  type: 'Identifier',
1419
+ loc: DUMMY_LOC,
1316
1420
  name: id.name,
1317
1421
  },
1318
1422
  params,
@@ -1328,9 +1432,11 @@ const getTransforms = (
1328
1432
  return [
1329
1433
  {
1330
1434
  type: 'Identifier',
1435
+ loc: DUMMY_LOC,
1331
1436
  name: 'props',
1332
1437
  typeAnnotation: {
1333
1438
  type: 'TSTypeAnnotation',
1439
+ loc: DUMMY_LOC,
1334
1440
  typeAnnotation: transformTypeAnnotationType(rest.typeAnnotation),
1335
1441
  },
1336
1442
  optional: false,
@@ -1392,9 +1498,11 @@ const getTransforms = (
1392
1498
  return [
1393
1499
  {
1394
1500
  type: 'Identifier',
1501
+ loc: DUMMY_LOC,
1395
1502
  name: 'props',
1396
1503
  typeAnnotation: {
1397
1504
  type: 'TSTypeAnnotation',
1505
+ loc: DUMMY_LOC,
1398
1506
  typeAnnotation: tsPropsObjectType,
1399
1507
  },
1400
1508
  optional: false,
@@ -1410,6 +1518,7 @@ const getTransforms = (
1410
1518
 
1411
1519
  return {
1412
1520
  type: 'TSDeclareFunction',
1521
+ loc: DUMMY_LOC,
1413
1522
  async: false,
1414
1523
  body: undefined,
1415
1524
  declare: true,
@@ -1417,6 +1526,7 @@ const getTransforms = (
1417
1526
  generator: false,
1418
1527
  id: {
1419
1528
  type: 'Identifier',
1529
+ loc: DUMMY_LOC,
1420
1530
  name: id.name,
1421
1531
  },
1422
1532
  params: functionInfo.params,
@@ -1435,6 +1545,7 @@ const getTransforms = (
1435
1545
 
1436
1546
  return {
1437
1547
  type: 'TSDeclareFunction',
1548
+ loc: DUMMY_LOC,
1438
1549
  async: false,
1439
1550
  body: undefined,
1440
1551
  declare: true,
@@ -1442,6 +1553,7 @@ const getTransforms = (
1442
1553
  generator: false,
1443
1554
  id: {
1444
1555
  type: 'Identifier',
1556
+ loc: DUMMY_LOC,
1445
1557
  name: id.name,
1446
1558
  },
1447
1559
  params: functionInfo.params,
@@ -1462,8 +1574,10 @@ const getTransforms = (
1462
1574
 
1463
1575
  return {
1464
1576
  type: 'TSInterfaceDeclaration',
1577
+ loc: DUMMY_LOC,
1465
1578
  body: {
1466
1579
  type: 'TSInterfaceBody',
1580
+ loc: DUMMY_LOC,
1467
1581
  body: transformedBody.members,
1468
1582
  },
1469
1583
  declare: node.type !== 'InterfaceDeclaration',
@@ -1480,6 +1594,7 @@ const getTransforms = (
1480
1594
  ): TSESTree.TSTypeAliasDeclaration {
1481
1595
  return {
1482
1596
  type: 'TSTypeAliasDeclaration',
1597
+ loc: DUMMY_LOC,
1483
1598
  declare: node.type === 'DeclareTypeAlias',
1484
1599
  id: transform.Identifier(node.id, false),
1485
1600
  typeAnnotation: transformTypeAnnotationType(node.right),
@@ -1498,12 +1613,14 @@ const getTransforms = (
1498
1613
 
1499
1614
  return {
1500
1615
  type: 'TSTypeAliasDeclaration',
1616
+ loc: DUMMY_LOC,
1501
1617
  declare: true,
1502
1618
  id: transform.Identifier(node.id, false),
1503
1619
  typeAnnotation:
1504
1620
  node.supertype == null
1505
1621
  ? {
1506
1622
  type: 'TSUnknownKeyword',
1623
+ loc: DUMMY_LOC,
1507
1624
  }
1508
1625
  : transformTypeAnnotationType(node.supertype),
1509
1626
  typeParameters:
@@ -1517,10 +1634,12 @@ const getTransforms = (
1517
1634
  ): TSESTree.VariableDeclaration {
1518
1635
  return {
1519
1636
  type: 'VariableDeclaration',
1637
+ loc: DUMMY_LOC,
1520
1638
  declare: true,
1521
1639
  declarations: [
1522
1640
  {
1523
1641
  type: 'VariableDeclarator',
1642
+ loc: DUMMY_LOC,
1524
1643
  declare: true,
1525
1644
  id: transform.Identifier(node.id, true),
1526
1645
  init: null,
@@ -1569,6 +1688,7 @@ const getTransforms = (
1569
1688
  ): TSESTree.ExportAllDeclaration {
1570
1689
  return {
1571
1690
  type: 'ExportAllDeclaration',
1691
+ loc: DUMMY_LOC,
1572
1692
  // flow does not currently support import/export assertions
1573
1693
  assertions: [],
1574
1694
  exportKind: node.exportKind,
@@ -1586,6 +1706,7 @@ const getTransforms = (
1586
1706
  // can never have a declaration with a source
1587
1707
  return {
1588
1708
  type: 'ExportNamedDeclaration',
1709
+ loc: DUMMY_LOC,
1589
1710
  // flow does not currently support import/export assertions
1590
1711
  assertions: [],
1591
1712
  declaration: null,
@@ -1629,6 +1750,7 @@ const getTransforms = (
1629
1750
 
1630
1751
  const mainExport = {
1631
1752
  type: 'ExportNamedDeclaration',
1753
+ loc: DUMMY_LOC,
1632
1754
  assertions: [],
1633
1755
  declaration: exportedDeclaration,
1634
1756
  exportKind: node.exportKind,
@@ -1642,6 +1764,7 @@ const getTransforms = (
1642
1764
  mainExport,
1643
1765
  {
1644
1766
  type: 'ExportNamedDeclaration',
1767
+ loc: DUMMY_LOC,
1645
1768
  assertions: [],
1646
1769
  declaration: mergedDeclaration,
1647
1770
  exportKind: node.exportKind,
@@ -1658,6 +1781,7 @@ const getTransforms = (
1658
1781
  ): TSESTree.ExportSpecifier {
1659
1782
  return {
1660
1783
  type: 'ExportSpecifier',
1784
+ loc: DUMMY_LOC,
1661
1785
  exported: transform.Identifier(node.exported, false),
1662
1786
  local: transform.Identifier(node.local, false),
1663
1787
  // flow does not support inline exportKind for named exports
@@ -1671,9 +1795,11 @@ const getTransforms = (
1671
1795
  if (node.type === 'FunctionTypeAnnotation' && node.this != null) {
1672
1796
  params.unshift({
1673
1797
  type: 'Identifier',
1798
+ loc: DUMMY_LOC,
1674
1799
  name: 'this',
1675
1800
  typeAnnotation: {
1676
1801
  type: 'TSTypeAnnotation',
1802
+ loc: DUMMY_LOC,
1677
1803
  typeAnnotation: transformTypeAnnotationType(
1678
1804
  node.this.typeAnnotation,
1679
1805
  ),
@@ -1684,15 +1810,18 @@ const getTransforms = (
1684
1810
  const rest = node.rest;
1685
1811
  params.push({
1686
1812
  type: 'RestElement',
1813
+ loc: DUMMY_LOC,
1687
1814
  argument:
1688
1815
  rest.name == null
1689
1816
  ? {
1690
1817
  type: 'Identifier',
1818
+ loc: DUMMY_LOC,
1691
1819
  name: '$$REST$$',
1692
1820
  }
1693
1821
  : transform.Identifier(rest.name, false),
1694
1822
  typeAnnotation: {
1695
1823
  type: 'TSTypeAnnotation',
1824
+ loc: DUMMY_LOC,
1696
1825
  typeAnnotation: transformTypeAnnotationType(rest.typeAnnotation),
1697
1826
  },
1698
1827
  });
@@ -1700,9 +1829,11 @@ const getTransforms = (
1700
1829
 
1701
1830
  return {
1702
1831
  type: 'TSFunctionType',
1832
+ loc: DUMMY_LOC,
1703
1833
  params,
1704
1834
  returnType: {
1705
1835
  type: 'TSTypeAnnotation',
1836
+ loc: DUMMY_LOC,
1706
1837
  typeAnnotation: transformTypeAnnotationType(node.returnType),
1707
1838
  },
1708
1839
  typeParameters:
@@ -1717,9 +1848,11 @@ const getTransforms = (
1717
1848
  ): TSESTree.Parameter {
1718
1849
  return {
1719
1850
  type: 'Identifier',
1851
+ loc: DUMMY_LOC,
1720
1852
  name: node.name == null ? `$$PARAM_${idx}$$` : node.name.name,
1721
1853
  typeAnnotation: {
1722
1854
  type: 'TSTypeAnnotation',
1855
+ loc: DUMMY_LOC,
1723
1856
  typeAnnotation: transformTypeAnnotationType(node.typeAnnotation),
1724
1857
  },
1725
1858
  optional: node.optional,
@@ -1819,30 +1952,38 @@ const getTransforms = (
1819
1952
  const params = assertHasExactlyNTypeParameters(2);
1820
1953
  return {
1821
1954
  type: 'TSTypeReference',
1955
+ loc: DUMMY_LOC,
1822
1956
  typeName: {
1823
1957
  type: 'Identifier',
1958
+ loc: DUMMY_LOC,
1824
1959
  name: 'Pick',
1825
1960
  },
1826
1961
  typeParameters: {
1827
1962
  type: 'TSTypeParameterInstantiation',
1963
+ loc: DUMMY_LOC,
1828
1964
  params: [
1829
1965
  params[0],
1830
1966
  {
1831
1967
  type: 'TSTypeReference',
1968
+ loc: DUMMY_LOC,
1832
1969
  typeName: {
1833
1970
  type: 'Identifier',
1971
+ loc: DUMMY_LOC,
1834
1972
  name: 'Exclude',
1835
1973
  },
1836
1974
  typeParameters: {
1837
1975
  type: 'TSTypeParameterInstantiation',
1976
+ loc: DUMMY_LOC,
1838
1977
  params: [
1839
1978
  {
1840
1979
  type: 'TSTypeOperator',
1980
+ loc: DUMMY_LOC,
1841
1981
  operator: 'keyof',
1842
1982
  typeAnnotation: params[0],
1843
1983
  },
1844
1984
  {
1845
1985
  type: 'TSTypeOperator',
1986
+ loc: DUMMY_LOC,
1846
1987
  operator: 'keyof',
1847
1988
  typeAnnotation: params[1],
1848
1989
  },
@@ -1860,6 +2001,7 @@ const getTransforms = (
1860
2001
  const params = assertHasExactlyNTypeParameters(2);
1861
2002
  return {
1862
2003
  type: 'TSIndexedAccessType',
2004
+ loc: DUMMY_LOC,
1863
2005
  objectType: params[0],
1864
2006
  indexType: params[1],
1865
2007
  };
@@ -1887,6 +2029,7 @@ const getTransforms = (
1887
2029
 
1888
2030
  return {
1889
2031
  type: 'TSImportType',
2032
+ loc: DUMMY_LOC,
1890
2033
  isTypeOf: true,
1891
2034
  argument: moduleName,
1892
2035
  qualifier: null,
@@ -1898,6 +2041,7 @@ const getTransforms = (
1898
2041
  // `$FlowFixMe` => `any`
1899
2042
  return {
1900
2043
  type: 'TSAnyKeyword',
2044
+ loc: DUMMY_LOC,
1901
2045
  };
1902
2046
  }
1903
2047
 
@@ -1905,14 +2049,18 @@ const getTransforms = (
1905
2049
  // `$KeyMirror<T>` => `{[K in keyof T]: K}`
1906
2050
  return {
1907
2051
  type: 'TSMappedType',
2052
+ loc: DUMMY_LOC,
1908
2053
  typeParameter: {
1909
2054
  type: 'TSTypeParameter',
2055
+ loc: DUMMY_LOC,
1910
2056
  name: {
1911
2057
  type: 'Identifier',
2058
+ loc: DUMMY_LOC,
1912
2059
  name: 'K',
1913
2060
  },
1914
2061
  constraint: {
1915
2062
  type: 'TSTypeOperator',
2063
+ loc: DUMMY_LOC,
1916
2064
  operator: 'keyof',
1917
2065
  typeAnnotation: assertHasExactlyNTypeParameters(1)[0],
1918
2066
  },
@@ -1922,8 +2070,10 @@ const getTransforms = (
1922
2070
  nameType: null,
1923
2071
  typeAnnotation: {
1924
2072
  type: 'TSTypeReference',
2073
+ loc: DUMMY_LOC,
1925
2074
  typeName: {
1926
2075
  type: 'Identifier',
2076
+ loc: DUMMY_LOC,
1927
2077
  name: 'K',
1928
2078
  },
1929
2079
  },
@@ -1934,6 +2084,7 @@ const getTransforms = (
1934
2084
  // `$Keys<T>` => `keyof T`
1935
2085
  return {
1936
2086
  type: 'TSTypeOperator',
2087
+ loc: DUMMY_LOC,
1937
2088
  operator: 'keyof',
1938
2089
  typeAnnotation: assertHasExactlyNTypeParameters(1)[0],
1939
2090
  };
@@ -1944,12 +2095,15 @@ const getTransforms = (
1944
2095
  // Not a great name because `NonNullable` also excludes `undefined`
1945
2096
  return {
1946
2097
  type: 'TSTypeReference',
2098
+ loc: DUMMY_LOC,
1947
2099
  typeName: {
1948
2100
  type: 'Identifier',
2101
+ loc: DUMMY_LOC,
1949
2102
  name: 'NonNullable',
1950
2103
  },
1951
2104
  typeParameters: {
1952
2105
  type: 'TSTypeParameterInstantiation',
2106
+ loc: DUMMY_LOC,
1953
2107
  params: assertHasExactlyNTypeParameters(1),
1954
2108
  },
1955
2109
  };
@@ -1959,12 +2113,15 @@ const getTransforms = (
1959
2113
  // `$ReadOnly<T>` => `Readonly<T>`
1960
2114
  return {
1961
2115
  type: 'TSTypeReference',
2116
+ loc: DUMMY_LOC,
1962
2117
  typeName: {
1963
2118
  type: 'Identifier',
2119
+ loc: DUMMY_LOC,
1964
2120
  name: 'Readonly',
1965
2121
  },
1966
2122
  typeParameters: {
1967
2123
  type: 'TSTypeParameterInstantiation',
2124
+ loc: DUMMY_LOC,
1968
2125
  params: assertHasExactlyNTypeParameters(1),
1969
2126
  },
1970
2127
  };
@@ -1977,12 +2134,15 @@ const getTransforms = (
1977
2134
  // TODO - maybe a config option?
1978
2135
  return {
1979
2136
  type: 'TSTypeReference',
2137
+ loc: DUMMY_LOC,
1980
2138
  typeName: {
1981
2139
  type: 'Identifier',
2140
+ loc: DUMMY_LOC,
1982
2141
  name: 'ReadonlyArray',
1983
2142
  },
1984
2143
  typeParameters: {
1985
2144
  type: 'TSTypeParameterInstantiation',
2145
+ loc: DUMMY_LOC,
1986
2146
  params: assertHasExactlyNTypeParameters(1),
1987
2147
  },
1988
2148
  };
@@ -1991,12 +2151,15 @@ const getTransforms = (
1991
2151
  case '$ReadOnlyMap': {
1992
2152
  return {
1993
2153
  type: 'TSTypeReference',
2154
+ loc: DUMMY_LOC,
1994
2155
  typeName: {
1995
2156
  type: 'Identifier',
2157
+ loc: DUMMY_LOC,
1996
2158
  name: 'ReadonlyMap',
1997
2159
  },
1998
2160
  typeParameters: {
1999
2161
  type: 'TSTypeParameterInstantiation',
2162
+ loc: DUMMY_LOC,
2000
2163
  params: assertHasExactlyNTypeParameters(2),
2001
2164
  },
2002
2165
  };
@@ -2005,12 +2168,15 @@ const getTransforms = (
2005
2168
  case '$ReadOnlySet': {
2006
2169
  return {
2007
2170
  type: 'TSTypeReference',
2171
+ loc: DUMMY_LOC,
2008
2172
  typeName: {
2009
2173
  type: 'Identifier',
2174
+ loc: DUMMY_LOC,
2010
2175
  name: 'ReadonlySet',
2011
2176
  },
2012
2177
  typeParameters: {
2013
2178
  type: 'TSTypeParameterInstantiation',
2179
+ loc: DUMMY_LOC,
2014
2180
  params: assertHasExactlyNTypeParameters(1),
2015
2181
  },
2016
2182
  };
@@ -2021,9 +2187,11 @@ const getTransforms = (
2021
2187
  const transformedType = assertHasExactlyNTypeParameters(1)[0];
2022
2188
  return {
2023
2189
  type: 'TSIndexedAccessType',
2190
+ loc: DUMMY_LOC,
2024
2191
  objectType: transformedType,
2025
2192
  indexType: {
2026
2193
  type: 'TSTypeOperator',
2194
+ loc: DUMMY_LOC,
2027
2195
  operator: 'keyof',
2028
2196
  typeAnnotation: transformedType,
2029
2197
  },
@@ -2042,20 +2210,26 @@ const getTransforms = (
2042
2210
 
2043
2211
  return {
2044
2212
  type: 'TSConstructorType',
2213
+ loc: DUMMY_LOC,
2045
2214
  abstract: false,
2046
2215
  params: [
2047
2216
  {
2048
2217
  type: 'RestElement',
2218
+ loc: DUMMY_LOC,
2049
2219
  argument: {
2050
2220
  type: 'Identifier',
2221
+ loc: DUMMY_LOC,
2051
2222
  name: 'args',
2052
2223
  },
2053
2224
  typeAnnotation: {
2054
2225
  type: 'TSTypeAnnotation',
2226
+ loc: DUMMY_LOC,
2055
2227
  typeAnnotation: {
2056
2228
  type: 'TSArrayType',
2229
+ loc: DUMMY_LOC,
2057
2230
  elementType: {
2058
2231
  type: 'TSAnyKeyword',
2232
+ loc: DUMMY_LOC,
2059
2233
  },
2060
2234
  },
2061
2235
  },
@@ -2063,6 +2237,7 @@ const getTransforms = (
2063
2237
  ],
2064
2238
  returnType: {
2065
2239
  type: 'TSTypeAnnotation',
2240
+ loc: DUMMY_LOC,
2066
2241
  typeAnnotation: param,
2067
2242
  },
2068
2243
  };
@@ -2085,16 +2260,20 @@ const getTransforms = (
2085
2260
  const [param] = assertHasExactlyNTypeParameters(1);
2086
2261
  return {
2087
2262
  type: 'TSUnionType',
2263
+ loc: DUMMY_LOC,
2088
2264
  types: [
2089
2265
  param,
2090
2266
  {
2091
2267
  type: 'TSTypeReference',
2268
+ loc: DUMMY_LOC,
2092
2269
  typeName: {
2093
2270
  type: 'Identifier',
2271
+ loc: DUMMY_LOC,
2094
2272
  name: 'ReadonlyArray',
2095
2273
  },
2096
2274
  typeParameters: {
2097
2275
  type: 'TSTypeParameterInstantiation',
2276
+ loc: DUMMY_LOC,
2098
2277
  params: [param],
2099
2278
  },
2100
2279
  },
@@ -2122,16 +2301,20 @@ const getTransforms = (
2122
2301
 
2123
2302
  return {
2124
2303
  type: 'TSTypeReference',
2304
+ loc: DUMMY_LOC,
2125
2305
  typeName: {
2126
2306
  type: 'TSQualifiedName',
2307
+ loc: DUMMY_LOC,
2127
2308
  left: getReactIdentifier(hasReactImport),
2128
2309
  right: {
2129
2310
  type: 'Identifier',
2311
+ loc: DUMMY_LOC,
2130
2312
  name: 'Component',
2131
2313
  },
2132
2314
  },
2133
2315
  typeParameters: {
2134
2316
  type: 'TSTypeParameterInstantiation',
2317
+ loc: DUMMY_LOC,
2135
2318
  params: params.map(param => transformTypeAnnotationType(param)),
2136
2319
  },
2137
2320
  };
@@ -2143,16 +2326,20 @@ const getTransforms = (
2143
2326
  case 'React.Context':
2144
2327
  return {
2145
2328
  type: 'TSTypeReference',
2329
+ loc: DUMMY_LOC,
2146
2330
  typeName: {
2147
2331
  type: 'TSQualifiedName',
2332
+ loc: DUMMY_LOC,
2148
2333
  left: getReactIdentifier(hasReactImport),
2149
2334
  right: {
2150
2335
  type: 'Identifier',
2336
+ loc: DUMMY_LOC,
2151
2337
  name: `Context`,
2152
2338
  },
2153
2339
  },
2154
2340
  typeParameters: {
2155
2341
  type: 'TSTypeParameterInstantiation',
2342
+ loc: DUMMY_LOC,
2156
2343
  params: assertHasExactlyNTypeParameters(1),
2157
2344
  },
2158
2345
  };
@@ -2163,11 +2350,14 @@ const getTransforms = (
2163
2350
  assertHasExactlyNTypeParameters(0);
2164
2351
  return {
2165
2352
  type: 'TSTypeReference',
2353
+ loc: DUMMY_LOC,
2166
2354
  typeName: {
2167
2355
  type: 'TSQualifiedName',
2356
+ loc: DUMMY_LOC,
2168
2357
  left: getReactIdentifier(hasReactImport),
2169
2358
  right: {
2170
2359
  type: 'Identifier',
2360
+ loc: DUMMY_LOC,
2171
2361
  name: 'Key',
2172
2362
  },
2173
2363
  },
@@ -2179,11 +2369,14 @@ const getTransforms = (
2179
2369
  assertHasExactlyNTypeParameters(0);
2180
2370
  return {
2181
2371
  type: 'TSTypeReference',
2372
+ loc: DUMMY_LOC,
2182
2373
  typeName: {
2183
2374
  type: 'TSQualifiedName',
2375
+ loc: DUMMY_LOC,
2184
2376
  left: getReactIdentifier(hasReactImport),
2185
2377
  right: {
2186
2378
  type: 'Identifier',
2379
+ loc: DUMMY_LOC,
2187
2380
  name: `ElementType`,
2188
2381
  },
2189
2382
  },
@@ -2196,11 +2389,14 @@ const getTransforms = (
2196
2389
  assertHasExactlyNTypeParameters(0);
2197
2390
  return {
2198
2391
  type: 'TSTypeReference',
2392
+ loc: DUMMY_LOC,
2199
2393
  typeName: {
2200
2394
  type: 'TSQualifiedName',
2395
+ loc: DUMMY_LOC,
2201
2396
  left: getReactIdentifier(hasReactImport),
2202
2397
  right: {
2203
2398
  type: 'Identifier',
2399
+ loc: DUMMY_LOC,
2204
2400
  name: `ReactNode`,
2205
2401
  },
2206
2402
  },
@@ -2212,16 +2408,20 @@ const getTransforms = (
2212
2408
  case 'React.Element': {
2213
2409
  return {
2214
2410
  type: 'TSTypeReference',
2411
+ loc: DUMMY_LOC,
2215
2412
  typeName: {
2216
2413
  type: 'TSQualifiedName',
2414
+ loc: DUMMY_LOC,
2217
2415
  left: getReactIdentifier(hasReactImport),
2218
2416
  right: {
2219
2417
  type: 'Identifier',
2418
+ loc: DUMMY_LOC,
2220
2419
  name: `ReactElement`,
2221
2420
  },
2222
2421
  },
2223
2422
  typeParameters: {
2224
2423
  type: 'TSTypeParameterInstantiation',
2424
+ loc: DUMMY_LOC,
2225
2425
  params: assertHasExactlyNTypeParameters(1),
2226
2426
  },
2227
2427
  };
@@ -2232,16 +2432,20 @@ const getTransforms = (
2232
2432
  case 'React.ElementRef':
2233
2433
  return {
2234
2434
  type: 'TSTypeReference',
2435
+ loc: DUMMY_LOC,
2235
2436
  typeName: {
2236
2437
  type: 'TSQualifiedName',
2438
+ loc: DUMMY_LOC,
2237
2439
  left: getReactIdentifier(hasReactImport),
2238
2440
  right: {
2239
2441
  type: 'Identifier',
2442
+ loc: DUMMY_LOC,
2240
2443
  name: `ElementRef`,
2241
2444
  },
2242
2445
  },
2243
2446
  typeParameters: {
2244
2447
  type: 'TSTypeParameterInstantiation',
2448
+ loc: DUMMY_LOC,
2245
2449
  params: assertHasExactlyNTypeParameters(1),
2246
2450
  },
2247
2451
  };
@@ -2252,11 +2456,14 @@ const getTransforms = (
2252
2456
  assertHasExactlyNTypeParameters(0);
2253
2457
  return {
2254
2458
  type: 'TSTypeReference',
2459
+ loc: DUMMY_LOC,
2255
2460
  typeName: {
2256
2461
  type: 'TSQualifiedName',
2462
+ loc: DUMMY_LOC,
2257
2463
  left: getReactIdentifier(hasReactImport),
2258
2464
  right: {
2259
2465
  type: 'Identifier',
2466
+ loc: DUMMY_LOC,
2260
2467
  name: `Fragment`,
2261
2468
  },
2262
2469
  },
@@ -2267,14 +2474,18 @@ const getTransforms = (
2267
2474
  assertHasExactlyNTypeParameters(0);
2268
2475
  return {
2269
2476
  type: 'TSTypeReference',
2477
+ loc: DUMMY_LOC,
2270
2478
  typeName: {
2271
2479
  type: 'TSQualifiedName',
2480
+ loc: DUMMY_LOC,
2272
2481
  left: {
2273
2482
  type: 'Identifier',
2483
+ loc: DUMMY_LOC,
2274
2484
  name: 'JSX',
2275
2485
  },
2276
2486
  right: {
2277
2487
  type: 'Identifier',
2488
+ loc: DUMMY_LOC,
2278
2489
  name: 'Element',
2279
2490
  },
2280
2491
  },
@@ -2287,16 +2498,20 @@ const getTransforms = (
2287
2498
  case 'React$ComponentType': {
2288
2499
  return {
2289
2500
  type: 'TSTypeReference',
2501
+ loc: DUMMY_LOC,
2290
2502
  typeName: {
2291
2503
  type: 'TSQualifiedName',
2504
+ loc: DUMMY_LOC,
2292
2505
  left: getReactIdentifier(hasReactImport),
2293
2506
  right: {
2294
2507
  type: 'Identifier',
2508
+ loc: DUMMY_LOC,
2295
2509
  name: 'ComponentType',
2296
2510
  },
2297
2511
  },
2298
2512
  typeParameters: {
2299
2513
  type: 'TSTypeParameterInstantiation',
2514
+ loc: DUMMY_LOC,
2300
2515
  params: assertHasExactlyNTypeParameters(1),
2301
2516
  },
2302
2517
  };
@@ -2332,23 +2547,29 @@ const getTransforms = (
2332
2547
  return [
2333
2548
  {
2334
2549
  type: 'TSIntersectionType',
2550
+ loc: DUMMY_LOC,
2335
2551
  types: [
2336
2552
  props,
2337
2553
  {
2338
2554
  type: 'TSTypeReference',
2555
+ loc: DUMMY_LOC,
2339
2556
  typeName: {
2340
2557
  type: 'TSQualifiedName',
2558
+ loc: DUMMY_LOC,
2341
2559
  left: {
2342
2560
  type: 'Identifier',
2561
+ loc: DUMMY_LOC,
2343
2562
  name: 'React',
2344
2563
  },
2345
2564
  right: {
2346
2565
  type: 'Identifier',
2566
+ loc: DUMMY_LOC,
2347
2567
  name: 'RefAttributes',
2348
2568
  },
2349
2569
  },
2350
2570
  typeParameters: {
2351
2571
  type: 'TSTypeParameterInstantiation',
2572
+ loc: DUMMY_LOC,
2352
2573
  params: [ref],
2353
2574
  },
2354
2575
  },
@@ -2359,16 +2580,20 @@ const getTransforms = (
2359
2580
 
2360
2581
  return {
2361
2582
  type: 'TSTypeReference',
2583
+ loc: DUMMY_LOC,
2362
2584
  typeName: {
2363
2585
  type: 'TSQualifiedName',
2586
+ loc: DUMMY_LOC,
2364
2587
  left: getReactIdentifier(hasReactImport),
2365
2588
  right: {
2366
2589
  type: 'Identifier',
2590
+ loc: DUMMY_LOC,
2367
2591
  name: 'ComponentType',
2368
2592
  },
2369
2593
  },
2370
2594
  typeParameters: {
2371
2595
  type: 'TSTypeParameterInstantiation',
2596
+ loc: DUMMY_LOC,
2372
2597
  params: newParams,
2373
2598
  },
2374
2599
  };
@@ -2379,16 +2604,20 @@ const getTransforms = (
2379
2604
  case 'React$ElementProps': {
2380
2605
  return {
2381
2606
  type: 'TSTypeReference',
2607
+ loc: DUMMY_LOC,
2382
2608
  typeName: {
2383
2609
  type: 'TSQualifiedName',
2610
+ loc: DUMMY_LOC,
2384
2611
  left: getReactIdentifier(hasReactImport),
2385
2612
  right: {
2386
2613
  type: 'Identifier',
2614
+ loc: DUMMY_LOC,
2387
2615
  name: 'ComponentProps',
2388
2616
  },
2389
2617
  },
2390
2618
  typeParameters: {
2391
2619
  type: 'TSTypeParameterInstantiation',
2620
+ loc: DUMMY_LOC,
2392
2621
  params: assertHasExactlyNTypeParameters(1),
2393
2622
  },
2394
2623
  };
@@ -2400,33 +2629,42 @@ const getTransforms = (
2400
2629
  const [param] = assertHasExactlyNTypeParameters(1);
2401
2630
  return {
2402
2631
  type: 'TSTypeReference',
2632
+ loc: DUMMY_LOC,
2403
2633
  typeName: {
2404
2634
  type: 'TSQualifiedName',
2635
+ loc: DUMMY_LOC,
2405
2636
  left: {
2406
2637
  type: 'Identifier',
2638
+ loc: DUMMY_LOC,
2407
2639
  name: 'JSX',
2408
2640
  },
2409
2641
  right: {
2410
2642
  type: 'Identifier',
2643
+ loc: DUMMY_LOC,
2411
2644
  name: 'LibraryManagedAttributes',
2412
2645
  },
2413
2646
  },
2414
2647
  typeParameters: {
2415
2648
  type: 'TSTypeParameterInstantiation',
2649
+ loc: DUMMY_LOC,
2416
2650
  params: [
2417
2651
  param,
2418
2652
  {
2419
2653
  type: 'TSTypeReference',
2654
+ loc: DUMMY_LOC,
2420
2655
  typeName: {
2421
2656
  type: 'TSQualifiedName',
2657
+ loc: DUMMY_LOC,
2422
2658
  left: getReactIdentifier(hasReactImport),
2423
2659
  right: {
2424
2660
  type: 'Identifier',
2661
+ loc: DUMMY_LOC,
2425
2662
  name: `ComponentProps`,
2426
2663
  },
2427
2664
  },
2428
2665
  typeParameters: {
2429
2666
  type: 'TSTypeParameterInstantiation',
2667
+ loc: DUMMY_LOC,
2430
2668
  params: [param],
2431
2669
  },
2432
2670
  },
@@ -2440,36 +2678,46 @@ const getTransforms = (
2440
2678
  case 'React$Ref':
2441
2679
  return {
2442
2680
  type: 'TSTypeReference',
2681
+ loc: DUMMY_LOC,
2443
2682
  typeName: {
2444
2683
  type: 'Identifier',
2684
+ loc: DUMMY_LOC,
2445
2685
  name: 'NonNullable',
2446
2686
  },
2447
2687
  typeParameters: {
2448
2688
  type: 'TSTypeParameterInstantiation',
2689
+ loc: DUMMY_LOC,
2449
2690
  params: [
2450
2691
  {
2451
2692
  type: 'TSUnionType',
2693
+ loc: DUMMY_LOC,
2452
2694
  types: [
2453
2695
  {
2454
2696
  type: 'TSTypeReference',
2697
+ loc: DUMMY_LOC,
2455
2698
  typeName: {
2456
2699
  type: 'TSQualifiedName',
2700
+ loc: DUMMY_LOC,
2457
2701
  left: getReactIdentifier(hasReactImport),
2458
2702
  right: {
2459
2703
  type: 'Identifier',
2704
+ loc: DUMMY_LOC,
2460
2705
  name: 'Ref',
2461
2706
  },
2462
2707
  },
2463
2708
  typeParameters: {
2464
2709
  type: 'TSTypeParameterInstantiation',
2710
+ loc: DUMMY_LOC,
2465
2711
  params: assertHasExactlyNTypeParameters(1),
2466
2712
  },
2467
2713
  },
2468
2714
  {
2469
2715
  type: 'TSStringKeyword',
2716
+ loc: DUMMY_LOC,
2470
2717
  },
2471
2718
  {
2472
2719
  type: 'TSNumberKeyword',
2720
+ loc: DUMMY_LOC,
2473
2721
  },
2474
2722
  ],
2475
2723
  },
@@ -2483,6 +2731,7 @@ const getTransforms = (
2483
2731
 
2484
2732
  return {
2485
2733
  type: 'TSTypeReference',
2734
+ loc: DUMMY_LOC,
2486
2735
  typeName:
2487
2736
  node.id.type === 'Identifier'
2488
2737
  ? transform.Identifier(node.id, false)
@@ -2499,6 +2748,7 @@ const getTransforms = (
2499
2748
  ): TSESTree.Identifier {
2500
2749
  return {
2501
2750
  type: 'Identifier',
2751
+ loc: DUMMY_LOC,
2502
2752
  name: node.name,
2503
2753
  ...(includeTypeAnnotation && node.typeAnnotation != null
2504
2754
  ? {
@@ -2512,6 +2762,7 @@ const getTransforms = (
2512
2762
  ): TSESTree.TSIndexedAccessType {
2513
2763
  return {
2514
2764
  type: 'TSIndexedAccessType',
2765
+ loc: DUMMY_LOC,
2515
2766
  objectType: transformTypeAnnotationType(node.objectType),
2516
2767
  indexType: transformTypeAnnotationType(node.indexType),
2517
2768
  };
@@ -2526,6 +2777,7 @@ const getTransforms = (
2526
2777
  ): TSESTree.ImportAttribute {
2527
2778
  return {
2528
2779
  type: 'ImportAttribute',
2780
+ loc: DUMMY_LOC,
2529
2781
  key:
2530
2782
  node.key.type === 'Identifier'
2531
2783
  ? transform.Identifier(node.key)
@@ -2539,20 +2791,23 @@ const getTransforms = (
2539
2791
  const importKind = node.importKind;
2540
2792
 
2541
2793
  const specifiers = [];
2542
- const unsupportedSpecifiers = [];
2794
+ const unsupportedSpecifiers: Array<TSESTree.TSTypeAliasDeclaration> = [];
2543
2795
  node.specifiers.forEach(spec => {
2544
2796
  let id = (() => {
2545
2797
  if (node.importKind === 'typeof' || spec.importKind === 'typeof') {
2546
2798
  const id = {
2547
2799
  type: 'Identifier',
2800
+ loc: DUMMY_LOC,
2548
2801
  name: getPlaceholderNameForTypeofImport(),
2549
2802
  };
2550
2803
 
2551
2804
  unsupportedSpecifiers.push({
2552
2805
  type: 'TSTypeAliasDeclaration',
2806
+ loc: DUMMY_LOC,
2553
2807
  id: transform.Identifier(spec.local, false),
2554
2808
  typeAnnotation: {
2555
2809
  type: 'TSTypeQuery',
2810
+ loc: DUMMY_LOC,
2556
2811
  exprName: id,
2557
2812
  },
2558
2813
  });
@@ -2567,6 +2822,7 @@ const getTransforms = (
2567
2822
  case 'ImportDefaultSpecifier':
2568
2823
  specifiers.push({
2569
2824
  type: 'ImportDefaultSpecifier',
2825
+ loc: DUMMY_LOC,
2570
2826
  local: id,
2571
2827
  });
2572
2828
  return;
@@ -2574,6 +2830,7 @@ const getTransforms = (
2574
2830
  case 'ImportNamespaceSpecifier':
2575
2831
  specifiers.push({
2576
2832
  type: 'ImportNamespaceSpecifier',
2833
+ loc: DUMMY_LOC,
2577
2834
  local: id,
2578
2835
  });
2579
2836
  return;
@@ -2581,6 +2838,7 @@ const getTransforms = (
2581
2838
  case 'ImportSpecifier':
2582
2839
  specifiers.push({
2583
2840
  type: 'ImportSpecifier',
2841
+ loc: DUMMY_LOC,
2584
2842
  importKind:
2585
2843
  spec.importKind === 'typeof' || spec.importKind === 'type'
2586
2844
  ? 'type'
@@ -2592,10 +2850,11 @@ const getTransforms = (
2592
2850
  }
2593
2851
  });
2594
2852
 
2595
- const out = specifiers.length
2853
+ const out: Array<TSESTree.ImportDeclaration> = specifiers.length
2596
2854
  ? [
2597
2855
  {
2598
2856
  type: 'ImportDeclaration',
2857
+ loc: DUMMY_LOC,
2599
2858
  assertions: node.assertions.map(transform.ImportAttribute),
2600
2859
  importKind:
2601
2860
  importKind === 'typeof' ? 'type' : importKind ?? 'value',
@@ -2612,7 +2871,9 @@ const getTransforms = (
2612
2871
  ): TSESTree.TSInterfaceHeritage {
2613
2872
  return {
2614
2873
  type: 'TSInterfaceHeritage',
2615
- expression: transform.Identifier(node.id, false),
2874
+ loc: DUMMY_LOC,
2875
+ // Bug: node.id can be qualified
2876
+ expression: transform.Identifier((node.id: $FlowFixMe), false),
2616
2877
  typeParameters:
2617
2878
  node.typeParameters == null
2618
2879
  ? undefined
@@ -2628,10 +2889,13 @@ const getTransforms = (
2628
2889
  // type T = U & V & { ... }
2629
2890
  return {
2630
2891
  type: 'TSIntersectionType',
2892
+ loc: DUMMY_LOC,
2631
2893
  types: [
2632
2894
  ...node.extends.map(ex => ({
2633
2895
  type: 'TSTypeReference',
2634
- typeName: transform.Identifier(ex.id, false),
2896
+ loc: DUMMY_LOC,
2897
+ // Bug: ex.id can be qualified
2898
+ typeName: transform.Identifier((ex.id: $FlowFixMe), false),
2635
2899
  typeParameters:
2636
2900
  ex.typeParameters == null
2637
2901
  ? undefined
@@ -2649,6 +2913,7 @@ const getTransforms = (
2649
2913
  ): TSESTree.TSIntersectionType {
2650
2914
  return {
2651
2915
  type: 'TSIntersectionType',
2916
+ loc: DUMMY_LOC,
2652
2917
  types: node.types.map(transformTypeAnnotationType),
2653
2918
  };
2654
2919
  },
@@ -2673,11 +2938,13 @@ const getTransforms = (
2673
2938
  ): TSESTree.TSUnknownKeyword {
2674
2939
  return {
2675
2940
  type: 'TSUnknownKeyword',
2941
+ loc: DUMMY_LOC,
2676
2942
  };
2677
2943
  },
2678
2944
  NullLiteral(_node: FlowESTree.NullLiteral): TSESTree.NullLiteral {
2679
2945
  return {
2680
2946
  type: 'Literal',
2947
+ loc: DUMMY_LOC,
2681
2948
  raw: 'null',
2682
2949
  value: null,
2683
2950
  };
@@ -2687,6 +2954,7 @@ const getTransforms = (
2687
2954
  ): TSESTree.TSNullKeyword {
2688
2955
  return {
2689
2956
  type: 'TSNullKeyword',
2957
+ loc: DUMMY_LOC,
2690
2958
  };
2691
2959
  },
2692
2960
  NullableTypeAnnotation(
@@ -2696,12 +2964,15 @@ const getTransforms = (
2696
2964
  // `?T` becomes `null | undefined | T`
2697
2965
  return {
2698
2966
  type: 'TSUnionType',
2967
+ loc: DUMMY_LOC,
2699
2968
  types: [
2700
2969
  {
2701
2970
  type: 'TSNullKeyword',
2971
+ loc: DUMMY_LOC,
2702
2972
  },
2703
2973
  {
2704
2974
  type: 'TSUndefinedKeyword',
2975
+ loc: DUMMY_LOC,
2705
2976
  },
2706
2977
  transformTypeAnnotationType(node.typeAnnotation),
2707
2978
  ],
@@ -2712,8 +2983,10 @@ const getTransforms = (
2712
2983
  ): TSESTree.TSLiteralType {
2713
2984
  return {
2714
2985
  type: 'TSLiteralType',
2986
+ loc: DUMMY_LOC,
2715
2987
  literal: ({
2716
2988
  type: 'Literal',
2989
+ loc: DUMMY_LOC,
2717
2990
  value: node.value,
2718
2991
  raw: node.raw,
2719
2992
  }: TSESTree.NumberLiteral),
@@ -2724,11 +2997,13 @@ const getTransforms = (
2724
2997
  ): TSESTree.TSNumberKeyword {
2725
2998
  return {
2726
2999
  type: 'TSNumberKeyword',
3000
+ loc: DUMMY_LOC,
2727
3001
  };
2728
3002
  },
2729
3003
  NumericLiteral(node: FlowESTree.NumericLiteral): TSESTree.NumberLiteral {
2730
3004
  return {
2731
3005
  type: 'Literal',
3006
+ loc: DUMMY_LOC,
2732
3007
  raw: node.raw,
2733
3008
  value: node.value,
2734
3009
  };
@@ -2749,10 +3024,13 @@ const getTransforms = (
2749
3024
  node.properties[0];
2750
3025
  const tsProp: TSESTree.TSMappedType = {
2751
3026
  type: 'TSMappedType',
3027
+ loc: DUMMY_LOC,
2752
3028
  typeParameter: {
2753
3029
  type: 'TSTypeParameter',
3030
+ loc: DUMMY_LOC,
2754
3031
  name: {
2755
3032
  type: 'Identifier',
3033
+ loc: DUMMY_LOC,
2756
3034
  name: prop.keyTparam.name,
2757
3035
  },
2758
3036
  constraint: transformTypeAnnotationType(prop.sourceType),
@@ -2824,6 +3102,7 @@ const getTransforms = (
2824
3102
 
2825
3103
  return {
2826
3104
  type: 'TSTypeLiteral',
3105
+ loc: DUMMY_LOC,
2827
3106
  members: tsBody,
2828
3107
  };
2829
3108
  } else {
@@ -2942,6 +3221,7 @@ const getTransforms = (
2942
3221
  .map(({node}) => node);
2943
3222
  const objectType = {
2944
3223
  type: 'TSTypeLiteral',
3224
+ loc: DUMMY_LOC,
2945
3225
  members: tsBody,
2946
3226
  };
2947
3227
 
@@ -2951,19 +3231,24 @@ const getTransforms = (
2951
3231
  const remainingTypes = typesToIntersect.slice(i + 1);
2952
3232
  intersectionMembers.push({
2953
3233
  type: 'TSTypeReference',
3234
+ loc: DUMMY_LOC,
2954
3235
  typeName: {
2955
3236
  type: 'Identifier',
3237
+ loc: DUMMY_LOC,
2956
3238
  name: 'Omit',
2957
3239
  },
2958
3240
  typeParameters: {
2959
3241
  type: 'TSTypeParameterInstantiation',
3242
+ loc: DUMMY_LOC,
2960
3243
  params: [
2961
3244
  currentType,
2962
3245
  {
2963
3246
  type: 'TSTypeOperator',
3247
+ loc: DUMMY_LOC,
2964
3248
  operator: 'keyof',
2965
3249
  typeAnnotation: {
2966
3250
  type: 'TSUnionType',
3251
+ loc: DUMMY_LOC,
2967
3252
  types: [...remainingTypes, objectType],
2968
3253
  },
2969
3254
  },
@@ -2975,6 +3260,7 @@ const getTransforms = (
2975
3260
 
2976
3261
  return {
2977
3262
  type: 'TSIntersectionType',
3263
+ loc: DUMMY_LOC,
2978
3264
  types: intersectionMembers,
2979
3265
  };
2980
3266
  }
@@ -2986,6 +3272,7 @@ const getTransforms = (
2986
3272
  const func = transform.FunctionTypeAnnotation(node.value);
2987
3273
  return {
2988
3274
  type: 'TSCallSignatureDeclaration',
3275
+ loc: DUMMY_LOC,
2989
3276
  params: func.params,
2990
3277
  returnType: func.returnType,
2991
3278
  typeParameters: func.typeParameters,
@@ -2996,12 +3283,15 @@ const getTransforms = (
2996
3283
  ): TSESTree.TSIndexSignature {
2997
3284
  return {
2998
3285
  type: 'TSIndexSignature',
3286
+ loc: DUMMY_LOC,
2999
3287
  parameters: [
3000
3288
  {
3001
3289
  type: 'Identifier',
3290
+ loc: DUMMY_LOC,
3002
3291
  name: node.id == null ? '$$Key$$' : node.id.name,
3003
3292
  typeAnnotation: {
3004
3293
  type: 'TSTypeAnnotation',
3294
+ loc: DUMMY_LOC,
3005
3295
  typeAnnotation: transformTypeAnnotationType(node.key),
3006
3296
  },
3007
3297
  },
@@ -3010,6 +3300,7 @@ const getTransforms = (
3010
3300
  static: node.static,
3011
3301
  typeAnnotation: {
3012
3302
  type: 'TSTypeAnnotation',
3303
+ loc: DUMMY_LOC,
3013
3304
  typeAnnotation: transformTypeAnnotationType(node.value),
3014
3305
  },
3015
3306
  };
@@ -3028,6 +3319,7 @@ const getTransforms = (
3028
3319
  const func = transform.FunctionTypeAnnotation(node.value);
3029
3320
  return {
3030
3321
  type: 'TSMethodSignature',
3322
+ loc: DUMMY_LOC,
3031
3323
  computed: false,
3032
3324
  key,
3033
3325
  kind: node.kind === 'init' ? 'method' : node.kind,
@@ -3045,6 +3337,7 @@ const getTransforms = (
3045
3337
  const func = transform.FunctionTypeAnnotation(node.value);
3046
3338
  return {
3047
3339
  type: 'TSMethodSignature',
3340
+ loc: DUMMY_LOC,
3048
3341
  computed: false,
3049
3342
  key,
3050
3343
  kind: node.kind,
@@ -3060,6 +3353,7 @@ const getTransforms = (
3060
3353
 
3061
3354
  return {
3062
3355
  type: 'TSPropertySignature',
3356
+ loc: DUMMY_LOC,
3063
3357
  computed: false,
3064
3358
  key,
3065
3359
  optional: node.optional,
@@ -3067,6 +3361,7 @@ const getTransforms = (
3067
3361
  static: node.static,
3068
3362
  typeAnnotation: {
3069
3363
  type: 'TSTypeAnnotation',
3364
+ loc: DUMMY_LOC,
3070
3365
  typeAnnotation: transformTypeAnnotationType(node.value),
3071
3366
  },
3072
3367
  };
@@ -3088,14 +3383,18 @@ const getTransforms = (
3088
3383
  // `T?.[K]` becomes `NonNullable<T>[K]`
3089
3384
  return {
3090
3385
  type: 'TSIndexedAccessType',
3386
+ loc: DUMMY_LOC,
3091
3387
  objectType: {
3092
3388
  type: 'TSTypeReference',
3389
+ loc: DUMMY_LOC,
3093
3390
  typeName: {
3094
3391
  type: 'Identifier',
3392
+ loc: DUMMY_LOC,
3095
3393
  name: 'NonNullable',
3096
3394
  },
3097
3395
  typeParameters: {
3098
3396
  type: 'TSTypeParameterInstantiation',
3397
+ loc: DUMMY_LOC,
3099
3398
  params: [transformTypeAnnotationType(node.objectType)],
3100
3399
  },
3101
3400
  },
@@ -3109,6 +3408,7 @@ const getTransforms = (
3109
3408
 
3110
3409
  return {
3111
3410
  type: 'TSQualifiedName',
3411
+ loc: DUMMY_LOC,
3112
3412
  left:
3113
3413
  qual.type === 'Identifier'
3114
3414
  ? transform.Identifier(qual, false)
@@ -3123,6 +3423,7 @@ const getTransforms = (
3123
3423
 
3124
3424
  return {
3125
3425
  type: 'TSQualifiedName',
3426
+ loc: DUMMY_LOC,
3126
3427
  left:
3127
3428
  qual.type === 'Identifier'
3128
3429
  ? transform.Identifier(qual, false)
@@ -3133,6 +3434,7 @@ const getTransforms = (
3133
3434
  RegExpLiteral(node: FlowESTree.RegExpLiteral): TSESTree.RegExpLiteral {
3134
3435
  return {
3135
3436
  type: 'Literal',
3437
+ loc: DUMMY_LOC,
3136
3438
  raw: node.raw,
3137
3439
  regex: {
3138
3440
  pattern: node.regex.pattern,
@@ -3144,6 +3446,7 @@ const getTransforms = (
3144
3446
  StringLiteral(node: FlowESTree.StringLiteral): TSESTree.StringLiteral {
3145
3447
  return {
3146
3448
  type: 'Literal',
3449
+ loc: DUMMY_LOC,
3147
3450
  raw: node.raw,
3148
3451
  value: node.value,
3149
3452
  };
@@ -3153,8 +3456,10 @@ const getTransforms = (
3153
3456
  ): TSESTree.TSLiteralType {
3154
3457
  return {
3155
3458
  type: 'TSLiteralType',
3459
+ loc: DUMMY_LOC,
3156
3460
  literal: ({
3157
3461
  type: 'Literal',
3462
+ loc: DUMMY_LOC,
3158
3463
  value: node.value,
3159
3464
  raw: node.raw,
3160
3465
  }: TSESTree.StringLiteral),
@@ -3165,6 +3470,7 @@ const getTransforms = (
3165
3470
  ): TSESTree.TSStringKeyword {
3166
3471
  return {
3167
3472
  type: 'TSStringKeyword',
3473
+ loc: DUMMY_LOC,
3168
3474
  };
3169
3475
  },
3170
3476
  SymbolTypeAnnotation(
@@ -3172,6 +3478,7 @@ const getTransforms = (
3172
3478
  ): TSESTree.TSSymbolKeyword {
3173
3479
  return {
3174
3480
  type: 'TSSymbolKeyword',
3481
+ loc: DUMMY_LOC,
3175
3482
  };
3176
3483
  },
3177
3484
  ThisTypeAnnotation(
@@ -3179,6 +3486,7 @@ const getTransforms = (
3179
3486
  ): TSESTree.TSThisType {
3180
3487
  return {
3181
3488
  type: 'TSThisType',
3489
+ loc: DUMMY_LOC,
3182
3490
  };
3183
3491
  },
3184
3492
  TupleTypeAnnotation(
@@ -3192,8 +3500,9 @@ const getTransforms = (
3192
3500
  element.variance != null &&
3193
3501
  element.variance.kind === 'plus',
3194
3502
  );
3195
- const tupleAnnot = {
3503
+ const tupleAnnot: TSESTree.TSTupleType = {
3196
3504
  type: 'TSTupleType',
3505
+ loc: DUMMY_LOC,
3197
3506
  elementTypes: node.types.map(element => {
3198
3507
  switch (element.type) {
3199
3508
  case 'TupleTypeLabeledElement':
@@ -3205,6 +3514,7 @@ const getTransforms = (
3205
3514
  }
3206
3515
  return {
3207
3516
  type: 'TSNamedTupleMember',
3517
+ loc: DUMMY_LOC,
3208
3518
  label: transform.Identifier(element.label),
3209
3519
  optional: element.optional,
3210
3520
  elementType: transformTypeAnnotationType(element.elementType),
@@ -3213,10 +3523,12 @@ const getTransforms = (
3213
3523
  const annot = transformTypeAnnotationType(element.typeAnnotation);
3214
3524
  return {
3215
3525
  type: 'TSRestType',
3526
+ loc: DUMMY_LOC,
3216
3527
  typeAnnotation:
3217
3528
  element.label != null
3218
3529
  ? {
3219
3530
  type: 'TSNamedTupleMember',
3531
+ loc: DUMMY_LOC,
3220
3532
  label: transform.Identifier(element.label),
3221
3533
  optional: false,
3222
3534
  elementType: annot,
@@ -3232,6 +3544,7 @@ const getTransforms = (
3232
3544
  return allReadOnly
3233
3545
  ? {
3234
3546
  type: 'TSTypeOperator',
3547
+ loc: DUMMY_LOC,
3235
3548
  operator: 'readonly',
3236
3549
  typeAnnotation: tupleAnnot,
3237
3550
  }
@@ -3243,6 +3556,7 @@ const getTransforms = (
3243
3556
  TypeAnnotation(node: FlowESTree.TypeAnnotation): TSESTree.TSTypeAnnotation {
3244
3557
  return {
3245
3558
  type: 'TSTypeAnnotation',
3559
+ loc: DUMMY_LOC,
3246
3560
  typeAnnotation: transformTypeAnnotationType(node.typeAnnotation),
3247
3561
  };
3248
3562
  },
@@ -3253,12 +3567,14 @@ const getTransforms = (
3253
3567
  case 'Identifier':
3254
3568
  return {
3255
3569
  type: 'TSTypeQuery',
3570
+ loc: DUMMY_LOC,
3256
3571
  exprName: transform.Identifier(node.argument),
3257
3572
  typeParameters: undefined,
3258
3573
  };
3259
3574
  case 'QualifiedTypeofIdentifier':
3260
3575
  return {
3261
3576
  type: 'TSTypeQuery',
3577
+ loc: DUMMY_LOC,
3262
3578
  exprName: transform.QualifiedTypeofIdentifier(node.argument),
3263
3579
  typeParameters: undefined,
3264
3580
  };
@@ -3288,8 +3604,10 @@ const getTransforms = (
3288
3604
  */
3289
3605
  return {
3290
3606
  type: 'TSTypeParameter',
3607
+ loc: DUMMY_LOC,
3291
3608
  name: {
3292
3609
  type: 'Identifier',
3610
+ loc: DUMMY_LOC,
3293
3611
  name: node.name,
3294
3612
  },
3295
3613
  constraint:
@@ -3311,6 +3629,7 @@ const getTransforms = (
3311
3629
  ): TSESTree.TSTypeParameterDeclaration {
3312
3630
  return {
3313
3631
  type: 'TSTypeParameterDeclaration',
3632
+ loc: DUMMY_LOC,
3314
3633
  params: node.params.map(transform.TypeParameter),
3315
3634
  };
3316
3635
  },
@@ -3319,6 +3638,7 @@ const getTransforms = (
3319
3638
  ): TSESTree.TSTypeParameterInstantiation {
3320
3639
  return {
3321
3640
  type: 'TSTypeParameterInstantiation',
3641
+ loc: DUMMY_LOC,
3322
3642
  params: node.params.map(transformTypeAnnotationType),
3323
3643
  };
3324
3644
  },
@@ -3327,6 +3647,7 @@ const getTransforms = (
3327
3647
  ): TSESTree.TSUnionType {
3328
3648
  return {
3329
3649
  type: 'TSUnionType',
3650
+ loc: DUMMY_LOC,
3330
3651
  types: node.types.map(transformTypeAnnotationType),
3331
3652
  };
3332
3653
  },
@@ -3335,6 +3656,7 @@ const getTransforms = (
3335
3656
  ): TSESTree.TSVoidKeyword {
3336
3657
  return {
3337
3658
  type: 'TSVoidKeyword',
3659
+ loc: DUMMY_LOC,
3338
3660
  };
3339
3661
  },
3340
3662
  ConditionalTypeAnnotation(
@@ -3342,6 +3664,7 @@ const getTransforms = (
3342
3664
  ): TSESTree.TSConditionalType {
3343
3665
  return {
3344
3666
  type: 'TSConditionalType',
3667
+ loc: DUMMY_LOC,
3345
3668
  checkType: transformTypeAnnotationType(node.checkType),
3346
3669
  extendsType: transformTypeAnnotationType(node.extendsType),
3347
3670
  trueType: transformTypeAnnotationType(node.trueType),
@@ -3353,10 +3676,12 @@ const getTransforms = (
3353
3676
  ): TSESTree.TSTypePredicate {
3354
3677
  return {
3355
3678
  type: 'TSTypePredicate',
3356
- asserts: node.asserts,
3679
+ loc: DUMMY_LOC,
3680
+ asserts: node.kind != null && node.kind === 'asserts',
3357
3681
  parameterName: transform.Identifier(node.parameterName, false),
3358
3682
  typeAnnotation: node.typeAnnotation && {
3359
3683
  type: 'TSTypeAnnotation',
3684
+ loc: DUMMY_LOC,
3360
3685
  typeAnnotation: transformTypeAnnotationType(node.typeAnnotation),
3361
3686
  },
3362
3687
  };
@@ -3366,6 +3691,7 @@ const getTransforms = (
3366
3691
  ): TSESTree.TSInferType {
3367
3692
  return {
3368
3693
  type: 'TSInferType',
3694
+ loc: DUMMY_LOC,
3369
3695
  typeParameter: transform.TypeParameter(node.typeParameter),
3370
3696
  };
3371
3697
  },
@@ -3374,6 +3700,7 @@ const getTransforms = (
3374
3700
  ): TSESTree.TSTypeOperator {
3375
3701
  return {
3376
3702
  type: 'TSTypeOperator',
3703
+ loc: DUMMY_LOC,
3377
3704
  operator: 'keyof',
3378
3705
  typeAnnotation: transformTypeAnnotationType(node.argument),
3379
3706
  };
@@ -3386,11 +3713,14 @@ const getTransforms = (
3386
3713
  const hasReactImport = isReactImport(node, 'React');
3387
3714
  return {
3388
3715
  type: 'TSTypeReference',
3716
+ loc: DUMMY_LOC,
3389
3717
  typeName: {
3390
3718
  type: 'TSQualifiedName',
3719
+ loc: DUMMY_LOC,
3391
3720
  left: getReactIdentifier(hasReactImport),
3392
3721
  right: {
3393
3722
  type: 'Identifier',
3723
+ loc: DUMMY_LOC,
3394
3724
  name: `ReactNode`,
3395
3725
  },
3396
3726
  },
@@ -3413,14 +3743,18 @@ const getTransforms = (
3413
3743
  const hasReactImport = isReactImport(node, 'React');
3414
3744
  const returnType = {
3415
3745
  type: 'TSTypeAnnotation',
3746
+ loc: DUMMY_LOC,
3416
3747
  // If no rendersType we assume its ReactNode type.
3417
3748
  typeAnnotation: {
3418
3749
  type: 'TSTypeReference',
3750
+ loc: DUMMY_LOC,
3419
3751
  typeName: {
3420
3752
  type: 'TSQualifiedName',
3753
+ loc: DUMMY_LOC,
3421
3754
  left: getReactIdentifier(hasReactImport),
3422
3755
  right: {
3423
3756
  type: 'Identifier',
3757
+ loc: DUMMY_LOC,
3424
3758
  name: `ReactNode`,
3425
3759
  },
3426
3760
  },
@@ -3430,6 +3764,7 @@ const getTransforms = (
3430
3764
 
3431
3765
  return {
3432
3766
  type: 'TSFunctionType',
3767
+ loc: DUMMY_LOC,
3433
3768
  typeParameters,
3434
3769
  params,
3435
3770
  returnType,