Allow tuple rest trailing comma (#10800)

This commit is contained in:
YeonJuan
2019-12-04 02:32:36 +09:00
committed by Nicolò Ribaudo
parent e74efd2c0a
commit d18afbd7c3
3 changed files with 185 additions and 1 deletions

View File

@@ -618,7 +618,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const restNode: N.TsRestType = this.startNode();
this.next(); // skips ellipsis
restNode.typeAnnotation = this.tsParseType();
this.checkCommaAfterRest(charCodes.rightSquareBracket);
if (
this.match(tt.comma) &&
this.lookaheadCharCode() !== charCodes.rightSquareBracket
) {
this.raiseRestNotLast(this.state.start);
}
return this.finishNode(restNode, "TSRestType");
}