hermes-parser 0.19.0 → 0.19.2
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/HermesParserNodeDeserializers.js +11 -3
- package/dist/HermesParserWASM.js +1 -1
- package/dist/estree/StripComponentSyntax.js +6 -2
- package/dist/estree/StripComponentSyntax.js.flow +2 -2
- package/dist/estree/StripFlowTypes.js +1 -0
- package/dist/estree/StripFlowTypes.js.flow +1 -0
- package/dist/estree/StripFlowTypesForBabel.js +28 -0
- package/dist/estree/StripFlowTypesForBabel.js.flow +26 -0
- package/dist/generated/ESTreeVisitorKeys.js +1 -0
- package/dist/generated/ParserVisitorKeys.js +4 -0
- package/package.json +2 -2
|
@@ -684,7 +684,9 @@ function mapStatementList(stmts) {
|
|
|
684
684
|
|
|
685
685
|
if (((_node$declaration2 = node.declaration) == null ? void 0 : _node$declaration2.type) === 'HookDeclaration') {
|
|
686
686
|
const comp = mapHookDeclaration(node.declaration);
|
|
687
|
-
newBody.push(
|
|
687
|
+
newBody.push(nodeWith(node, {
|
|
688
|
+
declaration: comp
|
|
689
|
+
}));
|
|
688
690
|
break;
|
|
689
691
|
}
|
|
690
692
|
|
|
@@ -705,7 +707,9 @@ function mapStatementList(stmts) {
|
|
|
705
707
|
|
|
706
708
|
if (((_node$declaration4 = node.declaration) == null ? void 0 : _node$declaration4.type) === 'HookDeclaration') {
|
|
707
709
|
const comp = mapHookDeclaration(node.declaration);
|
|
708
|
-
newBody.push(
|
|
710
|
+
newBody.push(nodeWith(node, {
|
|
711
|
+
declaration: comp
|
|
712
|
+
}));
|
|
709
713
|
break;
|
|
710
714
|
}
|
|
711
715
|
|
|
@@ -768,7 +768,7 @@ function mapStatementList(
|
|
|
768
768
|
|
|
769
769
|
if (node.declaration?.type === 'HookDeclaration') {
|
|
770
770
|
const comp = mapHookDeclaration(node.declaration);
|
|
771
|
-
newBody.push(comp);
|
|
771
|
+
newBody.push(nodeWith(node, {declaration: comp}));
|
|
772
772
|
break;
|
|
773
773
|
}
|
|
774
774
|
|
|
@@ -787,7 +787,7 @@ function mapStatementList(
|
|
|
787
787
|
|
|
788
788
|
if (node.declaration?.type === 'HookDeclaration') {
|
|
789
789
|
const comp = mapHookDeclaration(node.declaration);
|
|
790
|
-
newBody.push(comp);
|
|
790
|
+
newBody.push(nodeWith(node, {declaration: comp}));
|
|
791
791
|
break;
|
|
792
792
|
}
|
|
793
793
|
|
|
@@ -80,6 +80,29 @@ function mapDeclareEnum(node) {
|
|
|
80
80
|
parent: node.parent
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Convert DeclareNamespace nodes to DeclareVariable
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
function mapDeclareNamespace(node) {
|
|
89
|
+
return {
|
|
90
|
+
type: 'DeclareVariable',
|
|
91
|
+
kind: 'const',
|
|
92
|
+
id: nodeWith(node.id, {
|
|
93
|
+
typeAnnotation: {
|
|
94
|
+
type: 'TypeAnnotation',
|
|
95
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
96
|
+
loc: node.body.loc,
|
|
97
|
+
range: node.body.range,
|
|
98
|
+
parent: EMPTY_PARENT
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
loc: node.loc,
|
|
102
|
+
range: node.range,
|
|
103
|
+
parent: node.parent
|
|
104
|
+
};
|
|
105
|
+
}
|
|
83
106
|
/**
|
|
84
107
|
* Remove `this` param from functions.
|
|
85
108
|
*/
|
|
@@ -170,6 +193,11 @@ function transformProgram(program, _options) {
|
|
|
170
193
|
return mapDeclareEnum(node);
|
|
171
194
|
}
|
|
172
195
|
|
|
196
|
+
case 'DeclareNamespace':
|
|
197
|
+
{
|
|
198
|
+
return mapDeclareNamespace(node);
|
|
199
|
+
}
|
|
200
|
+
|
|
173
201
|
case 'FunctionDeclaration':
|
|
174
202
|
case 'FunctionExpression':
|
|
175
203
|
{
|
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
Program,
|
|
24
24
|
ESNode,
|
|
25
25
|
DeclareEnum,
|
|
26
|
+
DeclareNamespace,
|
|
26
27
|
DeclareVariable,
|
|
27
28
|
AnyTypeAnnotation,
|
|
28
29
|
GenericTypeAnnotation,
|
|
@@ -92,6 +93,28 @@ function mapDeclareEnum(node: DeclareEnum): DeclareVariable {
|
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Convert DeclareNamespace nodes to DeclareVariable
|
|
98
|
+
*/
|
|
99
|
+
function mapDeclareNamespace(node: DeclareNamespace): DeclareVariable {
|
|
100
|
+
return {
|
|
101
|
+
type: 'DeclareVariable',
|
|
102
|
+
kind: 'const',
|
|
103
|
+
id: nodeWith(node.id, {
|
|
104
|
+
typeAnnotation: {
|
|
105
|
+
type: 'TypeAnnotation',
|
|
106
|
+
typeAnnotation: createAnyTypeAnnotation(node.body),
|
|
107
|
+
loc: node.body.loc,
|
|
108
|
+
range: node.body.range,
|
|
109
|
+
parent: EMPTY_PARENT,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
loc: node.loc,
|
|
113
|
+
range: node.range,
|
|
114
|
+
parent: node.parent,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
95
118
|
/**
|
|
96
119
|
* Remove `this` param from functions.
|
|
97
120
|
*/
|
|
@@ -177,6 +200,9 @@ export function transformProgram(
|
|
|
177
200
|
case 'DeclareEnum': {
|
|
178
201
|
return mapDeclareEnum(node);
|
|
179
202
|
}
|
|
203
|
+
case 'DeclareNamespace': {
|
|
204
|
+
return mapDeclareNamespace(node);
|
|
205
|
+
}
|
|
180
206
|
case 'FunctionDeclaration':
|
|
181
207
|
case 'FunctionExpression': {
|
|
182
208
|
return mapFunction(node);
|
|
@@ -64,6 +64,7 @@ module.exports = {
|
|
|
64
64
|
DeclareInterface: ['id', 'typeParameters', 'extends', 'body'],
|
|
65
65
|
DeclareModule: ['id', 'body'],
|
|
66
66
|
DeclareModuleExports: ['typeAnnotation'],
|
|
67
|
+
DeclareNamespace: ['id', 'body'],
|
|
67
68
|
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'supertype'],
|
|
68
69
|
DeclareTypeAlias: ['id', 'typeParameters', 'right'],
|
|
69
70
|
DeclareVariable: ['id'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-parser",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"description": "A JavaScript parser built from the Hermes engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"hermes-estree": "0.19.
|
|
12
|
+
"hermes-estree": "0.19.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/parser": "7.7.4",
|