Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parser option to allow
new.target
outside functions (#15114)
- Loading branch information
1 parent
52ccb06
commit 2a7495f
Showing
11 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-false-2/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const y = () => new.target; |
4 changes: 4 additions & 0 deletions
4
...s/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-false-2/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"errorRecovery": false, | ||
"throws": "`new.target` can only be used in functions or class properties. (1:16)" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-false/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const x = new.target; |
4 changes: 4 additions & 0 deletions
4
...ges/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-false/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"errorRecovery": false, | ||
"throws": "`new.target` can only be used in functions or class properties. (1:10)" | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-true/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const x = new.target; | ||
const y = () => new.target; |
4 changes: 4 additions & 0 deletions
4
...ages/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-true/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"allowNewTargetOutsideFunction": true, | ||
"errorRecovery": false | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/babel-parser/test/fixtures/core/opts/allowNewTargetOutsideFunction-true/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":27,"index":49}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":27,"index":49}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":6,"end":20,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":20,"index":20}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":7,"index":7},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"init": { | ||
"type": "MetaProperty", | ||
"start":10,"end":20,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":20,"index":20}}, | ||
"meta": { | ||
"type": "Identifier", | ||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":13,"index":13},"identifierName":"new"}, | ||
"name": "new" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start":14,"end":20,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":20,"index":20},"identifierName":"target"}, | ||
"name": "target" | ||
} | ||
} | ||
} | ||
], | ||
"kind": "const" | ||
}, | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":22,"end":49,"loc":{"start":{"line":2,"column":0,"index":22},"end":{"line":2,"column":27,"index":49}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":28,"end":48,"loc":{"start":{"line":2,"column":6,"index":28},"end":{"line":2,"column":26,"index":48}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":28,"end":29,"loc":{"start":{"line":2,"column":6,"index":28},"end":{"line":2,"column":7,"index":29},"identifierName":"y"}, | ||
"name": "y" | ||
}, | ||
"init": { | ||
"type": "ArrowFunctionExpression", | ||
"start":32,"end":48,"loc":{"start":{"line":2,"column":10,"index":32},"end":{"line":2,"column":26,"index":48}}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "MetaProperty", | ||
"start":38,"end":48,"loc":{"start":{"line":2,"column":16,"index":38},"end":{"line":2,"column":26,"index":48}}, | ||
"meta": { | ||
"type": "Identifier", | ||
"start":38,"end":41,"loc":{"start":{"line":2,"column":16,"index":38},"end":{"line":2,"column":19,"index":41},"identifierName":"new"}, | ||
"name": "new" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start":42,"end":48,"loc":{"start":{"line":2,"column":20,"index":42},"end":{"line":2,"column":26,"index":48},"identifierName":"target"}, | ||
"name": "target" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"kind": "const" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters