Skip to content

Commit 5310fd0

Browse files
committed
Minor fixes
1 parent 7753f7b commit 5310fd0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/compiler/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,14 +4203,18 @@ namespace ts {
42034203
export interface TypeReference extends ObjectType {
42044204
target: GenericType; // Type reference target
42054205
node?: ArrayTypeNode | TupleTypeNode;
4206+
/* @internal */
42064207
mapper?: TypeMapper;
4208+
/* @internal */
42074209
resolvedTypeArguments?: ReadonlyArray<Type>; // Resolved ype reference type arguments
42084210
/* @internal */
42094211
literalType?: TypeReference; // Clone of type with ObjectFlags.ArrayLiteral set
42104212
}
42114213

42124214
export interface DeferredTypeReference extends TypeReference {
4215+
/* @internal */
42134216
node: ArrayTypeNode | TupleTypeNode;
4217+
/* @internal */
42144218
mapper?: TypeMapper;
42154219
}
42164220

0 commit comments

Comments
 (0)