From df695d9adb838785a10e1c354596c0e39da71847 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 31 Jul 2023 16:38:40 -0700 Subject: [PATCH 1/9] Remove reportErrors check in relateVariances --- src/compiler/checker.ts | 18 +++- tests/baselines/reference/issue55217.js | 45 ++++++++++ tests/baselines/reference/issue55217.symbols | 91 ++++++++++++++++++++ tests/baselines/reference/issue55217.types | 61 +++++++++++++ tests/cases/compiler/issue55217.ts | 31 +++++++ 5 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/issue55217.js create mode 100644 tests/baselines/reference/issue55217.symbols create mode 100644 tests/baselines/reference/issue55217.types create mode 100644 tests/cases/compiler/issue55217.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f24cb91da6394..d7de07417c9e6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2206,6 +2206,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var identityRelation = new Map(); var enumRelation = new Map(); + // function relationName(relation: Map): string { + // if (relation === subtypeRelation) return "subtype"; + // if (relation === strictSubtypeRelation) return "strict subtype"; + // if (relation === assignableRelation) return "assignable"; + // if (relation === comparableRelation) return "comparable"; + // if (relation === identityRelation) return "identity"; + // if (relation === enumRelation) return "enum"; + // Debug.fail("Unknown relation"); + // } + // (globalThis as any).__relationName = relationName; + var builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); @@ -21286,6 +21297,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { tracing?.pop(); } + // if (entry !== undefined) { + // // If the previous entry and the result disagree, then something has gone wrong. + // Debug.assert(!!(entry & RelationComparisonResult.Succeeded) === (result !== Ternary.False), "Cached relationship does not match recalculated result"); + // } + if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } @@ -21951,7 +21967,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && some(variances, v => (v & VarianceFlags.VarianceMask) === VarianceFlags.Invariant))) { + if (varianceCheckFailed && !(some(variances, v => (v & VarianceFlags.VarianceMask) === VarianceFlags.Invariant))) { return Ternary.False; } // We remember the original error information so we can restore it in case the structural diff --git a/tests/baselines/reference/issue55217.js b/tests/baselines/reference/issue55217.js new file mode 100644 index 0000000000000..c67a229237da6 --- /dev/null +++ b/tests/baselines/reference/issue55217.js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/issue55217.ts] //// + +//// [types.ts] +export type ProductName = 'a' | 'b' + +export type SubproductNameForProductName

= P extends unknown + ? keyof EntitiesByProductName[P] + : never + +type EntitiesByProductName = { + a: { a1: { value: 'a-a1' } } + b: { b1: { value: 'b-b1' } } +} + +export type DiscriminatedUnion< + P extends ProductName = ProductName, + E extends SubproductNameForProductName

= SubproductNameForProductName

, +> = P extends ProductName + ? E extends SubproductNameForProductName

+ // ? E extends unknown // With unknown, the exception doesn't happen. + ? EntitiesByProductName[P][E] + : never + : never + +//// [app.ts] +import { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types' + +export const bug =

() => { + const subproducts: DiscriminatedUnion>[] = [] + subproducts.map((_: DiscriminatedUnion) => null) +} + + +//// [types.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [app.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bug = void 0; +var bug = function () { + var subproducts = []; + subproducts.map(function (_) { return null; }); +}; +exports.bug = bug; diff --git a/tests/baselines/reference/issue55217.symbols b/tests/baselines/reference/issue55217.symbols new file mode 100644 index 0000000000000..24711a7693320 --- /dev/null +++ b/tests/baselines/reference/issue55217.symbols @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/issue55217.ts] //// + +=== types.ts === +export type ProductName = 'a' | 'b' +>ProductName : Symbol(ProductName, Decl(types.ts, 0, 0)) + +export type SubproductNameForProductName

= P extends unknown +>SubproductNameForProductName : Symbol(SubproductNameForProductName, Decl(types.ts, 0, 35)) +>P : Symbol(P, Decl(types.ts, 2, 41)) +>ProductName : Symbol(ProductName, Decl(types.ts, 0, 0)) +>P : Symbol(P, Decl(types.ts, 2, 41)) + + ? keyof EntitiesByProductName[P] +>EntitiesByProductName : Symbol(EntitiesByProductName, Decl(types.ts, 4, 9)) +>P : Symbol(P, Decl(types.ts, 2, 41)) + + : never + +type EntitiesByProductName = { +>EntitiesByProductName : Symbol(EntitiesByProductName, Decl(types.ts, 4, 9)) + + a: { a1: { value: 'a-a1' } } +>a : Symbol(a, Decl(types.ts, 6, 30)) +>a1 : Symbol(a1, Decl(types.ts, 7, 6)) +>value : Symbol(value, Decl(types.ts, 7, 12)) + + b: { b1: { value: 'b-b1' } } +>b : Symbol(b, Decl(types.ts, 7, 30)) +>b1 : Symbol(b1, Decl(types.ts, 8, 6)) +>value : Symbol(value, Decl(types.ts, 8, 12)) +} + +export type DiscriminatedUnion< +>DiscriminatedUnion : Symbol(DiscriminatedUnion, Decl(types.ts, 9, 1)) + + P extends ProductName = ProductName, +>P : Symbol(P, Decl(types.ts, 11, 31)) +>ProductName : Symbol(ProductName, Decl(types.ts, 0, 0)) +>ProductName : Symbol(ProductName, Decl(types.ts, 0, 0)) + + E extends SubproductNameForProductName

= SubproductNameForProductName

, +>E : Symbol(E, Decl(types.ts, 12, 38)) +>SubproductNameForProductName : Symbol(SubproductNameForProductName, Decl(types.ts, 0, 35)) +>P : Symbol(P, Decl(types.ts, 11, 31)) +>SubproductNameForProductName : Symbol(SubproductNameForProductName, Decl(types.ts, 0, 35)) +>P : Symbol(P, Decl(types.ts, 11, 31)) + +> = P extends ProductName +>P : Symbol(P, Decl(types.ts, 11, 31)) +>ProductName : Symbol(ProductName, Decl(types.ts, 0, 0)) + + ? E extends SubproductNameForProductName

+>E : Symbol(E, Decl(types.ts, 12, 38)) +>SubproductNameForProductName : Symbol(SubproductNameForProductName, Decl(types.ts, 0, 35)) +>P : Symbol(P, Decl(types.ts, 11, 31)) + + // ? E extends unknown // With unknown, the exception doesn't happen. + ? EntitiesByProductName[P][E] +>EntitiesByProductName : Symbol(EntitiesByProductName, Decl(types.ts, 4, 9)) +>P : Symbol(P, Decl(types.ts, 11, 31)) +>E : Symbol(E, Decl(types.ts, 12, 38)) + + : never + : never + +=== app.ts === +import { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types' +>SubproductNameForProductName : Symbol(SubproductNameForProductName, Decl(app.ts, 0, 8)) +>DiscriminatedUnion : Symbol(DiscriminatedUnion, Decl(app.ts, 0, 38)) +>ProductName : Symbol(ProductName, Decl(app.ts, 0, 58)) + +export const bug =

() => { +>bug : Symbol(bug, Decl(app.ts, 2, 12)) +>P : Symbol(P, Decl(app.ts, 2, 20)) +>ProductName : Symbol(ProductName, Decl(app.ts, 0, 58)) + + const subproducts: DiscriminatedUnion>[] = [] +>subproducts : Symbol(subproducts, Decl(app.ts, 3, 7)) +>DiscriminatedUnion : Symbol(DiscriminatedUnion, Decl(app.ts, 0, 38)) +>P : Symbol(P, Decl(app.ts, 2, 20)) +>SubproductNameForProductName : Symbol(SubproductNameForProductName, Decl(app.ts, 0, 8)) +>P : Symbol(P, Decl(app.ts, 2, 20)) + + subproducts.map((_: DiscriminatedUnion) => null) +>subproducts.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>subproducts : Symbol(subproducts, Decl(app.ts, 3, 7)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>_ : Symbol(_, Decl(app.ts, 4, 19)) +>DiscriminatedUnion : Symbol(DiscriminatedUnion, Decl(app.ts, 0, 38)) +} + diff --git a/tests/baselines/reference/issue55217.types b/tests/baselines/reference/issue55217.types new file mode 100644 index 0000000000000..a20c13ec7c819 --- /dev/null +++ b/tests/baselines/reference/issue55217.types @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/issue55217.ts] //// + +=== types.ts === +export type ProductName = 'a' | 'b' +>ProductName : "a" | "b" + +export type SubproductNameForProductName

= P extends unknown +>SubproductNameForProductName : SubproductNameForProductName

+ + ? keyof EntitiesByProductName[P] + : never + +type EntitiesByProductName = { +>EntitiesByProductName : { a: { a1: { value: 'a-a1'; };}; b: { b1: { value: 'b-b1'; };}; } + + a: { a1: { value: 'a-a1' } } +>a : { a1: { value: 'a-a1';}; } +>a1 : { value: 'a-a1'; } +>value : "a-a1" + + b: { b1: { value: 'b-b1' } } +>b : { b1: { value: 'b-b1';}; } +>b1 : { value: 'b-b1'; } +>value : "b-b1" +} + +export type DiscriminatedUnion< +>DiscriminatedUnion : DiscriminatedUnion + + P extends ProductName = ProductName, + E extends SubproductNameForProductName

= SubproductNameForProductName

, +> = P extends ProductName + ? E extends SubproductNameForProductName

+ // ? E extends unknown // With unknown, the exception doesn't happen. + ? EntitiesByProductName[P][E] + : never + : never + +=== app.ts === +import { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types' +>SubproductNameForProductName : any +>DiscriminatedUnion : any +>ProductName : any + +export const bug =

() => { +>bug :

() => void +>

() => { const subproducts: DiscriminatedUnion>[] = [] subproducts.map((_: DiscriminatedUnion) => null)} :

() => void + + const subproducts: DiscriminatedUnion>[] = [] +>subproducts : DiscriminatedUnion>[] +>[] : never[] + + subproducts.map((_: DiscriminatedUnion) => null) +>subproducts.map((_: DiscriminatedUnion) => null) : null[] +>subproducts.map : (callbackfn: (value: DiscriminatedUnion>, index: number, array: DiscriminatedUnion>[]) => U, thisArg?: any) => U[] +>subproducts : DiscriminatedUnion>[] +>map : (callbackfn: (value: DiscriminatedUnion>, index: number, array: DiscriminatedUnion>[]) => U, thisArg?: any) => U[] +>(_: DiscriminatedUnion) => null : (_: DiscriminatedUnion) => null +>_ : DiscriminatedUnion +} + diff --git a/tests/cases/compiler/issue55217.ts b/tests/cases/compiler/issue55217.ts new file mode 100644 index 0000000000000..c94786b221415 --- /dev/null +++ b/tests/cases/compiler/issue55217.ts @@ -0,0 +1,31 @@ +// @strict: true + +// @filename: types.ts +export type ProductName = 'a' | 'b' + +export type SubproductNameForProductName

= P extends unknown + ? keyof EntitiesByProductName[P] + : never + +type EntitiesByProductName = { + a: { a1: { value: 'a-a1' } } + b: { b1: { value: 'b-b1' } } +} + +export type DiscriminatedUnion< + P extends ProductName = ProductName, + E extends SubproductNameForProductName

= SubproductNameForProductName

, +> = P extends ProductName + ? E extends SubproductNameForProductName

+ // ? E extends unknown // With unknown, the exception doesn't happen. + ? EntitiesByProductName[P][E] + : never + : never + +// @filename: app.ts +import { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types' + +export const bug =

() => { + const subproducts: DiscriminatedUnion>[] = [] + subproducts.map((_: DiscriminatedUnion) => null) +} From 59020188c759576c1212fcfc9a213bcdd5436ca9 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 31 Jul 2023 16:42:47 -0700 Subject: [PATCH 2/9] Remove my helper because why not --- src/compiler/checker.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d7de07417c9e6..193031e32be1b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2206,17 +2206,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var identityRelation = new Map(); var enumRelation = new Map(); - // function relationName(relation: Map): string { - // if (relation === subtypeRelation) return "subtype"; - // if (relation === strictSubtypeRelation) return "strict subtype"; - // if (relation === assignableRelation) return "assignable"; - // if (relation === comparableRelation) return "comparable"; - // if (relation === identityRelation) return "identity"; - // if (relation === enumRelation) return "enum"; - // Debug.fail("Unknown relation"); - // } - // (globalThis as any).__relationName = relationName; - var builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); From d8b12a7a35ab9d5aa629573de47dfc986d75f883 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:22:40 -0700 Subject: [PATCH 3/9] Remove paren --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b569f8202dda9..666807f38ce09 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22372,7 +22372,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(some(variances, v => (v & VarianceFlags.VarianceMask) === VarianceFlags.Invariant))) { + if (varianceCheckFailed && !some(variances, v => (v & VarianceFlags.VarianceMask) === VarianceFlags.Invariant)) { return Ternary.False; } // We remember the original error information so we can restore it in case the structural From 540f073561ba27f121ea95b00b6a83a912bfbfdf Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:34:57 -0700 Subject: [PATCH 4/9] Uncomment check --- src/compiler/checker.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 666807f38ce09..57826eed801c1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21672,10 +21672,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { tracing?.pop(); } - // if (entry !== undefined) { - // // If the previous entry and the result disagree, then something has gone wrong. - // Debug.assert(!!(entry & RelationComparisonResult.Succeeded) === (result !== Ternary.False), "Cached relationship does not match recalculated result"); - // } + if (entry !== undefined) { + // If the previous entry and the result disagree, then something has gone wrong. + const entrySucceeded = !!(entry & RelationComparisonResult.Succeeded); + const resultSucceeded = result !== Ternary.False; + Debug.assertEqual(entrySucceeded, resultSucceeded, "Cached relationship does not match recalculated result"); + } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; From 2ef27bc8cefc015b205e3f50b06e55a072bdbf8b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:44:58 -0700 Subject: [PATCH 5/9] Comment out check for perf retesting --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 57826eed801c1..ba691bd8ef4a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21672,12 +21672,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { tracing?.pop(); } - if (entry !== undefined) { - // If the previous entry and the result disagree, then something has gone wrong. - const entrySucceeded = !!(entry & RelationComparisonResult.Succeeded); - const resultSucceeded = result !== Ternary.False; - Debug.assertEqual(entrySucceeded, resultSucceeded, "Cached relationship does not match recalculated result"); - } + // if (entry !== undefined) { + // // If the previous entry and the result disagree, then something has gone wrong. + // const entrySucceeded = !!(entry & RelationComparisonResult.Succeeded); + // const resultSucceeded = result !== Ternary.False; + // Debug.assertEqual(entrySucceeded, resultSucceeded, "Cached relationship does not match recalculated result"); + // } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; From bc5ef36a7457ce1ebbbc401a9395c5bf85fcc333 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 26 Jun 2024 21:56:56 -0700 Subject: [PATCH 6/9] Baselines --- tests/baselines/reference/issue55217.types | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/issue55217.types b/tests/baselines/reference/issue55217.types index a20c13ec7c819..e798f0cbd93a7 100644 --- a/tests/baselines/reference/issue55217.types +++ b/tests/baselines/reference/issue55217.types @@ -2,30 +2,40 @@ === types.ts === export type ProductName = 'a' | 'b' ->ProductName : "a" | "b" +>ProductName : ProductName +> : ^^^^^^^^^^^ export type SubproductNameForProductName

= P extends unknown >SubproductNameForProductName : SubproductNameForProductName

+> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ? keyof EntitiesByProductName[P] : never type EntitiesByProductName = { ->EntitiesByProductName : { a: { a1: { value: 'a-a1'; };}; b: { b1: { value: 'b-b1'; };}; } +>EntitiesByProductName : EntitiesByProductName +> : ^^^^^^^^^^^^^^^^^^^^^ a: { a1: { value: 'a-a1' } } ->a : { a1: { value: 'a-a1';}; } ->a1 : { value: 'a-a1'; } +>a : { a1: { value: "a-a1"; }; } +> : ^^^^^^ ^^^ +>a1 : { value: "a-a1"; } +> : ^^^^^^^^^ ^^^ >value : "a-a1" +> : ^^^^^^ b: { b1: { value: 'b-b1' } } ->b : { b1: { value: 'b-b1';}; } ->b1 : { value: 'b-b1'; } +>b : { b1: { value: "b-b1"; }; } +> : ^^^^^^ ^^^ +>b1 : { value: "b-b1"; } +> : ^^^^^^^^^ ^^^ >value : "b-b1" +> : ^^^^^^ } export type DiscriminatedUnion< >DiscriminatedUnion : DiscriminatedUnion +> : ^^^^^^^^^^^^^^^^^^^^^^^^ P extends ProductName = ProductName, E extends SubproductNameForProductName

= SubproductNameForProductName

, @@ -39,23 +49,36 @@ export type DiscriminatedUnion< === app.ts === import { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types' >SubproductNameForProductName : any +> : ^^^ >DiscriminatedUnion : any +> : ^^^ >ProductName : any +> : ^^^ export const bug =

() => { >bug :

() => void +> : ^ ^^^^^^^^^ ^^^^^^^^^^^ >

() => { const subproducts: DiscriminatedUnion>[] = [] subproducts.map((_: DiscriminatedUnion) => null)} :

() => void +> : ^ ^^^^^^^^^ ^^^^^^^^^^^ const subproducts: DiscriminatedUnion>[] = [] >subproducts : DiscriminatedUnion>[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >[] : never[] +> : ^^^^^^^ subproducts.map((_: DiscriminatedUnion) => null) >subproducts.map((_: DiscriminatedUnion) => null) : null[] +> : ^^^^^^ >subproducts.map : (callbackfn: (value: DiscriminatedUnion>, index: number, array: DiscriminatedUnion>[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^ >subproducts : DiscriminatedUnion>[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >map : (callbackfn: (value: DiscriminatedUnion>, index: number, array: DiscriminatedUnion>[]) => U, thisArg?: any) => U[] +> : ^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^ >(_: DiscriminatedUnion) => null : (_: DiscriminatedUnion) => null +> : ^ ^^ ^^^^^^^^^ >_ : DiscriminatedUnion +> : ^^^^^^^^^^^^^^^^^^ } From 849a6665161aecdca8dd09a2f844af126d0bb796 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 26 Jun 2024 22:01:44 -0700 Subject: [PATCH 7/9] Baselines --- .../reference/conditionalTypeDoesntSpinForever.types | 5 +++-- .../styledComponentsInstantiaionLimitNotReached.types | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types index 73fb1f2d6e19d..529ca4c2247e5 100644 --- a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types +++ b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types @@ -1,8 +1,9 @@ //// [tests/cases/compiler/conditionalTypeDoesntSpinForever.ts] //// === Performance Stats === -Type Count: 1,000 -Instantiation count: 2,500 -> 5,000 +Assignability cache: 1,000 +Type Count: 2,500 +Instantiation count: 5,000 === conditionalTypeDoesntSpinForever.ts === // A *self-contained* demonstration of the problem follows... diff --git a/tests/baselines/reference/styledComponentsInstantiaionLimitNotReached.types b/tests/baselines/reference/styledComponentsInstantiaionLimitNotReached.types index 4aebbfa368533..ece3f14b2679c 100644 --- a/tests/baselines/reference/styledComponentsInstantiaionLimitNotReached.types +++ b/tests/baselines/reference/styledComponentsInstantiaionLimitNotReached.types @@ -3,7 +3,7 @@ === Performance Stats === Assignability cache: 10,000 Type Count: 25,000 -Instantiation count: 250,000 -> 500,000 +Instantiation count: 500,000 Symbol count: 100,000 === styledComponentsInstantiaionLimitNotReached.ts === From 7228909cdfd2966d6bf8c66e2b3fce5b4cce3427 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 26 Jun 2024 22:05:33 -0700 Subject: [PATCH 8/9] Remove comment --- src/compiler/checker.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9b32b4018b174..0158a98b54bc8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23389,7 +23389,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // types are invariant, if any of the type parameters are invariant we reset the reported // errors and instead force a structural comparison (which will include elaborations that // reveal the reason). - // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. if (varianceCheckFailed && !some(variances, v => (v & VarianceFlags.VarianceMask) === VarianceFlags.Invariant)) { return Ternary.False; From 54c0e759fbcfc47a40c309a10268c7327069a374 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 5 Dec 2025 09:57:05 -0800 Subject: [PATCH 9/9] Enable consistency check --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e569fc8814232..965bd5c7b4229 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23344,12 +23344,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { tracing?.pop(); } - // if (entry !== undefined) { - // // If the previous entry and the result disagree, then something has gone wrong. - // const entrySucceeded = !!(entry & RelationComparisonResult.Succeeded); - // const resultSucceeded = result !== Ternary.False; - // Debug.assertEqual(entrySucceeded, resultSucceeded, "Cached relationship does not match recalculated result"); - // } + if (entry !== undefined) { + // If the previous entry and the result disagree, then something has gone wrong. + const entrySucceeded = !!(entry & RelationComparisonResult.Succeeded); + const resultSucceeded = result !== Ternary.False; + Debug.assertEqual(entrySucceeded, resultSucceeded, "Cached relationship does not match recalculated result"); + } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler;