flow-api-translator 0.18.0 → 0.18.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.
@@ -394,7 +394,7 @@ function convertObjectExpression(expr, context) {
394
394
 
395
395
  case 'Property':
396
396
  {
397
- if (prop.key.type !== 'Identifier' && prop.key.type !== 'StringLiteral') {
397
+ if (!(0, _hermesEstree.isIdentifier)(prop.key) && !(0, _hermesEstree.isStringLiteral)(prop.key) && !(0, _hermesEstree.isNumericLiteral)(prop.key)) {
398
398
  throw (0, _ErrorUtils.translationError)(prop.key, `ObjectExpression Property: Unsupported key type of "${prop.key.type}"`, context);
399
399
  }
400
400
 
@@ -772,7 +772,7 @@ function convertClassMember(member, context) {
772
772
  return EMPTY_TRANSLATION_RESULT;
773
773
  }
774
774
 
775
- if (member.key.type !== 'Identifier' && member.key.type !== 'StringLiteral') {
775
+ if (!(0, _hermesEstree.isIdentifier)(member.key) && !(0, _hermesEstree.isStringLiteral)(member.key) && !(0, _hermesEstree.isNumericLiteral)(member.key)) {
776
776
  throw (0, _ErrorUtils.translationError)(member.key, `ClassMember PropertyDefinition: Unsupported key type of "${member.key.type}"`, context);
777
777
  }
778
778
 
@@ -794,7 +794,7 @@ function convertClassMember(member, context) {
794
794
  return EMPTY_TRANSLATION_RESULT;
795
795
  }
796
796
 
797
- if (member.key.type !== 'Identifier' && member.key.type !== 'StringLiteral') {
797
+ if (!(0, _hermesEstree.isIdentifier)(member.key) && !(0, _hermesEstree.isStringLiteral)(member.key) && !(0, _hermesEstree.isNumericLiteral)(member.key)) {
798
798
  throw (0, _ErrorUtils.translationError)(member.key, `ClassMember PropertyDefinition: Unsupported key type of "${member.key.type}"`, context);
799
799
  }
800
800
 
@@ -76,7 +76,12 @@ import {
76
76
  import {createTranslationContext} from './utils/TranslationUtils';
77
77
  import {asDetachedNode} from 'hermes-transform';
78
78
  import {translationError, flowFixMeOrError} from './utils/ErrorUtils';
79
- import {isExpression} from 'hermes-estree';
79
+ import {
80
+ isExpression,
81
+ isStringLiteral,
82
+ isNumericLiteral,
83
+ isIdentifier,
84
+ } from 'hermes-estree';
80
85
 
81
86
  const EMPTY_TRANSLATION_RESULT = [null, []];
82
87
 
@@ -475,8 +480,9 @@ function convertObjectExpression(
475
480
  }
476
481
  case 'Property': {
477
482
  if (
478
- prop.key.type !== 'Identifier' &&
479
- prop.key.type !== 'StringLiteral'
483
+ !isIdentifier(prop.key) &&
484
+ !isStringLiteral(prop.key) &&
485
+ !isNumericLiteral(prop.key)
480
486
  ) {
481
487
  throw translationError(
482
488
  prop.key,
@@ -773,7 +779,7 @@ function convertExportDefaultDeclaration(
773
779
  context: TranslationContext,
774
780
  ): TranslatedResult<ProgramStatement> {
775
781
  const expr = stmt.declaration;
776
- if (isExpression(expr) && (expr: Expression).type === 'Identifier') {
782
+ if (isExpression(expr) && (expr: $FlowFixMe).type === 'Identifier') {
777
783
  const name = ((expr: $FlowFixMe): Identifier).name;
778
784
  const [declDecl, deps] = [
779
785
  t.TypeofTypeAnnotation({argument: t.Identifier({name})}),
@@ -1011,8 +1017,9 @@ function convertClassMember(
1011
1017
  return EMPTY_TRANSLATION_RESULT;
1012
1018
  }
1013
1019
  if (
1014
- member.key.type !== 'Identifier' &&
1015
- member.key.type !== 'StringLiteral'
1020
+ !isIdentifier(member.key) &&
1021
+ !isStringLiteral(member.key) &&
1022
+ !isNumericLiteral(member.key)
1016
1023
  ) {
1017
1024
  throw translationError(
1018
1025
  member.key,
@@ -1047,8 +1054,9 @@ function convertClassMember(
1047
1054
  return EMPTY_TRANSLATION_RESULT;
1048
1055
  }
1049
1056
  if (
1050
- member.key.type !== 'Identifier' &&
1051
- member.key.type !== 'StringLiteral'
1057
+ !isIdentifier(member.key) &&
1058
+ !isStringLiteral(member.key) &&
1059
+ !isNumericLiteral(member.key)
1052
1060
  ) {
1053
1061
  throw translationError(
1054
1062
  member.key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-api-translator",
3
- "version": "0.18.0",
3
+ "version": "0.18.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",
@@ -12,10 +12,10 @@
12
12
  "@babel/code-frame": "^7.16.0",
13
13
  "@typescript-eslint/visitor-keys": "^5.42.0",
14
14
  "flow-enums-runtime": "^0.0.6",
15
- "hermes-eslint": "0.18.0",
16
- "hermes-estree": "0.18.0",
17
- "hermes-parser": "0.18.0",
18
- "hermes-transform": "0.18.0"
15
+ "hermes-eslint": "0.18.1",
16
+ "hermes-estree": "0.18.1",
17
+ "hermes-parser": "0.18.1",
18
+ "hermes-transform": "0.18.1"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "prettier": "^3.0.0 || ^2.7.1"