Merge pull request #3305 from jviereck/T7052
Fix: Arrow functions with trailing comma + return type are throwing an error when parsing
This commit is contained in:
@@ -528,7 +528,7 @@ pp.parseParenExpression = function () {
|
||||
return val;
|
||||
};
|
||||
|
||||
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync) {
|
||||
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync, allowOptionalCommaStart) {
|
||||
startPos = startPos || this.state.start;
|
||||
startLoc = startLoc || this.state.startLoc;
|
||||
|
||||
@@ -578,7 +578,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
|
||||
this.unexpected(this.state.lastTokStart);
|
||||
}
|
||||
}
|
||||
if (optionalCommaStart) this.unexpected(optionalCommaStart);
|
||||
if (optionalCommaStart && !allowOptionalCommaStart) this.unexpected(optionalCommaStart);
|
||||
if (spreadStart) this.unexpected(spreadStart);
|
||||
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
|
||||
|
||||
|
||||
@@ -1038,7 +1038,7 @@ export default function (instance) {
|
||||
return this.parseArrowExpression(node, [], isAsync);
|
||||
} else {
|
||||
// let foo = (foo): number => {};
|
||||
let node = inner.call(this, startPos, startLoc, canBeArrow, isAsync);
|
||||
let node = inner.call(this, startPos, startLoc, canBeArrow, isAsync, this.hasPlugin("trailingFunctionCommas"));
|
||||
|
||||
if (this.match(tt.colon)) {
|
||||
let state = this.state.clone();
|
||||
|
||||
Reference in New Issue
Block a user