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.
- package/dist/TSDefToFlowDef.js +66 -327
- package/dist/TSDefToFlowDef.js.flow +70 -35
- package/dist/flowDefToTSDef.js +134 -825
- package/dist/flowDefToTSDef.js.flow +196 -100
- package/dist/flowImportTo.js +5 -25
- package/dist/flowImportTo.js.flow +4 -4
- package/dist/flowToFlowDef.js +190 -379
- package/dist/flowToFlowDef.js.flow +109 -27
- package/dist/flowToJS.js +3 -19
- package/dist/flowToJS.js.flow +5 -5
- package/dist/index.js +12 -50
- package/dist/index.js.flow +1 -1
- package/dist/src/TSDefToFlowDef.js +66 -327
- package/dist/src/flowDefToTSDef.js +134 -825
- package/dist/src/flowImportTo.js +5 -25
- package/dist/src/flowToFlowDef.js +190 -379
- package/dist/src/flowToJS.js +3 -19
- package/dist/src/index.js +12 -50
- package/dist/src/utils/DocblockUtils.js +4 -14
- package/dist/src/utils/ErrorUtils.js +4 -40
- package/dist/src/utils/FlowAnalyze.js +8 -28
- package/dist/src/utils/TSNodeUtils.js +83 -0
- package/dist/src/utils/TranslationUtils.js +0 -13
- package/dist/src/utils/ts-estree-ast-types.js +0 -29
- package/dist/utils/DocblockUtils.js +4 -14
- package/dist/utils/DocblockUtils.js.flow +1 -1
- package/dist/utils/ErrorUtils.js +4 -40
- package/dist/utils/ErrorUtils.js.flow +6 -6
- package/dist/utils/FlowAnalyze.js +8 -28
- package/dist/utils/FlowAnalyze.js.flow +9 -4
- package/dist/utils/TSNodeUtils.js +83 -0
- package/dist/utils/TSNodeUtils.js.flow +108 -0
- package/dist/utils/TranslationUtils.js +0 -13
- package/dist/utils/TranslationUtils.js.flow +2 -2
- package/dist/utils/ts-estree-ast-types.js +0 -29
- package/dist/utils/ts-estree-ast-types.js.flow +697 -740
- package/package.json +10 -9
package/dist/flowImportTo.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
}
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
import type {ScopeManager} from '
|
|
14
|
-
import type {Program, ESNode, StringLiteral} from '
|
|
13
|
+
import type {ScopeManager} from 'flow-eslint';
|
|
14
|
+
import type {Program, ESNode, StringLiteral} from 'flow-estree';
|
|
15
15
|
|
|
16
|
-
import {SimpleTransform} from '
|
|
16
|
+
import {SimpleTransform} from 'flow-parser';
|
|
17
17
|
|
|
18
18
|
export type SourceMapperParams = {
|
|
19
19
|
module: string,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type MapperOptions =
|
|
22
|
+
export type MapperOptions = Readonly<{
|
|
23
23
|
sourceMapper: SourceMapperParams => string,
|
|
24
24
|
}>;
|
|
25
25
|
|