@@ -5364,7 +5364,7 @@ namespace ts {
5364
5364
return <InterfaceTypeWithDeclaredMembers>type;
5365
5365
}
5366
5366
5367
- function getTypeWithThisArgument(type: Type, thisArgument? : Type): Type {
5367
+ function getTypeWithThisArgument(type: Type, thisArgument: Type): Type {
5368
5368
if (getObjectFlags(type) & ObjectFlags.Reference) {
5369
5369
const target = (<TypeReference>type).target;
5370
5370
const typeArguments = (<TypeReference>type).typeArguments;
@@ -8830,6 +8830,8 @@ namespace ts {
8830
8830
let sourceStack: Type[];
8831
8831
let targetStack: Type[];
8832
8832
let maybeCount = 0;
8833
+ let maybeReferenceKeys: string[];
8834
+ let maybeReferenceCount = 0;
8833
8835
let depth = 0;
8834
8836
let expandingFlags = 0;
8835
8837
let overflow = false;
@@ -9197,6 +9199,30 @@ namespace ts {
9197
9199
if (overflow) {
9198
9200
return Ternary.False;
9199
9201
}
9202
+
9203
+ if (getObjectFlags(source) & ObjectFlags.Reference &&
9204
+ getObjectFlags(target) & ObjectFlags.Reference &&
9205
+ (source as TypeReference).typeArguments && (source as TypeReference).typeArguments.length > 0 &&
9206
+ arrayIsEqualTo((source as TypeReference).typeArguments, (target as TypeReference).typeArguments, (a1, m1) => a1 === m1)) {
9207
+ // Same type arguments, let's see if we've already seen this pair before
9208
+ // this is a copy of the normal code! It can probably be merged somehow.
9209
+ const src = (source as TypeReference).target;
9210
+ const trg = (target as TypeReference).target;
9211
+ const id = relation !== identityRelation || src.id < trg.id ? src.id + "," + trg.id : trg.id + "," + src.id;
9212
+ if (!maybeReferenceKeys) {
9213
+ maybeReferenceKeys = [];
9214
+ }
9215
+ else {
9216
+ for (let i = 0; i < maybeReferenceCount; i++) {
9217
+ if (id === maybeReferenceKeys[i]) {
9218
+ return Ternary.Maybe;
9219
+ }
9220
+ }
9221
+ }
9222
+ maybeReferenceKeys[maybeReferenceCount] = id;
9223
+ maybeReferenceCount++;
9224
+ }
9225
+
9200
9226
const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
9201
9227
const related = relation.get(id);
9202
9228
if (related !== undefined) {
@@ -9209,6 +9235,7 @@ namespace ts {
9209
9235
return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
9210
9236
}
9211
9237
}
9238
+
9212
9239
if (!maybeKeys) {
9213
9240
maybeKeys = [];
9214
9241
sourceStack = [];
@@ -21258,7 +21285,7 @@ namespace ts {
21258
21285
checkExportsOnMergedDeclarations(node);
21259
21286
const symbol = getSymbolOfNode(node);
21260
21287
const type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
21261
- const typeWithThis = getTypeWithThisArgument(type);
21288
+ const typeWithThis = getTypeWithThisArgument(type, type.thisType );
21262
21289
const staticType = <ObjectType>getTypeOfSymbol(symbol);
21263
21290
checkTypeParameterListsIdentical(symbol);
21264
21291
checkClassForDuplicateDeclarations(node);
@@ -21506,7 +21533,7 @@ namespace ts {
21506
21533
const firstInterfaceDecl = getDeclarationOfKind<InterfaceDeclaration>(symbol, SyntaxKind.InterfaceDeclaration);
21507
21534
if (node === firstInterfaceDecl) {
21508
21535
const type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
21509
- const typeWithThis = getTypeWithThisArgument(type);
21536
+ const typeWithThis = getTypeWithThisArgument(type, type.thisType );
21510
21537
// run subsequent checks only if first set succeeded
21511
21538
if (checkInheritedPropertiesAreIdentical(type, node.name)) {
21512
21539
for (const baseType of getBaseTypes(type)) {
0 commit comments