flow-api-translator 0.36.1 → 0.327.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.
Files changed (37) hide show
  1. package/dist/TSDefToFlowDef.js +66 -327
  2. package/dist/TSDefToFlowDef.js.flow +70 -35
  3. package/dist/flowDefToTSDef.js +134 -825
  4. package/dist/flowDefToTSDef.js.flow +196 -100
  5. package/dist/flowImportTo.js +5 -25
  6. package/dist/flowImportTo.js.flow +4 -4
  7. package/dist/flowToFlowDef.js +190 -379
  8. package/dist/flowToFlowDef.js.flow +109 -27
  9. package/dist/flowToJS.js +3 -19
  10. package/dist/flowToJS.js.flow +5 -5
  11. package/dist/index.js +12 -50
  12. package/dist/index.js.flow +1 -1
  13. package/dist/src/TSDefToFlowDef.js +66 -327
  14. package/dist/src/flowDefToTSDef.js +134 -825
  15. package/dist/src/flowImportTo.js +5 -25
  16. package/dist/src/flowToFlowDef.js +190 -379
  17. package/dist/src/flowToJS.js +3 -19
  18. package/dist/src/index.js +12 -50
  19. package/dist/src/utils/DocblockUtils.js +4 -14
  20. package/dist/src/utils/ErrorUtils.js +4 -40
  21. package/dist/src/utils/FlowAnalyze.js +8 -28
  22. package/dist/src/utils/TSNodeUtils.js +83 -0
  23. package/dist/src/utils/TranslationUtils.js +0 -13
  24. package/dist/src/utils/ts-estree-ast-types.js +0 -29
  25. package/dist/utils/DocblockUtils.js +4 -14
  26. package/dist/utils/DocblockUtils.js.flow +1 -1
  27. package/dist/utils/ErrorUtils.js +4 -40
  28. package/dist/utils/ErrorUtils.js.flow +6 -6
  29. package/dist/utils/FlowAnalyze.js +8 -28
  30. package/dist/utils/FlowAnalyze.js.flow +9 -4
  31. package/dist/utils/TSNodeUtils.js +83 -0
  32. package/dist/utils/TSNodeUtils.js.flow +108 -0
  33. package/dist/utils/TranslationUtils.js +0 -13
  34. package/dist/utils/TranslationUtils.js.flow +2 -2
  35. package/dist/utils/ts-estree-ast-types.js +0 -29
  36. package/dist/utils/ts-estree-ast-types.js.flow +697 -740
  37. package/package.json +10 -9
@@ -1,73 +1,53 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
1
  'use strict';
11
2
 
12
3
  Object.defineProperty(exports, "__esModule", {
13
4
  value: true
14
5
  });
15
6
  exports.flowImportTo = flowImportTo;
16
-
17
- var _hermesParser = require("hermes-parser");
18
-
7
+ var _flowParser = require("flow-parser");
19
8
  function flowImportTo(ast, _code, _scopeManager, opts) {
20
9
  function mapSource(source) {
21
10
  const resultValue = opts.sourceMapper({
22
11
  module: source.value
23
12
  });
24
-
25
13
  if (resultValue === source.value) {
26
14
  return source;
27
15
  }
28
-
29
- return _hermesParser.SimpleTransform.nodeWith(source, {
16
+ return _flowParser.SimpleTransform.nodeWith(source, {
30
17
  value: resultValue,
31
18
  raw: `"${resultValue}"`
32
19
  });
33
20
  }
34
-
35
- const result = _hermesParser.SimpleTransform.transform(ast, {
21
+ const result = _flowParser.SimpleTransform.transform(ast, {
36
22
  transform(node) {
37
23
  switch (node.type) {
38
24
  case 'ImportDeclaration':
39
25
  {
40
- return _hermesParser.SimpleTransform.nodeWith(node, {
26
+ return _flowParser.SimpleTransform.nodeWith(node, {
41
27
  source: mapSource(node.source)
42
28
  });
43
29
  }
44
-
45
30
  case 'DeclareExportAllDeclaration':
46
31
  case 'ExportAllDeclaration':
47
32
  case 'DeclareExportDeclaration':
48
33
  case 'ExportNamedDeclaration':
49
34
  {
50
35
  if (node.source != null) {
51
- return _hermesParser.SimpleTransform.nodeWith(node, {
36
+ return _flowParser.SimpleTransform.nodeWith(node, {
52
37
  source: mapSource(node.source)
53
38
  });
54
39
  }
55
-
56
40
  return node;
57
41
  }
58
-
59
42
  default:
60
43
  {
61
44
  return node;
62
45
  }
63
46
  }
64
47
  }
65
-
66
48
  });
67
-
68
49
  if (result == null || result.type !== 'Program') {
69
50
  throw new Error('flowImportTo: Unexpected transform result.');
70
51
  }
71
-
72
52
  return result;
73
53
  }