diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index 8e10ad8e9072..c7163ec1f859 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -2780,16 +2780,14 @@ export default (superClass: Class): Class => } checkCommaAfterRest(close) { - if (this.match(tt.comma)) { - if (this.lookaheadCharCode() === close) { - if (!this.state.isDeclareContext) { - this.raiseTrailingCommaAfterRest(this.state.start); - return; - } - this.eat(tt.comma); - } else { - this.raiseRestNotLast(this.state.start); - } + if ( + this.state.isDeclareContext && + this.match(tt.comma) && + this.lookaheadCharCode() === close + ) { + this.next(); + } else { + super.checkCommaAfterRest(close); } }