@@ -3033,7 +3033,7 @@ namespace ts {
3033
3033
return createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
3034
3034
}
3035
3035
if (type.flags & TypeFlags.Substitution) {
3036
- return typeToTypeNodeHelper((<SubstitutionType>type).typeParameter , context);
3036
+ return typeToTypeNodeHelper((<SubstitutionType>type).typeVariable , context);
3037
3037
}
3038
3038
3039
3039
Debug.fail("Should be unreachable.");
@@ -7303,7 +7303,7 @@ namespace ts {
7303
7303
const res = tryGetDeclaredTypeOfSymbol(symbol);
7304
7304
if (res) {
7305
7305
return checkNoTypeArguments(node, symbol) ?
7306
- res.flags & TypeFlags.TypeParameter ? getConstrainedTypeParameter (<TypeParameter>res, node) : res :
7306
+ res.flags & TypeFlags.TypeParameter ? getConstrainedTypeVariable (<TypeParameter>res, node) : res :
7307
7307
unknownType;
7308
7308
}
7309
7309
@@ -7342,25 +7342,25 @@ namespace ts {
7342
7342
}
7343
7343
}
7344
7344
7345
- function getSubstitutionType(typeParameter: TypeParameter , substitute: Type) {
7345
+ function getSubstitutionType(typeVariable: TypeVariable , substitute: Type) {
7346
7346
const result = <SubstitutionType>createType(TypeFlags.Substitution);
7347
- result.typeParameter = typeParameter ;
7347
+ result.typeVariable = typeVariable ;
7348
7348
result.substitute = substitute;
7349
7349
return result;
7350
7350
}
7351
7351
7352
- function getConstrainedTypeParameter(typeParameter: TypeParameter , node: Node) {
7352
+ function getConstrainedTypeVariable(typeVariable: TypeVariable , node: Node) {
7353
7353
let constraints: Type[];
7354
7354
while (isPartOfTypeNode(node)) {
7355
7355
const parent = node.parent;
7356
7356
if (parent.kind === SyntaxKind.ConditionalType && node === (<ConditionalTypeNode>parent).trueType) {
7357
- if (getTypeFromTypeNode((<ConditionalTypeNode>parent).checkType) === typeParameter ) {
7357
+ if (getActualTypeVariable( getTypeFromTypeNode((<ConditionalTypeNode>parent).checkType)) === typeVariable ) {
7358
7358
constraints = append(constraints, getTypeFromTypeNode((<ConditionalTypeNode>parent).extendsType));
7359
7359
}
7360
7360
}
7361
7361
node = parent;
7362
7362
}
7363
- return constraints ? getSubstitutionType(typeParameter , getIntersectionType(append(constraints, typeParameter ))) : typeParameter ;
7363
+ return constraints ? getSubstitutionType(typeVariable , getIntersectionType(append(constraints, typeVariable ))) : typeVariable ;
7364
7364
}
7365
7365
7366
7366
function isJSDocTypeReference(node: TypeReferenceType): node is TypeReferenceNode {
@@ -8256,7 +8256,13 @@ namespace ts {
8256
8256
function getTypeFromIndexedAccessTypeNode(node: IndexedAccessTypeNode) {
8257
8257
const links = getNodeLinks(node);
8258
8258
if (!links.resolvedType) {
8259
- links.resolvedType = getIndexedAccessType(getTypeFromTypeNode(node.objectType), getTypeFromTypeNode(node.indexType), node);
8259
+ const objectType = getTypeFromTypeNode(node.objectType);
8260
+ const indexType = getTypeFromTypeNode(node.indexType);
8261
+ const resolved = getIndexedAccessType(objectType, indexType, node);
8262
+ links.resolvedType = resolved.flags & TypeFlags.IndexedAccess &&
8263
+ (<IndexedAccessType>resolved).objectType === objectType &&
8264
+ (<IndexedAccessType>resolved).indexType === indexType ?
8265
+ getConstrainedTypeVariable(<IndexedAccessType>resolved, node) : resolved;
8260
8266
}
8261
8267
return links.resolvedType;
8262
8268
}
@@ -8276,8 +8282,8 @@ namespace ts {
8276
8282
return links.resolvedType;
8277
8283
}
8278
8284
8279
- function getActualTypeParameter (type: Type) {
8280
- return type.flags & TypeFlags.Substitution ? (<SubstitutionType>type).typeParameter : type;
8285
+ function getActualTypeVariable (type: Type) {
8286
+ return type.flags & TypeFlags.Substitution ? (<SubstitutionType>type).typeVariable : type;
8281
8287
}
8282
8288
8283
8289
function getConditionalType(root: ConditionalRoot, mapper: TypeMapper): Type {
@@ -8321,7 +8327,7 @@ namespace ts {
8321
8327
}
8322
8328
}
8323
8329
// Return a deferred type for a check that is neither definitely true nor definitely false
8324
- const erasedCheckType = getActualTypeParameter (checkType);
8330
+ const erasedCheckType = getActualTypeVariable (checkType);
8325
8331
const result = <ConditionalType>createType(TypeFlags.Conditional);
8326
8332
result.root = root;
8327
8333
result.checkType = erasedCheckType;
@@ -9041,7 +9047,7 @@ namespace ts {
9041
9047
return getConditionalTypeInstantiation(<ConditionalType>type, combineTypeMappers((<ConditionalType>type).mapper, mapper));
9042
9048
}
9043
9049
if (type.flags & TypeFlags.Substitution) {
9044
- return mapper ((<SubstitutionType>type).typeParameter );
9050
+ return instantiateType ((<SubstitutionType>type).typeVariable, mapper );
9045
9051
}
9046
9052
}
9047
9053
return type;
@@ -9647,10 +9653,10 @@ namespace ts {
9647
9653
target = (<LiteralType>target).regularType;
9648
9654
}
9649
9655
if (source.flags & TypeFlags.Substitution) {
9650
- source = relation === definitelyAssignableRelation ? (<SubstitutionType>source).typeParameter : (<SubstitutionType>source).substitute;
9656
+ source = relation === definitelyAssignableRelation ? (<SubstitutionType>source).typeVariable : (<SubstitutionType>source).substitute;
9651
9657
}
9652
9658
if (target.flags & TypeFlags.Substitution) {
9653
- target = (<SubstitutionType>target).typeParameter ;
9659
+ target = (<SubstitutionType>target).typeVariable ;
9654
9660
}
9655
9661
9656
9662
// both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases
0 commit comments