fix: Allow toplevel await when option true and correctly mark await keyword as unexpected (#9371)
This commit is contained in:
1
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-false/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-false/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for await (const i of imports) {}
|
||||
3
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-false/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-false/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \"(\" (1:4)"
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-true/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-true/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
for await (const i of imports) {}
|
||||
3
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-true/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-true/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"allowAwaitOutsideFunction": true
|
||||
}
|
||||
136
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-true/output.json
vendored
Normal file
136
packages/babel-parser/test/fixtures/core/opts/allowAwaitOutsideFunction-true/output.json
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"await": true,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 11,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 17,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "i"
|
||||
},
|
||||
"name": "i"
|
||||
},
|
||||
"init": null
|
||||
}
|
||||
],
|
||||
"kind": "const"
|
||||
},
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 22,
|
||||
"end": 29,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 29
|
||||
},
|
||||
"identifierName": "imports"
|
||||
},
|
||||
"name": "imports"
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 31,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 31
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:13)"
|
||||
"throws": "Unexpected token (2:6)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:22)"
|
||||
"throws": "Unexpected token (2:6)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:18)"
|
||||
"throws": "Unexpected token (2:6)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user