@@ -4001,8 +4001,7 @@ namespace ts {
4001
4001
concatenate((<TypeReference>type).typeArguments, [thisArgument || (<TypeReference>type).target.thisType]));
4002
4002
}
4003
4003
if (type.flags & TypeFlags.Tuple) {
4004
- resolveTupleTypeMembers(type as TupleType, thisArgument);
4005
- return type;
4004
+ return createTupleType((type as TupleType).elementTypes, thisArgument);
4006
4005
}
4007
4006
return type;
4008
4007
}
@@ -4104,11 +4103,11 @@ namespace ts {
4104
4103
return members;
4105
4104
}
4106
4105
4107
- function resolveTupleTypeMembers(type: TupleType, thisArgument?: Type ) {
4106
+ function resolveTupleTypeMembers(type: TupleType) {
4108
4107
const arrayElementType = getUnionType(type.elementTypes);
4109
4108
// Make the tuple type itself the 'this' type by including an extra type argument
4110
4109
// (Unless it's provided in the case that the tuple is a type parameter constraint)
4111
- const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, thisArgument || type]));
4110
+ const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type.thisType || type]));
4112
4111
const members = createTupleTypeMemberSymbols(type.elementTypes);
4113
4112
addInheritedMembers(members, arrayType.properties);
4114
4113
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo);
@@ -5235,15 +5234,20 @@ namespace ts {
5235
5234
return links.resolvedType;
5236
5235
}
5237
5236
5238
- function createTupleType(elementTypes: Type[]) {
5239
- const id = getTypeListId(elementTypes);
5240
- return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
5237
+ function createTupleType(elementTypes: Type[], thisType?: Type) {
5238
+ let id = getTypeListId(elementTypes);
5239
+ if (thisType) {
5240
+ id += ',' + thisType.id;
5241
+ }
5242
+
5243
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes, thisType));
5241
5244
}
5242
5245
5243
- function createNewTupleType(elementTypes: Type[]) {
5246
+ function createNewTupleType(elementTypes: Type[], thisType?: Type ) {
5244
5247
const propagatedFlags = getPropagatingFlagsOfTypes(elementTypes, /*excludeKinds*/ 0);
5245
5248
const type = <TupleType>createObjectType(TypeFlags.Tuple | propagatedFlags);
5246
5249
type.elementTypes = elementTypes;
5250
+ type.thisType = thisType;
5247
5251
return type;
5248
5252
}
5249
5253
0 commit comments