Fix bug with parsing TS generic async arrow function (#9055)
This commit is contained in:
parent
e7f0c065cf
commit
4f16a12c03
@ -1299,11 +1299,17 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const oldInAsync = this.state.inAsync;
|
||||||
|
const oldInGenerator = this.state.inGenerator;
|
||||||
|
this.state.inAsync = true;
|
||||||
|
this.state.inGenerator = false;
|
||||||
res.id = null;
|
res.id = null;
|
||||||
res.generator = false;
|
res.generator = false;
|
||||||
res.expression = true; // May be set again by parseFunctionBody.
|
res.expression = true; // May be set again by parseFunctionBody.
|
||||||
res.async = true;
|
res.async = true;
|
||||||
this.parseFunctionBody(res, true);
|
this.parseFunctionBody(res, true);
|
||||||
|
this.state.inAsync = oldInAsync;
|
||||||
|
this.state.inGenerator = oldInGenerator;
|
||||||
return this.finishNode(res, "ArrowFunctionExpression");
|
return this.finishNode(res, "ArrowFunctionExpression");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
async <T>() => await null;
|
||||||
133
packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/output.json
vendored
Normal file
133
packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/output.json
vendored
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 26
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrowFunctionExpression",
|
||||||
|
"start": 0,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"typeParameters": {
|
||||||
|
"type": "TSTypeParameterDeclaration",
|
||||||
|
"start": 6,
|
||||||
|
"end": 9,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "TSTypeParameter",
|
||||||
|
"start": 7,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "T"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"id": null,
|
||||||
|
"generator": false,
|
||||||
|
"expression": true,
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "AwaitExpression",
|
||||||
|
"start": 15,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"argument": {
|
||||||
|
"type": "NullLiteral",
|
||||||
|
"start": 21,
|
||||||
|
"end": 25,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 21
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 25
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user