flow-parser 0.319.0 → 0.320.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/flow_parser.js +9498 -9488
- package/oxidized/FlowParserNodeDeserializers.js +26 -12
- package/oxidized/FlowParserWASM.js +1 -1
- package/oxidized/babel/TransformESTreeToBabel.js +11 -3
- package/oxidized/babel/TransformESTreeToBabel.js.flow +12 -4
- package/oxidized/estree/StripFlowTypesForBabel.js +33 -18
- package/oxidized/estree/StripFlowTypesForBabel.js.flow +40 -18
- package/oxidized/estree/TransformComponentSyntax.js +25 -12
- package/oxidized/estree/TransformComponentSyntax.js.flow +29 -11
- package/oxidized/generated/ESTreeVisitorKeys.js +1 -1
- package/oxidized/oxidized-src/FlowParserNodeDeserializers.js +26 -12
- package/oxidized/oxidized-src/babel/TransformESTreeToBabel.js +11 -3
- package/oxidized/oxidized-src/estree/StripFlowTypesForBabel.js +33 -18
- package/oxidized/oxidized-src/estree/TransformComponentSyntax.js +25 -12
- package/oxidized/oxidized-src/generated/ESTreeVisitorKeys.js +1 -1
- package/package.json +2 -2
|
@@ -30,6 +30,7 @@ const FlowESTreeAndBabelVisitorKeys = { ..._ESTreeVisitorKeys.default,
|
|
|
30
30
|
ClassPrivateMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],
|
|
31
31
|
ClassProperty: ['key', 'value', 'typeAnnotation', 'variance'],
|
|
32
32
|
ClassPrivateProperty: ['key', 'value', 'typeAnnotation', 'variance'],
|
|
33
|
+
DeclareVariable: ['id'],
|
|
33
34
|
Directive: ['value'],
|
|
34
35
|
DirectiveLiteral: [],
|
|
35
36
|
ExportNamespaceSpecifier: ['exported'],
|
|
@@ -435,11 +436,18 @@ function mapTypeofTypeAnnotation(node) {
|
|
|
435
436
|
}
|
|
436
437
|
|
|
437
438
|
function mapDeclareVariable(node) {
|
|
438
|
-
|
|
439
|
-
|
|
439
|
+
var _babelNode$declaratio;
|
|
440
|
+
|
|
441
|
+
const babelNode = node;
|
|
442
|
+
|
|
443
|
+
if (babelNode.id == null && Array.isArray(babelNode.declarations) && ((_babelNode$declaratio = babelNode.declarations[0]) == null ? void 0 : _babelNode$declaratio.id) != null) {
|
|
444
|
+
babelNode.id = babelNode.declarations[0].id;
|
|
440
445
|
}
|
|
441
446
|
|
|
442
|
-
|
|
447
|
+
delete babelNode.declarations;
|
|
448
|
+
delete babelNode.kind;
|
|
449
|
+
delete babelNode.implicitDeclare;
|
|
450
|
+
return babelNode;
|
|
443
451
|
}
|
|
444
452
|
|
|
445
453
|
function mapJSXElement(node) {
|
|
@@ -68,6 +68,7 @@ const FlowESTreeAndBabelVisitorKeys: VisitorKeys = {
|
|
|
68
68
|
ClassPrivateMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],
|
|
69
69
|
ClassProperty: ['key', 'value', 'typeAnnotation', 'variance'],
|
|
70
70
|
ClassPrivateProperty: ['key', 'value', 'typeAnnotation', 'variance'],
|
|
71
|
+
DeclareVariable: ['id'],
|
|
71
72
|
Directive: ['value'],
|
|
72
73
|
DirectiveLiteral: [],
|
|
73
74
|
ExportNamespaceSpecifier: ['exported'],
|
|
@@ -778,11 +779,18 @@ function mapTypeofTypeAnnotation(
|
|
|
778
779
|
}
|
|
779
780
|
|
|
780
781
|
function mapDeclareVariable(node: DeclareVariable): DeclareVariable {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
782
|
+
const babelNode: $FlowFixMe = node;
|
|
783
|
+
if (
|
|
784
|
+
babelNode.id == null &&
|
|
785
|
+
Array.isArray(babelNode.declarations) &&
|
|
786
|
+
babelNode.declarations[0]?.id != null
|
|
787
|
+
) {
|
|
788
|
+
babelNode.id = babelNode.declarations[0].id;
|
|
784
789
|
}
|
|
785
|
-
|
|
790
|
+
delete babelNode.declarations;
|
|
791
|
+
delete babelNode.kind;
|
|
792
|
+
delete babelNode.implicitDeclare;
|
|
793
|
+
return babelNode;
|
|
786
794
|
}
|
|
787
795
|
|
|
788
796
|
function mapJSXElement(node: JSXElement): JSXElement {
|
|
@@ -40,19 +40,32 @@ function createAnyTypeAnnotation(node) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function declareVariableDeclarator(id, node) {
|
|
44
|
+
return {
|
|
45
|
+
type: 'VariableDeclarator',
|
|
46
|
+
id,
|
|
47
|
+
init: null,
|
|
48
|
+
loc: node.loc,
|
|
49
|
+
range: node.range,
|
|
50
|
+
parent: EMPTY_PARENT
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
function mapDeclareEnum(node) {
|
|
55
|
+
const id = nodeWith(node.id, {
|
|
56
|
+
typeAnnotation: {
|
|
57
|
+
type: 'TypeAnnotation',
|
|
58
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
59
|
+
loc: node.body.loc,
|
|
60
|
+
range: node.body.range,
|
|
61
|
+
parent: EMPTY_PARENT
|
|
62
|
+
}
|
|
63
|
+
});
|
|
44
64
|
return {
|
|
45
65
|
type: 'DeclareVariable',
|
|
46
66
|
kind: 'const',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type: 'TypeAnnotation',
|
|
50
|
-
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
51
|
-
loc: node.body.loc,
|
|
52
|
-
range: node.body.range,
|
|
53
|
-
parent: EMPTY_PARENT
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
67
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
68
|
+
implicitDeclare: false,
|
|
56
69
|
loc: node.loc,
|
|
57
70
|
range: node.range,
|
|
58
71
|
parent: node.parent
|
|
@@ -60,18 +73,20 @@ function mapDeclareEnum(node) {
|
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
function mapDeclareNamespace(node) {
|
|
76
|
+
const id = nodeWith(node.id, {
|
|
77
|
+
typeAnnotation: {
|
|
78
|
+
type: 'TypeAnnotation',
|
|
79
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
80
|
+
loc: node.body.loc,
|
|
81
|
+
range: node.body.range,
|
|
82
|
+
parent: EMPTY_PARENT
|
|
83
|
+
}
|
|
84
|
+
});
|
|
63
85
|
return {
|
|
64
86
|
type: 'DeclareVariable',
|
|
65
87
|
kind: 'const',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
type: 'TypeAnnotation',
|
|
69
|
-
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
70
|
-
loc: node.body.loc,
|
|
71
|
-
range: node.body.range,
|
|
72
|
-
parent: EMPTY_PARENT
|
|
73
|
-
}
|
|
74
|
-
}),
|
|
88
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
89
|
+
implicitDeclare: false,
|
|
75
90
|
loc: node.loc,
|
|
76
91
|
range: node.range,
|
|
77
92
|
parent: node.parent
|
|
@@ -30,6 +30,8 @@ import type {
|
|
|
30
30
|
QualifiedTypeIdentifier,
|
|
31
31
|
QualifiedTypeofIdentifier,
|
|
32
32
|
AFunction,
|
|
33
|
+
BindingName,
|
|
34
|
+
VariableDeclarator,
|
|
33
35
|
} from 'flow-estree';
|
|
34
36
|
|
|
35
37
|
import {SimpleTransform} from '../transform/SimpleTransform';
|
|
@@ -71,22 +73,39 @@ function createAnyTypeAnnotation(node: ESNode): AnyTypeAnnotation {
|
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
function declareVariableDeclarator(
|
|
77
|
+
id: BindingName,
|
|
78
|
+
node: ESNode,
|
|
79
|
+
): VariableDeclarator {
|
|
80
|
+
return {
|
|
81
|
+
type: 'VariableDeclarator',
|
|
82
|
+
id,
|
|
83
|
+
init: null,
|
|
84
|
+
loc: node.loc,
|
|
85
|
+
range: node.range,
|
|
86
|
+
parent: EMPTY_PARENT,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
74
90
|
/**
|
|
75
91
|
* Convert DeclareEnum nodes to DeclareVariable
|
|
76
92
|
*/
|
|
77
93
|
function mapDeclareEnum(node: DeclareEnum): DeclareVariable {
|
|
94
|
+
const id = nodeWith(node.id, {
|
|
95
|
+
typeAnnotation: {
|
|
96
|
+
type: 'TypeAnnotation',
|
|
97
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
98
|
+
loc: node.body.loc,
|
|
99
|
+
range: node.body.range,
|
|
100
|
+
parent: EMPTY_PARENT,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
78
104
|
return {
|
|
79
105
|
type: 'DeclareVariable',
|
|
80
106
|
kind: 'const',
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type: 'TypeAnnotation',
|
|
84
|
-
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
85
|
-
loc: node.body.loc,
|
|
86
|
-
range: node.body.range,
|
|
87
|
-
parent: EMPTY_PARENT,
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
107
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
108
|
+
implicitDeclare: false,
|
|
90
109
|
loc: node.loc,
|
|
91
110
|
range: node.range,
|
|
92
111
|
parent: node.parent,
|
|
@@ -97,18 +116,21 @@ function mapDeclareEnum(node: DeclareEnum): DeclareVariable {
|
|
|
97
116
|
* Convert DeclareNamespace nodes to DeclareVariable
|
|
98
117
|
*/
|
|
99
118
|
function mapDeclareNamespace(node: DeclareNamespace): DeclareVariable {
|
|
119
|
+
const id = nodeWith(node.id, {
|
|
120
|
+
typeAnnotation: {
|
|
121
|
+
type: 'TypeAnnotation',
|
|
122
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
123
|
+
loc: node.body.loc,
|
|
124
|
+
range: node.body.range,
|
|
125
|
+
parent: EMPTY_PARENT,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
100
129
|
return {
|
|
101
130
|
type: 'DeclareVariable',
|
|
102
131
|
kind: 'const',
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
type: 'TypeAnnotation',
|
|
106
|
-
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
107
|
-
loc: node.body.loc,
|
|
108
|
-
range: node.body.range,
|
|
109
|
-
parent: EMPTY_PARENT,
|
|
110
|
-
},
|
|
111
|
-
}),
|
|
132
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
133
|
+
implicitDeclare: false,
|
|
112
134
|
loc: node.loc,
|
|
113
135
|
range: node.range,
|
|
114
136
|
parent: node.parent,
|
|
@@ -23,24 +23,37 @@ function createDefaultPosition() {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function declareVariableDeclarator(id, node) {
|
|
27
27
|
return {
|
|
28
|
-
type: '
|
|
29
|
-
id
|
|
28
|
+
type: 'VariableDeclarator',
|
|
29
|
+
id,
|
|
30
|
+
init: null,
|
|
31
|
+
loc: node.loc,
|
|
32
|
+
range: node.range,
|
|
33
|
+
parent: EMPTY_PARENT
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function mapDeclareComponent(node) {
|
|
38
|
+
const id = nodeWith(node.id, {
|
|
39
|
+
typeAnnotation: {
|
|
40
|
+
type: 'TypeAnnotation',
|
|
30
41
|
typeAnnotation: {
|
|
31
|
-
type: '
|
|
32
|
-
typeAnnotation: {
|
|
33
|
-
type: 'AnyTypeAnnotation',
|
|
34
|
-
loc: node.loc,
|
|
35
|
-
range: node.range,
|
|
36
|
-
parent: EMPTY_PARENT
|
|
37
|
-
},
|
|
42
|
+
type: 'AnyTypeAnnotation',
|
|
38
43
|
loc: node.loc,
|
|
39
44
|
range: node.range,
|
|
40
45
|
parent: EMPTY_PARENT
|
|
41
|
-
}
|
|
42
|
-
|
|
46
|
+
},
|
|
47
|
+
loc: node.loc,
|
|
48
|
+
range: node.range,
|
|
49
|
+
parent: EMPTY_PARENT
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
type: 'DeclareVariable',
|
|
54
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
43
55
|
kind: 'const',
|
|
56
|
+
implicitDeclare: false,
|
|
44
57
|
loc: node.loc,
|
|
45
58
|
range: node.range,
|
|
46
59
|
parent: node.parent
|
|
@@ -47,6 +47,7 @@ import type {
|
|
|
47
47
|
BindingName,
|
|
48
48
|
ObjectTypePropertySignature,
|
|
49
49
|
ObjectTypeSpreadProperty,
|
|
50
|
+
VariableDeclarator,
|
|
50
51
|
} from 'flow-estree';
|
|
51
52
|
|
|
52
53
|
import {SimpleTransform} from '../transform/SimpleTransform';
|
|
@@ -66,24 +67,41 @@ function createDefaultPosition(): Position {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
function
|
|
70
|
+
function declareVariableDeclarator(
|
|
71
|
+
id: BindingName,
|
|
72
|
+
node: ESNode,
|
|
73
|
+
): VariableDeclarator {
|
|
70
74
|
return {
|
|
71
|
-
type: '
|
|
72
|
-
id
|
|
75
|
+
type: 'VariableDeclarator',
|
|
76
|
+
id,
|
|
77
|
+
init: null,
|
|
78
|
+
loc: node.loc,
|
|
79
|
+
range: node.range,
|
|
80
|
+
parent: EMPTY_PARENT,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function mapDeclareComponent(node: DeclareComponent): DeclareVariable {
|
|
85
|
+
const id = nodeWith(node.id, {
|
|
86
|
+
typeAnnotation: {
|
|
87
|
+
type: 'TypeAnnotation',
|
|
73
88
|
typeAnnotation: {
|
|
74
|
-
type: '
|
|
75
|
-
typeAnnotation: {
|
|
76
|
-
type: 'AnyTypeAnnotation',
|
|
77
|
-
loc: node.loc,
|
|
78
|
-
range: node.range,
|
|
79
|
-
parent: EMPTY_PARENT,
|
|
80
|
-
},
|
|
89
|
+
type: 'AnyTypeAnnotation',
|
|
81
90
|
loc: node.loc,
|
|
82
91
|
range: node.range,
|
|
83
92
|
parent: EMPTY_PARENT,
|
|
84
93
|
},
|
|
85
|
-
|
|
94
|
+
loc: node.loc,
|
|
95
|
+
range: node.range,
|
|
96
|
+
parent: EMPTY_PARENT,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
type: 'DeclareVariable',
|
|
102
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
86
103
|
kind: 'const',
|
|
104
|
+
implicitDeclare: false,
|
|
87
105
|
loc: node.loc,
|
|
88
106
|
range: node.range,
|
|
89
107
|
parent: node.parent,
|
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
|
51
51
|
DeclareNamespace: ['id', 'body'],
|
|
52
52
|
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
53
53
|
DeclareTypeAlias: ['id', 'typeParameters', 'right'],
|
|
54
|
-
DeclareVariable: ['
|
|
54
|
+
DeclareVariable: ['declarations'],
|
|
55
55
|
DeclaredPredicate: ['value'],
|
|
56
56
|
Decorator: ['expression'],
|
|
57
57
|
DoWhileStatement: ['body', 'test'],
|
|
@@ -816,14 +816,16 @@ module.exports = [function () {
|
|
|
816
816
|
return {
|
|
817
817
|
type: 'DeclareVariable',
|
|
818
818
|
loc: this.addEmptyLoc(),
|
|
819
|
-
|
|
820
|
-
kind: this.deserializeString()
|
|
819
|
+
declarations: this.deserializeNodeList(),
|
|
820
|
+
kind: this.deserializeString(),
|
|
821
|
+
implicitDeclare: this.deserializeBoolean()
|
|
821
822
|
};
|
|
822
823
|
}, function () {
|
|
823
824
|
return {
|
|
824
825
|
type: 'DeclareFunction',
|
|
825
826
|
loc: this.addEmptyLoc(),
|
|
826
827
|
id: this.deserializeNode(),
|
|
828
|
+
implicitDeclare: this.deserializeBoolean(),
|
|
827
829
|
predicate: this.deserializeNode()
|
|
828
830
|
};
|
|
829
831
|
}, function () {
|
|
@@ -835,7 +837,8 @@ module.exports = [function () {
|
|
|
835
837
|
extends: this.deserializeNodeList(),
|
|
836
838
|
implements: this.deserializeNodeList(),
|
|
837
839
|
mixins: this.deserializeNodeList(),
|
|
838
|
-
body: this.deserializeNode()
|
|
840
|
+
body: this.deserializeNode(),
|
|
841
|
+
implicitDeclare: this.deserializeBoolean()
|
|
839
842
|
};
|
|
840
843
|
}, function () {
|
|
841
844
|
return {
|
|
@@ -845,13 +848,15 @@ module.exports = [function () {
|
|
|
845
848
|
params: this.deserializeNodeList(),
|
|
846
849
|
rest: this.deserializeNode(),
|
|
847
850
|
rendersType: this.deserializeNode(),
|
|
848
|
-
typeParameters: this.deserializeNode()
|
|
851
|
+
typeParameters: this.deserializeNode(),
|
|
852
|
+
implicitDeclare: this.deserializeBoolean()
|
|
849
853
|
};
|
|
850
854
|
}, function () {
|
|
851
855
|
return {
|
|
852
856
|
type: 'DeclareHook',
|
|
853
857
|
loc: this.addEmptyLoc(),
|
|
854
|
-
id: this.deserializeNode()
|
|
858
|
+
id: this.deserializeNode(),
|
|
859
|
+
implicitDeclare: this.deserializeBoolean()
|
|
855
860
|
};
|
|
856
861
|
}, function () {
|
|
857
862
|
return {
|
|
@@ -873,20 +878,25 @@ module.exports = [function () {
|
|
|
873
878
|
default: this.deserializeBoolean(),
|
|
874
879
|
declaration: this.deserializeNode(),
|
|
875
880
|
specifiers: this.deserializeNodeList(),
|
|
876
|
-
source: this.deserializeNode()
|
|
881
|
+
source: this.deserializeNode(),
|
|
882
|
+
implicitDeclare: this.deserializeBoolean()
|
|
877
883
|
};
|
|
878
884
|
}, function () {
|
|
879
885
|
return {
|
|
880
886
|
type: 'DeclareExportAllDeclaration',
|
|
881
887
|
loc: this.addEmptyLoc(),
|
|
882
|
-
source: this.deserializeNode()
|
|
888
|
+
source: this.deserializeNode(),
|
|
889
|
+
implicitDeclare: this.deserializeBoolean()
|
|
883
890
|
};
|
|
884
891
|
}, function () {
|
|
885
892
|
return {
|
|
886
893
|
type: 'DeclareNamespace',
|
|
887
894
|
loc: this.addEmptyLoc(),
|
|
895
|
+
global: this.deserializeBoolean(),
|
|
888
896
|
id: this.deserializeNode(),
|
|
889
|
-
body: this.deserializeNode()
|
|
897
|
+
body: this.deserializeNode(),
|
|
898
|
+
implicitDeclare: this.deserializeBoolean(),
|
|
899
|
+
keyword: this.deserializeString()
|
|
890
900
|
};
|
|
891
901
|
}, function () {
|
|
892
902
|
return {
|
|
@@ -895,7 +905,8 @@ module.exports = [function () {
|
|
|
895
905
|
id: this.deserializeNode(),
|
|
896
906
|
typeParameters: this.deserializeNode(),
|
|
897
907
|
body: this.deserializeNode(),
|
|
898
|
-
extends: this.deserializeNodeList()
|
|
908
|
+
extends: this.deserializeNodeList(),
|
|
909
|
+
implicitDeclare: this.deserializeBoolean()
|
|
899
910
|
};
|
|
900
911
|
}, function () {
|
|
901
912
|
return {
|
|
@@ -903,14 +914,16 @@ module.exports = [function () {
|
|
|
903
914
|
loc: this.addEmptyLoc(),
|
|
904
915
|
id: this.deserializeNode(),
|
|
905
916
|
typeParameters: this.deserializeNode(),
|
|
906
|
-
right: this.deserializeNode()
|
|
917
|
+
right: this.deserializeNode(),
|
|
918
|
+
implicitDeclare: this.deserializeBoolean()
|
|
907
919
|
};
|
|
908
920
|
}, function () {
|
|
909
921
|
return {
|
|
910
922
|
type: 'DeclareEnum',
|
|
911
923
|
loc: this.addEmptyLoc(),
|
|
912
924
|
id: this.deserializeNode(),
|
|
913
|
-
body: this.deserializeNode()
|
|
925
|
+
body: this.deserializeNode(),
|
|
926
|
+
implicitDeclare: this.deserializeBoolean()
|
|
914
927
|
};
|
|
915
928
|
}, function () {
|
|
916
929
|
return {
|
|
@@ -1698,7 +1711,8 @@ module.exports = [function () {
|
|
|
1698
1711
|
impltype: this.deserializeNode(),
|
|
1699
1712
|
lowerBound: this.deserializeNode(),
|
|
1700
1713
|
upperBound: this.deserializeNode(),
|
|
1701
|
-
supertype: this.deserializeNode()
|
|
1714
|
+
supertype: this.deserializeNode(),
|
|
1715
|
+
implicitDeclare: this.deserializeBoolean()
|
|
1702
1716
|
};
|
|
1703
1717
|
}, function () {
|
|
1704
1718
|
return {
|
|
@@ -30,6 +30,7 @@ const FlowESTreeAndBabelVisitorKeys = { ..._ESTreeVisitorKeys.default,
|
|
|
30
30
|
ClassPrivateMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],
|
|
31
31
|
ClassProperty: ['key', 'value', 'typeAnnotation', 'variance'],
|
|
32
32
|
ClassPrivateProperty: ['key', 'value', 'typeAnnotation', 'variance'],
|
|
33
|
+
DeclareVariable: ['id'],
|
|
33
34
|
Directive: ['value'],
|
|
34
35
|
DirectiveLiteral: [],
|
|
35
36
|
ExportNamespaceSpecifier: ['exported'],
|
|
@@ -435,11 +436,18 @@ function mapTypeofTypeAnnotation(node) {
|
|
|
435
436
|
}
|
|
436
437
|
|
|
437
438
|
function mapDeclareVariable(node) {
|
|
438
|
-
|
|
439
|
-
|
|
439
|
+
var _babelNode$declaratio;
|
|
440
|
+
|
|
441
|
+
const babelNode = node;
|
|
442
|
+
|
|
443
|
+
if (babelNode.id == null && Array.isArray(babelNode.declarations) && ((_babelNode$declaratio = babelNode.declarations[0]) == null ? void 0 : _babelNode$declaratio.id) != null) {
|
|
444
|
+
babelNode.id = babelNode.declarations[0].id;
|
|
440
445
|
}
|
|
441
446
|
|
|
442
|
-
|
|
447
|
+
delete babelNode.declarations;
|
|
448
|
+
delete babelNode.kind;
|
|
449
|
+
delete babelNode.implicitDeclare;
|
|
450
|
+
return babelNode;
|
|
443
451
|
}
|
|
444
452
|
|
|
445
453
|
function mapJSXElement(node) {
|
|
@@ -40,19 +40,32 @@ function createAnyTypeAnnotation(node) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function declareVariableDeclarator(id, node) {
|
|
44
|
+
return {
|
|
45
|
+
type: 'VariableDeclarator',
|
|
46
|
+
id,
|
|
47
|
+
init: null,
|
|
48
|
+
loc: node.loc,
|
|
49
|
+
range: node.range,
|
|
50
|
+
parent: EMPTY_PARENT
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
function mapDeclareEnum(node) {
|
|
55
|
+
const id = nodeWith(node.id, {
|
|
56
|
+
typeAnnotation: {
|
|
57
|
+
type: 'TypeAnnotation',
|
|
58
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
59
|
+
loc: node.body.loc,
|
|
60
|
+
range: node.body.range,
|
|
61
|
+
parent: EMPTY_PARENT
|
|
62
|
+
}
|
|
63
|
+
});
|
|
44
64
|
return {
|
|
45
65
|
type: 'DeclareVariable',
|
|
46
66
|
kind: 'const',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type: 'TypeAnnotation',
|
|
50
|
-
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
51
|
-
loc: node.body.loc,
|
|
52
|
-
range: node.body.range,
|
|
53
|
-
parent: EMPTY_PARENT
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
67
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
68
|
+
implicitDeclare: false,
|
|
56
69
|
loc: node.loc,
|
|
57
70
|
range: node.range,
|
|
58
71
|
parent: node.parent
|
|
@@ -60,18 +73,20 @@ function mapDeclareEnum(node) {
|
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
function mapDeclareNamespace(node) {
|
|
76
|
+
const id = nodeWith(node.id, {
|
|
77
|
+
typeAnnotation: {
|
|
78
|
+
type: 'TypeAnnotation',
|
|
79
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
80
|
+
loc: node.body.loc,
|
|
81
|
+
range: node.body.range,
|
|
82
|
+
parent: EMPTY_PARENT
|
|
83
|
+
}
|
|
84
|
+
});
|
|
63
85
|
return {
|
|
64
86
|
type: 'DeclareVariable',
|
|
65
87
|
kind: 'const',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
type: 'TypeAnnotation',
|
|
69
|
-
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
70
|
-
loc: node.body.loc,
|
|
71
|
-
range: node.body.range,
|
|
72
|
-
parent: EMPTY_PARENT
|
|
73
|
-
}
|
|
74
|
-
}),
|
|
88
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
89
|
+
implicitDeclare: false,
|
|
75
90
|
loc: node.loc,
|
|
76
91
|
range: node.range,
|
|
77
92
|
parent: node.parent
|
|
@@ -23,24 +23,37 @@ function createDefaultPosition() {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function declareVariableDeclarator(id, node) {
|
|
27
27
|
return {
|
|
28
|
-
type: '
|
|
29
|
-
id
|
|
28
|
+
type: 'VariableDeclarator',
|
|
29
|
+
id,
|
|
30
|
+
init: null,
|
|
31
|
+
loc: node.loc,
|
|
32
|
+
range: node.range,
|
|
33
|
+
parent: EMPTY_PARENT
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function mapDeclareComponent(node) {
|
|
38
|
+
const id = nodeWith(node.id, {
|
|
39
|
+
typeAnnotation: {
|
|
40
|
+
type: 'TypeAnnotation',
|
|
30
41
|
typeAnnotation: {
|
|
31
|
-
type: '
|
|
32
|
-
typeAnnotation: {
|
|
33
|
-
type: 'AnyTypeAnnotation',
|
|
34
|
-
loc: node.loc,
|
|
35
|
-
range: node.range,
|
|
36
|
-
parent: EMPTY_PARENT
|
|
37
|
-
},
|
|
42
|
+
type: 'AnyTypeAnnotation',
|
|
38
43
|
loc: node.loc,
|
|
39
44
|
range: node.range,
|
|
40
45
|
parent: EMPTY_PARENT
|
|
41
|
-
}
|
|
42
|
-
|
|
46
|
+
},
|
|
47
|
+
loc: node.loc,
|
|
48
|
+
range: node.range,
|
|
49
|
+
parent: EMPTY_PARENT
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
type: 'DeclareVariable',
|
|
54
|
+
declarations: [declareVariableDeclarator(id, node)],
|
|
43
55
|
kind: 'const',
|
|
56
|
+
implicitDeclare: false,
|
|
44
57
|
loc: node.loc,
|
|
45
58
|
range: node.range,
|
|
46
59
|
parent: node.parent
|
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
|
51
51
|
DeclareNamespace: ['id', 'body'],
|
|
52
52
|
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
53
53
|
DeclareTypeAlias: ['id', 'typeParameters', 'right'],
|
|
54
|
-
DeclareVariable: ['
|
|
54
|
+
DeclareVariable: ['declarations'],
|
|
55
55
|
DeclaredPredicate: ['value'],
|
|
56
56
|
Decorator: ['expression'],
|
|
57
57
|
DoWhileStatement: ['body', 'test'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flow-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.320.0",
|
|
4
4
|
"description": "JavaScript parser written in OCaml. Produces ESTree AST",
|
|
5
5
|
"homepage": "https://flow.org",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "make js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"flow-estree": "0.
|
|
26
|
+
"flow-estree": "0.320.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/generator": "7.7.4",
|