mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Root class merged with interface can be extended
I found that merging a class that has no base with an interface that has a base class causes a crash because `getDefaultConstructSignatures` assumes that any base must be a class base. Which was true in the previously buggy state.
This commit is contained in:
@@ -2845,6 +2845,10 @@ namespace ts {
|
||||
return type.resolvedBaseConstructorType;
|
||||
}
|
||||
|
||||
function hasClassBaseType(type: InterfaceType): boolean {
|
||||
return !!forEach(getBaseTypes(type), t => !!(t.symbol.flags & SymbolFlags.Class));
|
||||
}
|
||||
|
||||
function getBaseTypes(type: InterfaceType): ObjectType[] {
|
||||
let isClass = type.symbol.flags & SymbolFlags.Class;
|
||||
let isInterface = type.symbol.flags & SymbolFlags.Interface;
|
||||
@@ -3254,7 +3258,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDefaultConstructSignatures(classType: InterfaceType): Signature[] {
|
||||
if (!getBaseTypes(classType).length) {
|
||||
if (!hasClassBaseType(classType)) {
|
||||
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
|
||||
}
|
||||
let baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
|
||||
Reference in New Issue
Block a user