mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
Handle the scenario when heritage clause of interface is not entity name expression
Fixes #12291
This commit is contained in:
parent
9fec77551c
commit
cbde25f229
@ -1143,7 +1143,10 @@ namespace ts {
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
|
||||
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
|
||||
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
|
||||
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
|
||||
}
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts(3,25): error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts (1 errors) ====
|
||||
|
||||
class A { }
|
||||
interface Class extends (typeof A) { }
|
||||
~~~~~~~~~~
|
||||
!!! error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
|
||||
@ -0,0 +1,18 @@
|
||||
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts]
|
||||
|
||||
class A { }
|
||||
interface Class extends (typeof A) { }
|
||||
|
||||
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
|
||||
|
||||
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.d.ts]
|
||||
declare class A {
|
||||
}
|
||||
interface Class {
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
// @declaration: true
|
||||
|
||||
class A { }
|
||||
interface Class extends (typeof A) { }
|
||||
Loading…
x
Reference in New Issue
Block a user