flow-api-translator 0.31.2 → 0.32.1

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.
@@ -43,7 +43,7 @@ function constructFlowNode(node) {
43
43
  };
44
44
  }
45
45
 
46
- const makeCommentOwnLine = // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
46
+ const makeCommentOwnLine = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
47
47
  _hermesTransform.makeCommentOwnLine;
48
48
 
49
49
  function TSDefToFlowDef(originalCode, ast, opts) {
@@ -107,7 +107,7 @@ const getTransforms = (originalCode, opts) => {
107
107
  code = makeCommentOwnLine(code, comment); // $FlowExpectedError[prop-missing]
108
108
  // $FlowExpectedError[cannot-write]
109
109
 
110
- (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-cast]
110
+ (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-type]
111
111
 
112
112
  node.comments.push(comment);
113
113
  }
@@ -183,14 +183,14 @@ const getTransforms = (originalCode, opts) => {
183
183
 
184
184
  case 'TSAbstractPropertyDefinition':
185
185
  case 'PropertyDefinition':
186
- // $FlowFixMe[incompatible-call] ambiguous node
186
+ // $FlowFixMe[incompatible-type] ambiguous node
187
187
  Transform._translateIntoObjectProp(classItem, properties, indexers);
188
188
 
189
189
  break;
190
190
 
191
191
  case 'MethodDefinition':
192
192
  case 'TSAbstractMethodDefinition':
193
- // $FlowFixMe[incompatible-call] ambiguous node
193
+ // $FlowFixMe[incompatible-type] ambiguous node
194
194
  Transform._translateIntoObjectMethod(classItem, properties);
195
195
 
196
196
  break;
@@ -975,7 +975,7 @@ const getTransforms = (originalCode, opts) => {
975
975
  objectType: base,
976
976
  indexType: constructFlowNode({
977
977
  type: 'StringLiteralTypeAnnotation',
978
- // $FlowFixMe[incompatible-call]
978
+ // $FlowFixMe[incompatible-type]
979
979
  value: name,
980
980
  // $FlowFixMe[incompatible-type]
981
981
  raw: `'${name}'`
@@ -46,7 +46,7 @@ function constructFlowNode<T: FlowESTree.BaseNode>(
46
46
  }
47
47
 
48
48
  const makeCommentOwnLine =
49
- // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
49
+ // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
50
50
  (makeCommentOwnLineOriginal: (string, mixed) => string);
51
51
 
52
52
  export function TSDefToFlowDef(
@@ -112,7 +112,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
112
112
  // $FlowExpectedError[prop-missing]
113
113
  // $FlowExpectedError[cannot-write]
114
114
  node.comments ??= [];
115
- // $FlowExpectedError[incompatible-cast]
115
+ // $FlowExpectedError[incompatible-type]
116
116
  (node.comments: Array<TSESTree.Comment>).push(comment);
117
117
  }
118
118
  function unsupportedAnnotation(
@@ -202,12 +202,12 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
202
202
  break;
203
203
  case 'TSAbstractPropertyDefinition':
204
204
  case 'PropertyDefinition':
205
- // $FlowFixMe[incompatible-call] ambiguous node
205
+ // $FlowFixMe[incompatible-type] ambiguous node
206
206
  Transform._translateIntoObjectProp(classItem, properties, indexers);
207
207
  break;
208
208
  case 'MethodDefinition':
209
209
  case 'TSAbstractMethodDefinition':
210
- // $FlowFixMe[incompatible-call] ambiguous node
210
+ // $FlowFixMe[incompatible-type] ambiguous node
211
211
  Transform._translateIntoObjectMethod(classItem, properties);
212
212
  break;
213
213
  }
@@ -1062,7 +1062,7 @@ const getTransforms = (originalCode: string, opts: TranslationOptions) => {
1062
1062
  objectType: base,
1063
1063
  indexType: constructFlowNode<FlowESTree.StringLiteralTypeAnnotation>({
1064
1064
  type: 'StringLiteralTypeAnnotation',
1065
- // $FlowFixMe[incompatible-call]
1065
+ // $FlowFixMe[incompatible-type]
1066
1066
  value: name,
1067
1067
  // $FlowFixMe[incompatible-type]
1068
1068
  raw: `'${name}'`,
@@ -45,9 +45,9 @@ function constructFlowNode(node) {
45
45
  return node;
46
46
  }
47
47
 
48
- const cloneJSDocCommentsToNewNode = // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
48
+ const cloneJSDocCommentsToNewNode = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
49
49
  _hermesTransform.cloneJSDocCommentsToNewNode;
50
- const makeCommentOwnLine = // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
50
+ const makeCommentOwnLine = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
51
51
  _hermesTransform.makeCommentOwnLine;
52
52
  const VALID_REACT_IMPORTS = new Set(['React', 'react']);
53
53
 
@@ -86,8 +86,6 @@ function flowDefToTSDef(originalCode, ast, scopeManager, opts) {
86
86
  if (node.type in transform) {
87
87
  const result = transform[// $FlowExpectedError[prop-missing]
88
88
  node.type]( // $FlowExpectedError[incompatible-type]
89
- // $FlowExpectedError[prop-missing]
90
- // $FlowFixMe[incompatible-call]
91
89
  node);
92
90
  tsBody.push(...(Array.isArray(result) ? result : [result]));
93
91
  } else {
@@ -160,7 +158,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
160
158
  code = makeCommentOwnLine(code, comment); // $FlowExpectedError[prop-missing]
161
159
  // $FlowExpectedError[cannot-write]
162
160
 
163
- (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-cast]
161
+ (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-type]
164
162
 
165
163
  node.comments.push(comment);
166
164
  }
@@ -46,11 +46,11 @@ function constructFlowNode<T: FlowESTree.BaseNode>(
46
46
  }
47
47
 
48
48
  const cloneJSDocCommentsToNewNode =
49
- // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
49
+ // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
50
50
  (cloneJSDocCommentsToNewNodeOriginal: (mixed, mixed) => void);
51
51
 
52
52
  const makeCommentOwnLine =
53
- // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
53
+ // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
54
54
  (makeCommentOwnLineOriginal: (string, mixed) => string);
55
55
 
56
56
  const VALID_REACT_IMPORTS = new Set<string>(['React', 'react']);
@@ -102,8 +102,6 @@ export function flowDefToTSDef(
102
102
  node.type
103
103
  ](
104
104
  // $FlowExpectedError[incompatible-type]
105
- // $FlowExpectedError[prop-missing]
106
- // $FlowFixMe[incompatible-call]
107
105
  node,
108
106
  );
109
107
  tsBody.push(...(Array.isArray(result) ? result : [result]));
@@ -180,7 +178,7 @@ const getTransforms = (
180
178
  // $FlowExpectedError[prop-missing]
181
179
  // $FlowExpectedError[cannot-write]
182
180
  node.comments ??= [];
183
- // $FlowExpectedError[incompatible-cast]
181
+ // $FlowExpectedError[incompatible-type]
184
182
  (node.comments: Array<TSESTree.Comment>).push(comment);
185
183
  }
186
184
  function unsupportedAnnotation(
@@ -49,7 +49,7 @@ function getTopLevelStatement(node, context) {
49
49
  var _currentNode$parent;
50
50
 
51
51
  if (((_currentNode$parent = currentNode.parent) == null ? void 0 : _currentNode$parent.type) === 'Program') {
52
- // $FlowFixMe[incompatible-return]
52
+ // $FlowFixMe[incompatible-type]
53
53
  return currentNode;
54
54
  }
55
55
 
@@ -425,7 +425,7 @@ function convertObjectExpression(expr, context) {
425
425
 
426
426
  const [resultExpr, deps] = convertAFunction(prop.value, context);
427
427
  return [inheritComments(prop, _hermesTransform.t.ObjectTypeMethodSignature({
428
- // $FlowFixMe[incompatible-call]
428
+ // $FlowFixMe[incompatible-type]
429
429
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
430
430
  value: resultExpr
431
431
  })), deps];
@@ -439,7 +439,7 @@ function convertObjectExpression(expr, context) {
439
439
  const kind = prop.kind;
440
440
  const [resultExpr, deps] = convertAFunction(prop.value, context);
441
441
  return [inheritComments(prop, _hermesTransform.t.ObjectTypeAccessorSignature({
442
- // $FlowFixMe[incompatible-call]
442
+ // $FlowFixMe[incompatible-type]
443
443
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
444
444
  kind,
445
445
  value: resultExpr
@@ -448,7 +448,7 @@ function convertObjectExpression(expr, context) {
448
448
 
449
449
  const [resultExpr, deps] = convertExpressionToTypeAnnotation(prop.value, context);
450
450
  return [inheritComments(prop, _hermesTransform.t.ObjectTypePropertySignature({
451
- // $FlowFixMe[incompatible-call]
451
+ // $FlowFixMe[incompatible-type]
452
452
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
453
453
  value: resultExpr,
454
454
  optional: false,
@@ -754,7 +754,7 @@ function convertClassDeclaration(class_, context) {
754
754
  }
755
755
 
756
756
  return [_hermesTransform.t.DeclareClass({
757
- // $FlowFixMe[incompatible-call]
757
+ // $FlowFixMe[incompatible-type]
758
758
  id: (0, _hermesTransform.asDetachedNode)(class_.id),
759
759
  typeParameters: resultTypeParams,
760
760
  implements: class_.implements.map(impl => (0, _hermesTransform.asDetachedNode)(impl)),
@@ -827,7 +827,7 @@ function convertSuperClassHelper(detachedId, nodeForDependencies, superTypeParam
827
827
 
828
828
  function convertSuperClass(superClass, superTypeParameters, context) {
829
829
  if (superClass == null) {
830
- // $FlowFixMe[incompatible-return]
830
+ // $FlowFixMe[incompatible-type]
831
831
  return EMPTY_TRANSLATION_RESULT;
832
832
  }
833
833
 
@@ -889,7 +889,7 @@ function convertClassMember(member, context) {
889
889
 
890
890
  // PrivateIdentifier's are not exposed so can be stripped.
891
891
  if (member.key.type === 'PrivateIdentifier') {
892
- // $FlowFixMe[incompatible-return]
892
+ // $FlowFixMe[incompatible-type]
893
893
  return EMPTY_TRANSLATION_RESULT;
894
894
  }
895
895
 
@@ -900,7 +900,7 @@ function convertClassMember(member, context) {
900
900
  if (((_member$value = member.value) == null ? void 0 : _member$value.type) === 'ArrowFunctionExpression' && member.typeAnnotation == null) {
901
901
  const [resultTypeAnnotation, deps] = convertAFunction(member.value, context);
902
902
  return [inheritComments(member, _hermesTransform.t.ObjectTypePropertySignature({
903
- // $FlowFixMe[incompatible-call]
903
+ // $FlowFixMe[incompatible-type]
904
904
  key: (0, _hermesTransform.asDetachedNode)(member.key),
905
905
  value: resultTypeAnnotation,
906
906
  optional: member.optional,
@@ -911,7 +911,7 @@ function convertClassMember(member, context) {
911
911
 
912
912
  const [resultTypeAnnotation, deps] = convertTypeAnnotation(member.typeAnnotation, member, context);
913
913
  return [inheritComments(member, _hermesTransform.t.ObjectTypePropertySignature({
914
- // $FlowFixMe[incompatible-call]
914
+ // $FlowFixMe[incompatible-type]
915
915
  key: (0, _hermesTransform.asDetachedNode)(member.key),
916
916
  value: resultTypeAnnotation,
917
917
  optional: member.optional,
@@ -924,7 +924,7 @@ function convertClassMember(member, context) {
924
924
  {
925
925
  // PrivateIdentifier's are not exposed so can be stripped.
926
926
  if (member.key.type === 'PrivateIdentifier') {
927
- // $FlowFixMe[incompatible-return]
927
+ // $FlowFixMe[incompatible-type]
928
928
  return EMPTY_TRANSLATION_RESULT;
929
929
  }
930
930
 
@@ -941,7 +941,7 @@ function convertClassMember(member, context) {
941
941
  // accessors are methods - but flow accessor signatures are properties
942
942
  const kind = member.kind;
943
943
  return [inheritComments(member, _hermesTransform.t.ObjectTypeAccessorSignature({
944
- // $FlowFixMe[incompatible-call]
944
+ // $FlowFixMe[incompatible-type]
945
945
  key: (0, _hermesTransform.asDetachedNode)(newKey),
946
946
  value: resultValue,
947
947
  static: member.static,
@@ -950,7 +950,7 @@ function convertClassMember(member, context) {
950
950
  }
951
951
 
952
952
  return [inheritComments(member, _hermesTransform.t.ObjectTypeMethodSignature({
953
- // $FlowFixMe[incompatible-call]
953
+ // $FlowFixMe[incompatible-type]
954
954
  key: (0, _hermesTransform.asDetachedNode)(newKey),
955
955
  value: resultValue,
956
956
  static: member.static
@@ -1138,7 +1138,7 @@ function convertFunctionParameters(params, context) {
1138
1138
  throw (0, _ErrorUtils.translationError)(param, `FunctionParameter: Multiple rest elements found`, context);
1139
1139
  }
1140
1140
 
1141
- const [resultParam, deps] = convertBindingNameToFunctionTypeParam( // $FlowFixMe[incompatible-call] I dont think these other cases are possible
1141
+ const [resultParam, deps] = convertBindingNameToFunctionTypeParam( // $FlowFixMe[incompatible-type] I dont think these other cases are possible
1142
1142
  param.argument, context, index, false);
1143
1143
  return [resultParams, resultParam, [...paramsDeps, ...deps]];
1144
1144
  }
@@ -1200,7 +1200,7 @@ function convertTypeAnnotationType(annot, container, context) {
1200
1200
 
1201
1201
  function convertTypeAnnotationTypeOrNull(annot, context) {
1202
1202
  if (annot == null) {
1203
- // $FlowFixMe[incompatible-return]
1203
+ // $FlowFixMe[incompatible-type]
1204
1204
  return EMPTY_TRANSLATION_RESULT;
1205
1205
  }
1206
1206
 
@@ -1209,7 +1209,7 @@ function convertTypeAnnotationTypeOrNull(annot, context) {
1209
1209
 
1210
1210
  function convertTypeParameterDeclarationOrNull(decl, context) {
1211
1211
  if (decl == null) {
1212
- // $FlowFixMe[incompatible-return]
1212
+ // $FlowFixMe[incompatible-type]
1213
1213
  return EMPTY_TRANSLATION_RESULT;
1214
1214
  }
1215
1215
 
@@ -1218,7 +1218,7 @@ function convertTypeParameterDeclarationOrNull(decl, context) {
1218
1218
 
1219
1219
  function convertTypeParameterInstantiationOrNull(inst, context) {
1220
1220
  if (inst == null) {
1221
- // $FlowFixMe[incompatible-return]
1221
+ // $FlowFixMe[incompatible-type]
1222
1222
  return EMPTY_TRANSLATION_RESULT;
1223
1223
  }
1224
1224
 
@@ -124,7 +124,7 @@ function getTopLevelStatement(
124
124
  let currentNode: ?ESNode = node;
125
125
  while (currentNode != null) {
126
126
  if (currentNode.parent?.type === 'Program') {
127
- // $FlowFixMe[incompatible-return]
127
+ // $FlowFixMe[incompatible-type]
128
128
  return currentNode;
129
129
  }
130
130
  currentNode = currentNode.parent;
@@ -535,7 +535,7 @@ function convertObjectExpression(
535
535
  inheritComments(
536
536
  prop,
537
537
  t.ObjectTypeMethodSignature({
538
- // $FlowFixMe[incompatible-call]
538
+ // $FlowFixMe[incompatible-type]
539
539
  key: asDetachedNode<
540
540
  Identifier | NumericLiteral | StringLiteral | Expression,
541
541
  >(prop.key),
@@ -564,7 +564,7 @@ function convertObjectExpression(
564
564
  inheritComments(
565
565
  prop,
566
566
  t.ObjectTypeAccessorSignature({
567
- // $FlowFixMe[incompatible-call]
567
+ // $FlowFixMe[incompatible-type]
568
568
  key: asDetachedNode<
569
569
  Identifier | NumericLiteral | StringLiteral | Expression,
570
570
  >(prop.key),
@@ -585,7 +585,7 @@ function convertObjectExpression(
585
585
  inheritComments(
586
586
  prop,
587
587
  t.ObjectTypePropertySignature({
588
- // $FlowFixMe[incompatible-call]
588
+ // $FlowFixMe[incompatible-type]
589
589
  key: asDetachedNode<
590
590
  Identifier | NumericLiteral | StringLiteral | Expression,
591
591
  >(prop.key),
@@ -994,7 +994,7 @@ function convertClassDeclaration(
994
994
  }
995
995
  return [
996
996
  t.DeclareClass({
997
- // $FlowFixMe[incompatible-call]
997
+ // $FlowFixMe[incompatible-type]
998
998
  id: asDetachedNode<Identifier | null>(class_.id),
999
999
  typeParameters: resultTypeParams,
1000
1000
  implements: class_.implements.map(impl => asDetachedNode(impl)),
@@ -1080,7 +1080,7 @@ function convertSuperClass(
1080
1080
  context: TranslationContext,
1081
1081
  ): TranslatedResultOrNull<InterfaceExtends> {
1082
1082
  if (superClass == null) {
1083
- // $FlowFixMe[incompatible-return]
1083
+ // $FlowFixMe[incompatible-type]
1084
1084
  return EMPTY_TRANSLATION_RESULT;
1085
1085
  }
1086
1086
 
@@ -1175,7 +1175,7 @@ function convertClassMember(
1175
1175
  case 'PropertyDefinition': {
1176
1176
  // PrivateIdentifier's are not exposed so can be stripped.
1177
1177
  if (member.key.type === 'PrivateIdentifier') {
1178
- // $FlowFixMe[incompatible-return]
1178
+ // $FlowFixMe[incompatible-type]
1179
1179
  return EMPTY_TRANSLATION_RESULT;
1180
1180
  }
1181
1181
  if (
@@ -1203,7 +1203,7 @@ function convertClassMember(
1203
1203
  inheritComments(
1204
1204
  member,
1205
1205
  t.ObjectTypePropertySignature({
1206
- // $FlowFixMe[incompatible-call]
1206
+ // $FlowFixMe[incompatible-type]
1207
1207
  key: asDetachedNode<
1208
1208
  ClassPropertyNameComputed | ClassPropertyNameNonComputed,
1209
1209
  >(member.key),
@@ -1227,7 +1227,7 @@ function convertClassMember(
1227
1227
  inheritComments(
1228
1228
  member,
1229
1229
  t.ObjectTypePropertySignature({
1230
- // $FlowFixMe[incompatible-call]
1230
+ // $FlowFixMe[incompatible-type]
1231
1231
  key: asDetachedNode<
1232
1232
  ClassPropertyNameComputed | ClassPropertyNameNonComputed,
1233
1233
  >(member.key),
@@ -1243,7 +1243,7 @@ function convertClassMember(
1243
1243
  case 'MethodDefinition': {
1244
1244
  // PrivateIdentifier's are not exposed so can be stripped.
1245
1245
  if (member.key.type === 'PrivateIdentifier') {
1246
- // $FlowFixMe[incompatible-return]
1246
+ // $FlowFixMe[incompatible-type]
1247
1247
  return EMPTY_TRANSLATION_RESULT;
1248
1248
  }
1249
1249
  if (
@@ -1281,7 +1281,7 @@ function convertClassMember(
1281
1281
  inheritComments(
1282
1282
  member,
1283
1283
  t.ObjectTypeAccessorSignature({
1284
- // $FlowFixMe[incompatible-call]
1284
+ // $FlowFixMe[incompatible-type]
1285
1285
  key: asDetachedNode<
1286
1286
  ClassPropertyNameComputed | ClassPropertyNameNonComputed,
1287
1287
  >(newKey),
@@ -1298,7 +1298,7 @@ function convertClassMember(
1298
1298
  inheritComments(
1299
1299
  member,
1300
1300
  t.ObjectTypeMethodSignature({
1301
- // $FlowFixMe[incompatible-call]
1301
+ // $FlowFixMe[incompatible-type]
1302
1302
  key: asDetachedNode<
1303
1303
  ClassPropertyNameComputed | ClassPropertyNameNonComputed,
1304
1304
  >(newKey),
@@ -1603,7 +1603,7 @@ function convertFunctionParameters(
1603
1603
  );
1604
1604
  }
1605
1605
  const [resultParam, deps] = convertBindingNameToFunctionTypeParam(
1606
- // $FlowFixMe[incompatible-call] I dont think these other cases are possible
1606
+ // $FlowFixMe[incompatible-type] I dont think these other cases are possible
1607
1607
  param.argument,
1608
1608
  context,
1609
1609
  index,
@@ -1729,7 +1729,7 @@ function convertTypeAnnotationTypeOrNull(
1729
1729
  context: TranslationContext,
1730
1730
  ): TranslatedResultOrNull<TypeAnnotationType> {
1731
1731
  if (annot == null) {
1732
- // $FlowFixMe[incompatible-return]
1732
+ // $FlowFixMe[incompatible-type]
1733
1733
  return EMPTY_TRANSLATION_RESULT;
1734
1734
  }
1735
1735
 
@@ -1740,7 +1740,7 @@ function convertTypeParameterDeclarationOrNull(
1740
1740
  context: TranslationContext,
1741
1741
  ): TranslatedResultOrNull<TypeParameterDeclaration> {
1742
1742
  if (decl == null) {
1743
- // $FlowFixMe[incompatible-return]
1743
+ // $FlowFixMe[incompatible-type]
1744
1744
  return EMPTY_TRANSLATION_RESULT;
1745
1745
  }
1746
1746
  return [asDetachedNode(decl), analyzeTypeDependencies(decl, context)];
@@ -1750,7 +1750,7 @@ function convertTypeParameterInstantiationOrNull(
1750
1750
  context: TranslationContext,
1751
1751
  ): TranslatedResultOrNull<TypeParameterInstantiation> {
1752
1752
  if (inst == null) {
1753
- // $FlowFixMe[incompatible-return]
1753
+ // $FlowFixMe[incompatible-type]
1754
1754
  return EMPTY_TRANSLATION_RESULT;
1755
1755
  }
1756
1756
  return [asDetachedNode(inst), analyzeTypeDependencies(inst, context)];
package/dist/flowToJS.js CHANGED
@@ -35,5 +35,5 @@ function stripAtFlow(ast, _options) {
35
35
  }
36
36
 
37
37
  function flowToJS(sourceAST, _code, _scopeManager) {
38
- return [_hermesParser.Transforms.stripComponentSyntax, _hermesParser.Transforms.stripFlowTypes, stripAtFlow].reduce((ast, transform) => transform(ast, {}), sourceAST);
38
+ return [_hermesParser.Transforms.transformComponentSyntax, _hermesParser.Transforms.stripFlowTypes, stripAtFlow].reduce((ast, transform) => transform(ast, {}), sourceAST);
39
39
  }
@@ -37,7 +37,7 @@ export function flowToJS(
37
37
  _scopeManager: ScopeManager,
38
38
  ): Program {
39
39
  return [
40
- Transforms.stripComponentSyntax,
40
+ Transforms.transformComponentSyntax,
41
41
  Transforms.stripFlowTypes,
42
42
  stripAtFlow,
43
43
  ].reduce((ast, transform) => transform(ast, {}), sourceAST);
package/dist/index.js CHANGED
@@ -61,7 +61,7 @@ async function translateFlowDefToTSDef(code, prettierOptions = {}) {
61
61
  const [tsAST, mutatedCode] = (0, _flowDefToTSDef.flowDefToTSDef)(code, ast, scopeManager, {
62
62
  recoverFromErrors: true
63
63
  });
64
- return (0, _hermesTransform.print)( // $FlowExpectedError[incompatible-call] - this is fine as we're providing the visitor keys
64
+ return (0, _hermesTransform.print)( // $FlowExpectedError[incompatible-type] - this is fine as we're providing the visitor keys
65
65
  tsAST, mutatedCode, { ...prettierOptions
66
66
  }, _visitorKeys.visitorKeys);
67
67
  }
@@ -53,7 +53,7 @@ export async function translateFlowDefToTSDef(
53
53
  });
54
54
 
55
55
  return print(
56
- // $FlowExpectedError[incompatible-call] - this is fine as we're providing the visitor keys
56
+ // $FlowExpectedError[incompatible-type] - this is fine as we're providing the visitor keys
57
57
  tsAST,
58
58
  mutatedCode,
59
59
  {
@@ -43,7 +43,7 @@ function constructFlowNode(node) {
43
43
  };
44
44
  }
45
45
 
46
- const makeCommentOwnLine = // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
46
+ const makeCommentOwnLine = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
47
47
  _hermesTransform.makeCommentOwnLine;
48
48
 
49
49
  function TSDefToFlowDef(originalCode, ast, opts) {
@@ -107,7 +107,7 @@ const getTransforms = (originalCode, opts) => {
107
107
  code = makeCommentOwnLine(code, comment); // $FlowExpectedError[prop-missing]
108
108
  // $FlowExpectedError[cannot-write]
109
109
 
110
- (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-cast]
110
+ (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-type]
111
111
 
112
112
  node.comments.push(comment);
113
113
  }
@@ -183,14 +183,14 @@ const getTransforms = (originalCode, opts) => {
183
183
 
184
184
  case 'TSAbstractPropertyDefinition':
185
185
  case 'PropertyDefinition':
186
- // $FlowFixMe[incompatible-call] ambiguous node
186
+ // $FlowFixMe[incompatible-type] ambiguous node
187
187
  Transform._translateIntoObjectProp(classItem, properties, indexers);
188
188
 
189
189
  break;
190
190
 
191
191
  case 'MethodDefinition':
192
192
  case 'TSAbstractMethodDefinition':
193
- // $FlowFixMe[incompatible-call] ambiguous node
193
+ // $FlowFixMe[incompatible-type] ambiguous node
194
194
  Transform._translateIntoObjectMethod(classItem, properties);
195
195
 
196
196
  break;
@@ -975,7 +975,7 @@ const getTransforms = (originalCode, opts) => {
975
975
  objectType: base,
976
976
  indexType: constructFlowNode({
977
977
  type: 'StringLiteralTypeAnnotation',
978
- // $FlowFixMe[incompatible-call]
978
+ // $FlowFixMe[incompatible-type]
979
979
  value: name,
980
980
  // $FlowFixMe[incompatible-type]
981
981
  raw: `'${name}'`
@@ -45,9 +45,9 @@ function constructFlowNode(node) {
45
45
  return node;
46
46
  }
47
47
 
48
- const cloneJSDocCommentsToNewNode = // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
48
+ const cloneJSDocCommentsToNewNode = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
49
49
  _hermesTransform.cloneJSDocCommentsToNewNode;
50
- const makeCommentOwnLine = // $FlowExpectedError[incompatible-cast] - trust me this re-type is 100% safe
50
+ const makeCommentOwnLine = // $FlowExpectedError[incompatible-type] - trust me this re-type is 100% safe
51
51
  _hermesTransform.makeCommentOwnLine;
52
52
  const VALID_REACT_IMPORTS = new Set(['React', 'react']);
53
53
 
@@ -86,8 +86,6 @@ function flowDefToTSDef(originalCode, ast, scopeManager, opts) {
86
86
  if (node.type in transform) {
87
87
  const result = transform[// $FlowExpectedError[prop-missing]
88
88
  node.type]( // $FlowExpectedError[incompatible-type]
89
- // $FlowExpectedError[prop-missing]
90
- // $FlowFixMe[incompatible-call]
91
89
  node);
92
90
  tsBody.push(...(Array.isArray(result) ? result : [result]));
93
91
  } else {
@@ -160,7 +158,7 @@ const getTransforms = (originalCode, scopeManager, opts) => {
160
158
  code = makeCommentOwnLine(code, comment); // $FlowExpectedError[prop-missing]
161
159
  // $FlowExpectedError[cannot-write]
162
160
 
163
- (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-cast]
161
+ (_node$comments = node.comments) != null ? _node$comments : node.comments = []; // $FlowExpectedError[incompatible-type]
164
162
 
165
163
  node.comments.push(comment);
166
164
  }
@@ -49,7 +49,7 @@ function getTopLevelStatement(node, context) {
49
49
  var _currentNode$parent;
50
50
 
51
51
  if (((_currentNode$parent = currentNode.parent) == null ? void 0 : _currentNode$parent.type) === 'Program') {
52
- // $FlowFixMe[incompatible-return]
52
+ // $FlowFixMe[incompatible-type]
53
53
  return currentNode;
54
54
  }
55
55
 
@@ -425,7 +425,7 @@ function convertObjectExpression(expr, context) {
425
425
 
426
426
  const [resultExpr, deps] = convertAFunction(prop.value, context);
427
427
  return [inheritComments(prop, _hermesTransform.t.ObjectTypeMethodSignature({
428
- // $FlowFixMe[incompatible-call]
428
+ // $FlowFixMe[incompatible-type]
429
429
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
430
430
  value: resultExpr
431
431
  })), deps];
@@ -439,7 +439,7 @@ function convertObjectExpression(expr, context) {
439
439
  const kind = prop.kind;
440
440
  const [resultExpr, deps] = convertAFunction(prop.value, context);
441
441
  return [inheritComments(prop, _hermesTransform.t.ObjectTypeAccessorSignature({
442
- // $FlowFixMe[incompatible-call]
442
+ // $FlowFixMe[incompatible-type]
443
443
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
444
444
  kind,
445
445
  value: resultExpr
@@ -448,7 +448,7 @@ function convertObjectExpression(expr, context) {
448
448
 
449
449
  const [resultExpr, deps] = convertExpressionToTypeAnnotation(prop.value, context);
450
450
  return [inheritComments(prop, _hermesTransform.t.ObjectTypePropertySignature({
451
- // $FlowFixMe[incompatible-call]
451
+ // $FlowFixMe[incompatible-type]
452
452
  key: (0, _hermesTransform.asDetachedNode)(prop.key),
453
453
  value: resultExpr,
454
454
  optional: false,
@@ -754,7 +754,7 @@ function convertClassDeclaration(class_, context) {
754
754
  }
755
755
 
756
756
  return [_hermesTransform.t.DeclareClass({
757
- // $FlowFixMe[incompatible-call]
757
+ // $FlowFixMe[incompatible-type]
758
758
  id: (0, _hermesTransform.asDetachedNode)(class_.id),
759
759
  typeParameters: resultTypeParams,
760
760
  implements: class_.implements.map(impl => (0, _hermesTransform.asDetachedNode)(impl)),
@@ -827,7 +827,7 @@ function convertSuperClassHelper(detachedId, nodeForDependencies, superTypeParam
827
827
 
828
828
  function convertSuperClass(superClass, superTypeParameters, context) {
829
829
  if (superClass == null) {
830
- // $FlowFixMe[incompatible-return]
830
+ // $FlowFixMe[incompatible-type]
831
831
  return EMPTY_TRANSLATION_RESULT;
832
832
  }
833
833
 
@@ -889,7 +889,7 @@ function convertClassMember(member, context) {
889
889
 
890
890
  // PrivateIdentifier's are not exposed so can be stripped.
891
891
  if (member.key.type === 'PrivateIdentifier') {
892
- // $FlowFixMe[incompatible-return]
892
+ // $FlowFixMe[incompatible-type]
893
893
  return EMPTY_TRANSLATION_RESULT;
894
894
  }
895
895
 
@@ -900,7 +900,7 @@ function convertClassMember(member, context) {
900
900
  if (((_member$value = member.value) == null ? void 0 : _member$value.type) === 'ArrowFunctionExpression' && member.typeAnnotation == null) {
901
901
  const [resultTypeAnnotation, deps] = convertAFunction(member.value, context);
902
902
  return [inheritComments(member, _hermesTransform.t.ObjectTypePropertySignature({
903
- // $FlowFixMe[incompatible-call]
903
+ // $FlowFixMe[incompatible-type]
904
904
  key: (0, _hermesTransform.asDetachedNode)(member.key),
905
905
  value: resultTypeAnnotation,
906
906
  optional: member.optional,
@@ -911,7 +911,7 @@ function convertClassMember(member, context) {
911
911
 
912
912
  const [resultTypeAnnotation, deps] = convertTypeAnnotation(member.typeAnnotation, member, context);
913
913
  return [inheritComments(member, _hermesTransform.t.ObjectTypePropertySignature({
914
- // $FlowFixMe[incompatible-call]
914
+ // $FlowFixMe[incompatible-type]
915
915
  key: (0, _hermesTransform.asDetachedNode)(member.key),
916
916
  value: resultTypeAnnotation,
917
917
  optional: member.optional,
@@ -924,7 +924,7 @@ function convertClassMember(member, context) {
924
924
  {
925
925
  // PrivateIdentifier's are not exposed so can be stripped.
926
926
  if (member.key.type === 'PrivateIdentifier') {
927
- // $FlowFixMe[incompatible-return]
927
+ // $FlowFixMe[incompatible-type]
928
928
  return EMPTY_TRANSLATION_RESULT;
929
929
  }
930
930
 
@@ -941,7 +941,7 @@ function convertClassMember(member, context) {
941
941
  // accessors are methods - but flow accessor signatures are properties
942
942
  const kind = member.kind;
943
943
  return [inheritComments(member, _hermesTransform.t.ObjectTypeAccessorSignature({
944
- // $FlowFixMe[incompatible-call]
944
+ // $FlowFixMe[incompatible-type]
945
945
  key: (0, _hermesTransform.asDetachedNode)(newKey),
946
946
  value: resultValue,
947
947
  static: member.static,
@@ -950,7 +950,7 @@ function convertClassMember(member, context) {
950
950
  }
951
951
 
952
952
  return [inheritComments(member, _hermesTransform.t.ObjectTypeMethodSignature({
953
- // $FlowFixMe[incompatible-call]
953
+ // $FlowFixMe[incompatible-type]
954
954
  key: (0, _hermesTransform.asDetachedNode)(newKey),
955
955
  value: resultValue,
956
956
  static: member.static
@@ -1138,7 +1138,7 @@ function convertFunctionParameters(params, context) {
1138
1138
  throw (0, _ErrorUtils.translationError)(param, `FunctionParameter: Multiple rest elements found`, context);
1139
1139
  }
1140
1140
 
1141
- const [resultParam, deps] = convertBindingNameToFunctionTypeParam( // $FlowFixMe[incompatible-call] I dont think these other cases are possible
1141
+ const [resultParam, deps] = convertBindingNameToFunctionTypeParam( // $FlowFixMe[incompatible-type] I dont think these other cases are possible
1142
1142
  param.argument, context, index, false);
1143
1143
  return [resultParams, resultParam, [...paramsDeps, ...deps]];
1144
1144
  }
@@ -1200,7 +1200,7 @@ function convertTypeAnnotationType(annot, container, context) {
1200
1200
 
1201
1201
  function convertTypeAnnotationTypeOrNull(annot, context) {
1202
1202
  if (annot == null) {
1203
- // $FlowFixMe[incompatible-return]
1203
+ // $FlowFixMe[incompatible-type]
1204
1204
  return EMPTY_TRANSLATION_RESULT;
1205
1205
  }
1206
1206
 
@@ -1209,7 +1209,7 @@ function convertTypeAnnotationTypeOrNull(annot, context) {
1209
1209
 
1210
1210
  function convertTypeParameterDeclarationOrNull(decl, context) {
1211
1211
  if (decl == null) {
1212
- // $FlowFixMe[incompatible-return]
1212
+ // $FlowFixMe[incompatible-type]
1213
1213
  return EMPTY_TRANSLATION_RESULT;
1214
1214
  }
1215
1215
 
@@ -1218,7 +1218,7 @@ function convertTypeParameterDeclarationOrNull(decl, context) {
1218
1218
 
1219
1219
  function convertTypeParameterInstantiationOrNull(inst, context) {
1220
1220
  if (inst == null) {
1221
- // $FlowFixMe[incompatible-return]
1221
+ // $FlowFixMe[incompatible-type]
1222
1222
  return EMPTY_TRANSLATION_RESULT;
1223
1223
  }
1224
1224
 
@@ -35,5 +35,5 @@ function stripAtFlow(ast, _options) {
35
35
  }
36
36
 
37
37
  function flowToJS(sourceAST, _code, _scopeManager) {
38
- return [_hermesParser.Transforms.stripComponentSyntax, _hermesParser.Transforms.stripFlowTypes, stripAtFlow].reduce((ast, transform) => transform(ast, {}), sourceAST);
38
+ return [_hermesParser.Transforms.transformComponentSyntax, _hermesParser.Transforms.stripFlowTypes, stripAtFlow].reduce((ast, transform) => transform(ast, {}), sourceAST);
39
39
  }
package/dist/src/index.js CHANGED
@@ -61,7 +61,7 @@ async function translateFlowDefToTSDef(code, prettierOptions = {}) {
61
61
  const [tsAST, mutatedCode] = (0, _flowDefToTSDef.flowDefToTSDef)(code, ast, scopeManager, {
62
62
  recoverFromErrors: true
63
63
  });
64
- return (0, _hermesTransform.print)( // $FlowExpectedError[incompatible-call] - this is fine as we're providing the visitor keys
64
+ return (0, _hermesTransform.print)( // $FlowExpectedError[incompatible-type] - this is fine as we're providing the visitor keys
65
65
  tsAST, mutatedCode, { ...prettierOptions
66
66
  }, _visitorKeys.visitorKeys);
67
67
  }
@@ -25,7 +25,7 @@ function analyzeFunctionReturn(func) {
25
25
  if (returnType != null) {
26
26
  return returnType;
27
27
  } // We trust Flow has validated this function to only return void
28
- // $FlowFixMe[incompatible-return]
28
+ // $FlowFixMe[incompatible-type]
29
29
 
30
30
 
31
31
  return _hermesTransform.t.TypeAnnotation({
@@ -25,7 +25,7 @@ function analyzeFunctionReturn(func) {
25
25
  if (returnType != null) {
26
26
  return returnType;
27
27
  } // We trust Flow has validated this function to only return void
28
- // $FlowFixMe[incompatible-return]
28
+ // $FlowFixMe[incompatible-type]
29
29
 
30
30
 
31
31
  return _hermesTransform.t.TypeAnnotation({
@@ -23,7 +23,7 @@ export function analyzeFunctionReturn(func: AFunction): TypeAnnotation {
23
23
  }
24
24
 
25
25
  // We trust Flow has validated this function to only return void
26
- // $FlowFixMe[incompatible-return]
26
+ // $FlowFixMe[incompatible-type]
27
27
  return t.TypeAnnotation({typeAnnotation: t.VoidTypeAnnotation()});
28
28
  }
29
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-api-translator",
3
- "version": "0.31.2",
3
+ "version": "0.32.1",
4
4
  "description": "Toolkit for creating Flow and TypeScript compatible libraries from Flow source code.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -13,10 +13,10 @@
13
13
  "@typescript-eslint/parser": "8.38.0",
14
14
  "@typescript-eslint/visitor-keys": "8.38.0",
15
15
  "flow-enums-runtime": "^0.0.6",
16
- "hermes-eslint": "0.31.2",
17
- "hermes-estree": "0.31.2",
18
- "hermes-parser": "0.31.2",
19
- "hermes-transform": "0.31.2",
16
+ "hermes-eslint": "0.32.1",
17
+ "hermes-estree": "0.32.1",
18
+ "hermes-parser": "0.32.1",
19
+ "hermes-transform": "0.32.1",
20
20
  "typescript": "5.3.2"
21
21
  },
22
22
  "peerDependencies": {