flow-api-translator 0.37.0 → 0.328.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.
- package/dist/TSDefToFlowDef.js +35 -279
- package/dist/TSDefToFlowDef.js.flow +16 -4
- package/dist/flowDefToTSDef.js +51 -377
- package/dist/flowDefToTSDef.js.flow +93 -12
- package/dist/flowImportTo.js +5 -16
- package/dist/flowImportTo.js.flow +3 -3
- package/dist/flowToFlowDef.js +134 -359
- package/dist/flowToFlowDef.js.flow +18 -12
- package/dist/flowToJS.js +3 -10
- package/dist/flowToJS.js.flow +5 -5
- package/dist/index.js +12 -28
- package/dist/index.js.flow +1 -1
- package/dist/src/TSDefToFlowDef.js +35 -279
- package/dist/src/flowDefToTSDef.js +51 -377
- package/dist/src/flowImportTo.js +5 -16
- package/dist/src/flowToFlowDef.js +134 -359
- package/dist/src/flowToJS.js +3 -10
- package/dist/src/index.js +12 -28
- package/dist/src/utils/DocblockUtils.js +4 -4
- package/dist/src/utils/ErrorUtils.js +3 -18
- package/dist/src/utils/FlowAnalyze.js +5 -16
- package/dist/src/utils/TSNodeUtils.js +28 -13
- package/dist/src/utils/TranslationUtils.js +0 -4
- package/dist/utils/DocblockUtils.js +4 -4
- package/dist/utils/DocblockUtils.js.flow +1 -1
- package/dist/utils/ErrorUtils.js +3 -18
- package/dist/utils/ErrorUtils.js.flow +3 -3
- package/dist/utils/FlowAnalyze.js +5 -16
- package/dist/utils/FlowAnalyze.js.flow +3 -3
- package/dist/utils/TSNodeUtils.js +28 -13
- package/dist/utils/TSNodeUtils.js.flow +35 -1
- package/dist/utils/TranslationUtils.js +0 -4
- package/dist/utils/TranslationUtils.js.flow +2 -2
- package/package.json +9 -9
package/dist/src/flowImportTo.js
CHANGED
|
@@ -4,61 +4,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.flowImportTo = flowImportTo;
|
|
7
|
-
|
|
8
|
-
var _hermesParser = require("hermes-parser");
|
|
9
|
-
|
|
7
|
+
var _flowParser = require("flow-parser");
|
|
10
8
|
function flowImportTo(ast, _code, _scopeManager, opts) {
|
|
11
9
|
function mapSource(source) {
|
|
12
10
|
const resultValue = opts.sourceMapper({
|
|
13
11
|
module: source.value
|
|
14
12
|
});
|
|
15
|
-
|
|
16
13
|
if (resultValue === source.value) {
|
|
17
14
|
return source;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
return _hermesParser.SimpleTransform.nodeWith(source, {
|
|
16
|
+
return _flowParser.SimpleTransform.nodeWith(source, {
|
|
21
17
|
value: resultValue,
|
|
22
18
|
raw: `"${resultValue}"`
|
|
23
19
|
});
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
const result = _hermesParser.SimpleTransform.transform(ast, {
|
|
21
|
+
const result = _flowParser.SimpleTransform.transform(ast, {
|
|
27
22
|
transform(node) {
|
|
28
23
|
switch (node.type) {
|
|
29
24
|
case 'ImportDeclaration':
|
|
30
25
|
{
|
|
31
|
-
return
|
|
26
|
+
return _flowParser.SimpleTransform.nodeWith(node, {
|
|
32
27
|
source: mapSource(node.source)
|
|
33
28
|
});
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
case 'DeclareExportAllDeclaration':
|
|
37
31
|
case 'ExportAllDeclaration':
|
|
38
32
|
case 'DeclareExportDeclaration':
|
|
39
33
|
case 'ExportNamedDeclaration':
|
|
40
34
|
{
|
|
41
35
|
if (node.source != null) {
|
|
42
|
-
return
|
|
36
|
+
return _flowParser.SimpleTransform.nodeWith(node, {
|
|
43
37
|
source: mapSource(node.source)
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
return node;
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
default:
|
|
51
43
|
{
|
|
52
44
|
return node;
|
|
53
45
|
}
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
});
|
|
58
|
-
|
|
59
49
|
if (result == null || result.type !== 'Program') {
|
|
60
50
|
throw new Error('flowImportTo: Unexpected transform result.');
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
return result;
|
|
64
53
|
}
|