From 9f74a7a22887a0e5f85171640b01f66df193b37f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Dec 2017 09:24:14 -0800 Subject: [PATCH] Rename TypeVariable to InstantiableType --- src/compiler/checker.ts | 16 ++++++++-------- src/compiler/types.ts | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f643541a329..344ad57de33 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6294,7 +6294,7 @@ namespace ts { return arrayFrom(props.values()); } - function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { + function getConstraintOfType(type: InstantiableType | UnionOrIntersectionType): Type { return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : type.flags & TypeFlags.IndexedAccess ? getConstraintOfIndexedAccess(type) : getBaseConstraintOfType(type); @@ -6316,7 +6316,7 @@ namespace ts { function getBaseConstraintOfType(type: Type): Type { if (type.flags & (TypeFlags.InstantiableNonPrimitive | TypeFlags.UnionOrIntersection)) { - const constraint = getResolvedBaseConstraint(type); + const constraint = getResolvedBaseConstraint(type); if (constraint !== noConstraintType && constraint !== circularConstraintType) { return constraint; } @@ -6330,7 +6330,7 @@ namespace ts { return undefined; } - function hasNonCircularBaseConstraint(type: TypeVariable): boolean { + function hasNonCircularBaseConstraint(type: InstantiableType): boolean { return getResolvedBaseConstraint(type) !== circularConstraintType; } @@ -6339,7 +6339,7 @@ namespace ts { * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint * circularly references the type variable. */ - function getResolvedBaseConstraint(type: TypeVariable | UnionOrIntersectionType): Type { + function getResolvedBaseConstraint(type: InstantiableType | UnionOrIntersectionType): Type { let typeStack: Type[]; let circular: boolean; if (!type.resolvedBaseConstraint) { @@ -7995,7 +7995,7 @@ namespace ts { return links.resolvedType; } - function getIndexTypeForGenericType(type: TypeVariable | UnionOrIntersectionType) { + function getIndexTypeForGenericType(type: InstantiableType | UnionOrIntersectionType) { if (!type.resolvedIndexType) { type.resolvedIndexType = createType(TypeFlags.Index); type.resolvedIndexType.type = type; @@ -8014,7 +8014,7 @@ namespace ts { } function getIndexType(type: Type): Type { - return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive) ? getIndexTypeForGenericType(type) : + return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive) ? getIndexTypeForGenericType(type) : getObjectFlags(type) & ObjectFlags.Mapped ? getConstraintTypeFromMappedType(type) : type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringType : getLiteralTypeFromPropertyNames(type); @@ -11449,11 +11449,11 @@ namespace ts { else if (target.flags & TypeFlags.UnionOrIntersection) { const targetTypes = (target).types; let typeVariableCount = 0; - let typeVariable: TypeVariable; + let typeVariable: TypeParameter | IndexedAccessType; // First infer to each type in union or intersection that isn't a type variable for (const t of targetTypes) { if (getInferenceInfoForType(t)) { - typeVariable = t; + typeVariable = t; typeVariableCount++; } else { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0f7b8aada5b..2ba528b59f8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3612,7 +3612,7 @@ namespace ts { syntheticType?: Type; } - export interface TypeVariable extends Type { + export interface InstantiableType extends Type { /* @internal */ resolvedBaseConstraint?: Type; /* @internal */ @@ -3620,7 +3620,7 @@ namespace ts { } // Type parameters (TypeFlags.TypeParameter) - export interface TypeParameter extends TypeVariable { + export interface TypeParameter extends InstantiableType { /** Retrieve using getConstraintFromTypeParameter */ /* @internal */ constraint?: Type; // Constraint @@ -3638,24 +3638,24 @@ namespace ts { // Indexed access types (TypeFlags.IndexedAccess) // Possible forms are T[xxx], xxx[T], or xxx[keyof T], where T is a type variable - export interface IndexedAccessType extends TypeVariable { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; } // keyof T types (TypeFlags.Index) - export interface IndexType extends Type { - type: TypeVariable | UnionOrIntersectionType; + export interface IndexType extends InstantiableType { + type: InstantiableType | UnionOrIntersectionType; } - export interface ConditionalType extends TypeVariable { + export interface ConditionalType extends InstantiableType { conditionType: Type; trueType: Type; falseType: Type; } - export interface ExtendsType extends TypeVariable { + export interface ExtendsType extends InstantiableType { checkType: Type; extendsType: Type; }