Throw error if TypeScript class has empty implements (#9292)
This commit is contained in:
@@ -905,11 +905,21 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.finishNode(node, "TSTypeAssertion");
|
||||
}
|
||||
|
||||
tsParseHeritageClause(): $ReadOnlyArray<N.TsExpressionWithTypeArguments> {
|
||||
return this.tsParseDelimitedList(
|
||||
tsParseHeritageClause(
|
||||
descriptor: string,
|
||||
): $ReadOnlyArray<N.TsExpressionWithTypeArguments> {
|
||||
const originalStart = this.state.start;
|
||||
|
||||
const delimitedList = this.tsParseDelimitedList(
|
||||
"HeritageClauseElement",
|
||||
this.tsParseExpressionWithTypeArguments.bind(this),
|
||||
);
|
||||
|
||||
if (!delimitedList.length) {
|
||||
this.raise(originalStart, `'${descriptor}' list cannot be empty.`);
|
||||
}
|
||||
|
||||
return delimitedList;
|
||||
}
|
||||
|
||||
tsParseExpressionWithTypeArguments(): N.TsExpressionWithTypeArguments {
|
||||
@@ -930,7 +940,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.id = this.parseIdentifier();
|
||||
node.typeParameters = this.tsTryParseTypeParameters();
|
||||
if (this.eat(tt._extends)) {
|
||||
node.extends = this.tsParseHeritageClause();
|
||||
node.extends = this.tsParseHeritageClause("extends");
|
||||
}
|
||||
const body: N.TSInterfaceBody = this.startNode();
|
||||
body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
|
||||
@@ -1879,7 +1889,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.superTypeParameters = this.tsParseTypeArguments();
|
||||
}
|
||||
if (this.eatContextual("implements")) {
|
||||
node.implements = this.tsParseHeritageClause();
|
||||
node.implements = this.tsParseHeritageClause("implements");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user