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:
Nathan Shively-Sanders
2015-10-22 11:26:19 -07:00
parent ae6ebe1550
commit 56322d2ecc

View File

@@ -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);