Add assertions to ExportNamedDeclaration without from (#13957)
This commit is contained in:
parent
966387d263
commit
87fc2e76d7
@ -1893,6 +1893,9 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
node.source = null;
|
node.source = null;
|
||||||
node.declaration = null;
|
node.declaration = null;
|
||||||
|
if (this.hasPlugin("importAssertions")) {
|
||||||
|
node.assertions = [];
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1903,6 +1906,9 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
if (this.shouldParseExportDeclaration()) {
|
if (this.shouldParseExportDeclaration()) {
|
||||||
node.specifiers = [];
|
node.specifiers = [];
|
||||||
node.source = null;
|
node.source = null;
|
||||||
|
if (this.hasPlugin("importAssertions")) {
|
||||||
|
node.assertions = [];
|
||||||
|
}
|
||||||
node.declaration = this.parseExportDeclaration(node);
|
node.declaration = this.parseExportDeclaration(node);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2015,12 +2021,8 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
if (assertions) {
|
if (assertions) {
|
||||||
node.assertions = assertions;
|
node.assertions = assertions;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (expect) {
|
||||||
if (expect) {
|
|
||||||
this.unexpected();
|
this.unexpected();
|
||||||
} else {
|
|
||||||
node.source = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
|
|||||||
@ -56,7 +56,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": null,
|
"source": null,
|
||||||
"declaration": null
|
"declaration": null,
|
||||||
|
"assertions": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "ExpressionStatement",
|
"type": "ExpressionStatement",
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
export class Foo {}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||||
|
"specifiers": [],
|
||||||
|
"source": null,
|
||||||
|
"declaration": {
|
||||||
|
"type": "ClassDeclaration",
|
||||||
|
"start":7,"end":19,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":19}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":13,"end":16,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":16},"identifierName":"Foo"},
|
||||||
|
"name": "Foo"
|
||||||
|
},
|
||||||
|
"superClass": null,
|
||||||
|
"body": {
|
||||||
|
"type": "ClassBody",
|
||||||
|
"start":17,"end":19,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}},
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assertions": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export function foo() {}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||||
|
"specifiers": [],
|
||||||
|
"source": null,
|
||||||
|
"declaration": {
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start":7,"end":24,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":24}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":16,"end":19,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":19},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":22,"end":24,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":24}},
|
||||||
|
"body": [],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assertions": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export const foo = "";
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
|
||||||
|
"specifiers": [],
|
||||||
|
"source": null,
|
||||||
|
"declaration": {
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":7,"end":22,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":22}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":13,"end":21,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":21}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":13,"end":16,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":16},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":19,"end":21,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":21}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "",
|
||||||
|
"raw": "\"\""
|
||||||
|
},
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "const"
|
||||||
|
},
|
||||||
|
"assertions": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
const foo = "";
|
||||||
|
|
||||||
|
export { foo };
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":15}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":15}},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":6,"end":14,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":14}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start":12,"end":14,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":14}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "",
|
||||||
|
"raw": "\"\""
|
||||||
|
},
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "const"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExportNamedDeclaration",
|
||||||
|
"start":17,"end":32,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":15}},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ExportSpecifier",
|
||||||
|
"start":26,"end":29,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":12}},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":26,"end":29,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"exported": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":26,"end":29,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":12},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": null,
|
||||||
|
"declaration": null,
|
||||||
|
"assertions": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user