From cbf4be508c0d9797dea45449ecd75f6727595d9e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 20 Jan 2023 10:56:05 -0800 Subject: [PATCH 1/2] Add test case for #52271 --- ...substitutionTypePassedToExtends.errors.txt | 21 ++++++++++++ .../substitutionTypePassedToExtends.js | 10 ++++++ .../substitutionTypePassedToExtends.symbols | 32 +++++++++++++++++++ .../substitutionTypePassedToExtends.types | 13 ++++++++ .../substitutionTypePassedToExtends.ts | 7 ++++ 5 files changed, 83 insertions(+) create mode 100644 tests/baselines/reference/substitutionTypePassedToExtends.errors.txt create mode 100644 tests/baselines/reference/substitutionTypePassedToExtends.js create mode 100644 tests/baselines/reference/substitutionTypePassedToExtends.symbols create mode 100644 tests/baselines/reference/substitutionTypePassedToExtends.types create mode 100644 tests/cases/compiler/substitutionTypePassedToExtends.ts diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.errors.txt b/tests/baselines/reference/substitutionTypePassedToExtends.errors.txt new file mode 100644 index 0000000000000..369fed6922b72 --- /dev/null +++ b/tests/baselines/reference/substitutionTypePassedToExtends.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/substitutionTypePassedToExtends.ts(4,16): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +tests/cases/compiler/substitutionTypePassedToExtends.ts(4,31): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +tests/cases/compiler/substitutionTypePassedToExtends.ts(4,53): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. +tests/cases/compiler/substitutionTypePassedToExtends.ts(5,21): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + + +==== tests/cases/compiler/substitutionTypePassedToExtends.ts (4 errors) ==== + type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' + type Bar1 = T + + type Foo2 = Set extends Set ? Bar2> : 'else' + ~~~ +!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + ~~~ +!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + ~~~ +!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + type Bar2> = T + ~~~ +!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. + \ No newline at end of file diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.js b/tests/baselines/reference/substitutionTypePassedToExtends.js new file mode 100644 index 0000000000000..13460c28e5f35 --- /dev/null +++ b/tests/baselines/reference/substitutionTypePassedToExtends.js @@ -0,0 +1,10 @@ +//// [substitutionTypePassedToExtends.ts] +type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' +type Bar1 = T + +type Foo2 = Set extends Set ? Bar2> : 'else' +type Bar2> = T + + +//// [substitutionTypePassedToExtends.js] +"use strict"; diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.symbols b/tests/baselines/reference/substitutionTypePassedToExtends.symbols new file mode 100644 index 0000000000000..f750323cc1b24 --- /dev/null +++ b/tests/baselines/reference/substitutionTypePassedToExtends.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/substitutionTypePassedToExtends.ts === +type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' +>Foo1 : Symbol(Foo1, Decl(substitutionTypePassedToExtends.ts, 0, 0)) +>A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 0, 10)) +>B : Symbol(B, Decl(substitutionTypePassedToExtends.ts, 0, 12)) +>A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 0, 10)) +>B : Symbol(B, Decl(substitutionTypePassedToExtends.ts, 0, 12)) +>Bar1 : Symbol(Bar1, Decl(substitutionTypePassedToExtends.ts, 0, 67)) +>A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 0, 10)) +>B : Symbol(B, Decl(substitutionTypePassedToExtends.ts, 0, 12)) + +type Bar1 = T +>Bar1 : Symbol(Bar1, Decl(substitutionTypePassedToExtends.ts, 0, 67)) +>T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 1, 10)) +>T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 1, 10)) + +type Foo2 = Set extends Set ? Bar2> : 'else' +>Foo2 : Symbol(Foo2, Decl(substitutionTypePassedToExtends.ts, 1, 36)) +>A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) +>Set : Symbol(Set) +>A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) +>Set : Symbol(Set) +>Bar2 : Symbol(Bar2, Decl(substitutionTypePassedToExtends.ts, 3, 68)) +>Set : Symbol(Set) +>A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) + +type Bar2> = T +>Bar2 : Symbol(Bar2, Decl(substitutionTypePassedToExtends.ts, 3, 68)) +>T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 4, 10)) +>Set : Symbol(Set) +>T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 4, 10)) + diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.types b/tests/baselines/reference/substitutionTypePassedToExtends.types new file mode 100644 index 0000000000000..8f3e35f9d7b61 --- /dev/null +++ b/tests/baselines/reference/substitutionTypePassedToExtends.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/substitutionTypePassedToExtends.ts === +type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' +>Foo1 : Foo1 + +type Bar1 = T +>Bar1 : T + +type Foo2 = Set extends Set ? Bar2> : 'else' +>Foo2 : Set + +type Bar2> = T +>Bar2 : T + diff --git a/tests/cases/compiler/substitutionTypePassedToExtends.ts b/tests/cases/compiler/substitutionTypePassedToExtends.ts new file mode 100644 index 0000000000000..0f6918df0d531 --- /dev/null +++ b/tests/cases/compiler/substitutionTypePassedToExtends.ts @@ -0,0 +1,7 @@ +// @strict: true + +type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' +type Bar1 = T + +type Foo2 = Set extends Set ? Bar2> : 'else' +type Bar2> = T From c961ce7f7f0e82677102b616b299bc344cf990f5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:46:44 -0800 Subject: [PATCH 2/2] PR feedback --- ...substitutionTypePassedToExtends.errors.txt | 21 ------------------- .../substitutionTypePassedToExtends.symbols | 8 +++---- .../substitutionTypePassedToExtends.types | 2 +- .../substitutionTypePassedToExtends.ts | 1 + 4 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 tests/baselines/reference/substitutionTypePassedToExtends.errors.txt diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.errors.txt b/tests/baselines/reference/substitutionTypePassedToExtends.errors.txt deleted file mode 100644 index 369fed6922b72..0000000000000 --- a/tests/baselines/reference/substitutionTypePassedToExtends.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/substitutionTypePassedToExtends.ts(4,16): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. -tests/cases/compiler/substitutionTypePassedToExtends.ts(4,31): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. -tests/cases/compiler/substitutionTypePassedToExtends.ts(4,53): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. -tests/cases/compiler/substitutionTypePassedToExtends.ts(5,21): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. - - -==== tests/cases/compiler/substitutionTypePassedToExtends.ts (4 errors) ==== - type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' - type Bar1 = T - - type Foo2 = Set extends Set ? Bar2> : 'else' - ~~~ -!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. - ~~~ -!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. - ~~~ -!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. - type Bar2> = T - ~~~ -!!! error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. - \ No newline at end of file diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.symbols b/tests/baselines/reference/substitutionTypePassedToExtends.symbols index f750323cc1b24..b4ff138a915b9 100644 --- a/tests/baselines/reference/substitutionTypePassedToExtends.symbols +++ b/tests/baselines/reference/substitutionTypePassedToExtends.symbols @@ -17,16 +17,16 @@ type Bar1 = T type Foo2 = Set extends Set ? Bar2> : 'else' >Foo2 : Symbol(Foo2, Decl(substitutionTypePassedToExtends.ts, 1, 36)) >A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) ->Set : Symbol(Set) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) ->Set : Symbol(Set) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Bar2 : Symbol(Bar2, Decl(substitutionTypePassedToExtends.ts, 3, 68)) ->Set : Symbol(Set) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >A : Symbol(A, Decl(substitutionTypePassedToExtends.ts, 3, 10)) type Bar2> = T >Bar2 : Symbol(Bar2, Decl(substitutionTypePassedToExtends.ts, 3, 68)) >T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 4, 10)) ->Set : Symbol(Set) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >T : Symbol(T, Decl(substitutionTypePassedToExtends.ts, 4, 10)) diff --git a/tests/baselines/reference/substitutionTypePassedToExtends.types b/tests/baselines/reference/substitutionTypePassedToExtends.types index 8f3e35f9d7b61..80ed20dfc5fd0 100644 --- a/tests/baselines/reference/substitutionTypePassedToExtends.types +++ b/tests/baselines/reference/substitutionTypePassedToExtends.types @@ -6,7 +6,7 @@ type Bar1 = T >Bar1 : T type Foo2 = Set extends Set ? Bar2> : 'else' ->Foo2 : Set +>Foo2 : Foo2 type Bar2> = T >Bar2 : T diff --git a/tests/cases/compiler/substitutionTypePassedToExtends.ts b/tests/cases/compiler/substitutionTypePassedToExtends.ts index 0f6918df0d531..e969208e5a0f9 100644 --- a/tests/cases/compiler/substitutionTypePassedToExtends.ts +++ b/tests/cases/compiler/substitutionTypePassedToExtends.ts @@ -1,4 +1,5 @@ // @strict: true +// @target: esnext type Foo1 = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else' type Bar1 = T