@@ -3876,8 +3876,9 @@ namespace ts {
3876
3876
function visitAndTransformType<T>(type: Type, transform: (type: Type) => T) {
3877
3877
const typeId = "" + type.id;
3878
3878
const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class;
3879
- const id = getObjectFlags(type) & ObjectFlags.Reference ? "N" + getNodeId((<DeferredTypeReference>type).node) :
3880
- (isConstructorObject ? "+" : "") + getSymbolId(type.symbol);
3879
+ const id = getObjectFlags(type) & ObjectFlags.Reference && (<TypeReference>type).node ? "N" + getNodeId((<TypeReference>type).node!) :
3880
+ type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
3881
+ undefined;
3881
3882
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
3882
3883
// of types allows us to catch circular references to instantiations of the same anonymous type
3883
3884
if (!context.visitedTypes) {
@@ -29347,12 +29348,9 @@ namespace ts {
29347
29348
29348
29349
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) {
29349
29350
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
29350
- // that all instantiated base constructor signatures return the same type. We can simply compare the type
29351
- // references (as opposed to checking the structure of the types) because elsewhere we have already checked
29352
- // that the base type is a class or interface type (and not, for example, an anonymous object type).
29353
- // (Javascript constructor functions have this property trivially true since their return type is ignored.)
29351
+ // that all instantiated base constructor signatures return the same type.
29354
29352
const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
29355
- if (forEach(constructors, sig => !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType)) {
29353
+ if (forEach(constructors, sig => !isJSConstructor(sig.declaration) && !isTypeIdenticalTo( getReturnTypeOfSignature(sig), baseType) )) {
29356
29354
error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type);
29357
29355
}
29358
29356
}
0 commit comments