flow-api-translator 0.11.0 → 0.12.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.
@@ -58,6 +58,7 @@ function flowDefToTSDef(originalCode, ast, scopeManager, opts) {
58
58
  const result = transform[// $FlowExpectedError[prop-missing]
59
59
  node.type]( // $FlowExpectedError[incompatible-type]
60
60
  // $FlowExpectedError[prop-missing]
61
+ // $FlowFixMe[incompatible-call]
61
62
  node);
62
63
  tsBody.push(...(Array.isArray(result) ? result : [result]));
63
64
  } else {
@@ -72,6 +72,7 @@ export function flowDefToTSDef(
72
72
  ](
73
73
  // $FlowExpectedError[incompatible-type]
74
74
  // $FlowExpectedError[prop-missing]
75
+ // $FlowFixMe[incompatible-call]
75
76
  node,
76
77
  );
77
78
  tsBody.push(...(Array.isArray(result) ? result : [result]));
package/dist/index.js CHANGED
@@ -32,27 +32,27 @@ var _flowImportTo = require("./flowImportTo");
32
32
 
33
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
34
 
35
- function translateFlowToFlowDef(code, prettierOptions = {}) {
35
+ async function translateFlowToFlowDef(code, prettierOptions = {}) {
36
36
  const {
37
37
  ast,
38
38
  scopeManager
39
- } = (0, _hermesTransform.parse)(code);
39
+ } = await (0, _hermesTransform.parse)(code);
40
40
  const [flowDefAst, mutatedCode] = (0, _flowToFlowDef.default)(ast, code, scopeManager, {
41
41
  recoverFromErrors: true
42
42
  });
43
43
  return (0, _hermesTransform.print)(flowDefAst, mutatedCode, prettierOptions);
44
44
  }
45
45
 
46
- function translateFlowToTSDef(code, prettierOptions = {}) {
47
- const flowDefCode = translateFlowToFlowDef(code, prettierOptions);
46
+ async function translateFlowToTSDef(code, prettierOptions = {}) {
47
+ const flowDefCode = await translateFlowToFlowDef(code, prettierOptions);
48
48
  return translateFlowDefToTSDef(flowDefCode, prettierOptions);
49
49
  }
50
50
 
51
- function translateFlowDefToTSDef(code, prettierOptions = {}) {
51
+ async function translateFlowDefToTSDef(code, prettierOptions = {}) {
52
52
  const {
53
53
  ast,
54
54
  scopeManager
55
- } = (0, _hermesTransform.parse)(code);
55
+ } = await (0, _hermesTransform.parse)(code);
56
56
  const [tsAST, mutatedCode] = (0, _flowDefToTSDef.flowDefToTSDef)(code, ast, scopeManager, {
57
57
  recoverFromErrors: true
58
58
  });
@@ -61,20 +61,20 @@ function translateFlowDefToTSDef(code, prettierOptions = {}) {
61
61
  }, _visitorKeys.visitorKeys);
62
62
  }
63
63
 
64
- function translateFlowToJS(code, prettierOptions = {}) {
64
+ async function translateFlowToJS(code, prettierOptions = {}) {
65
65
  const {
66
66
  ast,
67
67
  scopeManager
68
- } = (0, _hermesTransform.parse)(code);
68
+ } = await (0, _hermesTransform.parse)(code);
69
69
  const jsAST = (0, _flowToJS.flowToJS)(ast, code, scopeManager);
70
70
  return (0, _hermesTransform.print)(jsAST, code, prettierOptions);
71
71
  }
72
72
 
73
- function translateFlowImportsTo(code, prettierOptions = {}, opts) {
73
+ async function translateFlowImportsTo(code, prettierOptions = {}, opts) {
74
74
  const {
75
75
  ast,
76
76
  scopeManager
77
- } = (0, _hermesTransform.parse)(code);
77
+ } = await (0, _hermesTransform.parse)(code);
78
78
  const jsAST = (0, _flowImportTo.flowImportTo)(ast, code, scopeManager, opts);
79
79
  return (0, _hermesTransform.print)(jsAST, code, prettierOptions);
80
80
  }
@@ -19,11 +19,11 @@ import {flowDefToTSDef} from './flowDefToTSDef';
19
19
  import {flowToJS} from './flowToJS';
20
20
  import {flowImportTo} from './flowImportTo';
21
21
 
22
- export function translateFlowToFlowDef(
22
+ export async function translateFlowToFlowDef(
23
23
  code: string,
24
24
  prettierOptions: {...} = {},
25
- ): string {
26
- const {ast, scopeManager} = parse(code);
25
+ ): Promise<string> {
26
+ const {ast, scopeManager} = await parse(code);
27
27
 
28
28
  const [flowDefAst, mutatedCode] = flowToFlowDef(ast, code, scopeManager, {
29
29
  recoverFromErrors: true,
@@ -32,20 +32,20 @@ export function translateFlowToFlowDef(
32
32
  return print(flowDefAst, mutatedCode, prettierOptions);
33
33
  }
34
34
 
35
- export function translateFlowToTSDef(
35
+ export async function translateFlowToTSDef(
36
36
  code: string,
37
37
  prettierOptions: {...} = {},
38
- ): string {
39
- const flowDefCode = translateFlowToFlowDef(code, prettierOptions);
38
+ ): Promise<string> {
39
+ const flowDefCode = await translateFlowToFlowDef(code, prettierOptions);
40
40
 
41
41
  return translateFlowDefToTSDef(flowDefCode, prettierOptions);
42
42
  }
43
43
 
44
- export function translateFlowDefToTSDef(
44
+ export async function translateFlowDefToTSDef(
45
45
  code: string,
46
46
  prettierOptions: {...} = {},
47
- ): string {
48
- const {ast, scopeManager} = parse(code);
47
+ ): Promise<string> {
48
+ const {ast, scopeManager} = await parse(code);
49
49
  const [tsAST, mutatedCode] = flowDefToTSDef(code, ast, scopeManager, {
50
50
  recoverFromErrors: true,
51
51
  });
@@ -61,11 +61,11 @@ export function translateFlowDefToTSDef(
61
61
  );
62
62
  }
63
63
 
64
- export function translateFlowToJS(
64
+ export async function translateFlowToJS(
65
65
  code: string,
66
66
  prettierOptions: {...} = {},
67
- ): string {
68
- const {ast, scopeManager} = parse(code);
67
+ ): Promise<string> {
68
+ const {ast, scopeManager} = await parse(code);
69
69
 
70
70
  const jsAST = flowToJS(ast, code, scopeManager);
71
71
 
@@ -73,12 +73,12 @@ export function translateFlowToJS(
73
73
  }
74
74
 
75
75
  export type {MapperOptions as FlowImportsMapperOptions};
76
- export function translateFlowImportsTo(
76
+ export async function translateFlowImportsTo(
77
77
  code: string,
78
78
  prettierOptions: {...} = {},
79
79
  opts: MapperOptions,
80
- ): string {
81
- const {ast, scopeManager} = parse(code);
80
+ ): Promise<string> {
81
+ const {ast, scopeManager} = await parse(code);
82
82
 
83
83
  const jsAST = flowImportTo(ast, code, scopeManager, opts);
84
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-api-translator",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
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,13 +12,13 @@
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.10.1",
16
- "hermes-estree": "0.10.1",
17
- "hermes-parser": "0.10.1",
18
- "hermes-transform": "0.10.1"
15
+ "hermes-eslint": "0.12.0",
16
+ "hermes-estree": "0.12.0",
17
+ "hermes-parser": "0.12.0",
18
+ "hermes-transform": "0.12.0"
19
19
  },
20
20
  "peerDependencies": {
21
- "prettier": "^2.7.1"
21
+ "prettier": "^3.0.0 || ^2.7.1"
22
22
  },
23
23
  "files": [
24
24
  "dist",