@@ -3876,8 +3876,9 @@ namespace ts {
38763876 function visitAndTransformType<T>(type: Type, transform: (type: Type) => T) {
38773877 const typeId = "" + type.id;
38783878 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;
38813882 // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
38823883 // of types allows us to catch circular references to instantiations of the same anonymous type
38833884 if (!context.visitedTypes) {
@@ -29347,12 +29348,9 @@ namespace ts {
2934729348
2934829349 if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) {
2934929350 // 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.
2935429352 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) )) {
2935629354 error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type);
2935729355 }
2935829356 }
0 commit comments