From 56322d2eccf8c9954838c84b13e82d037a7bbc97 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 22 Oct 2015 11:26:19 -0700 Subject: [PATCH] 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. --- src/compiler/checker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 056f21ae945..fcdb93b01e0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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);