TypeScript 4.0: Allow spread in the middle of tuples (#11753)
This commit is contained in:
committed by
Huáng Jùnliàng
parent
d7347fb8bd
commit
5b4b3a3e4a
@@ -630,9 +630,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
/* skipFirstToken */ false,
|
||||
);
|
||||
|
||||
// Validate the elementTypes to ensure:
|
||||
// No mandatory elements may follow optional elements
|
||||
// If there's a rest element, it must be at the end of the tuple
|
||||
// Validate the elementTypes to ensure that no mandatory elements
|
||||
// follow optional elements
|
||||
let seenOptionalElement = false;
|
||||
node.elementTypes.forEach(elementNode => {
|
||||
if (elementNode.type === "TSOptionalType") {
|
||||
@@ -651,12 +650,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const restNode: N.TsRestType = this.startNode();
|
||||
this.next(); // skips ellipsis
|
||||
restNode.typeAnnotation = this.tsParseType();
|
||||
if (
|
||||
this.match(tt.comma) &&
|
||||
this.lookaheadCharCode() !== charCodes.rightSquareBracket
|
||||
) {
|
||||
this.raiseRestNotLast(this.state.start);
|
||||
}
|
||||
return this.finishNode(restNode, "TSRestType");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user