Skip to content

Commit

Permalink
Add test case for microsoft#52271
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Jan 20, 2023
1 parent f526e16 commit cbf4be5
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
@@ -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> = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else'
type Bar1<T extends unknown[][]> = T

type Foo2<A> = Set<A> extends Set<unknown[]> ? Bar2<Set<A>> : '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 extends Set<unknown[]>> = 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.

10 changes: 10 additions & 0 deletions tests/baselines/reference/substitutionTypePassedToExtends.js
@@ -0,0 +1,10 @@
//// [substitutionTypePassedToExtends.ts]
type Foo1<A,B> = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else'
type Bar1<T extends unknown[][]> = T

type Foo2<A> = Set<A> extends Set<unknown[]> ? Bar2<Set<A>> : 'else'
type Bar2<T extends Set<unknown[]>> = T


//// [substitutionTypePassedToExtends.js]
"use strict";
32 changes: 32 additions & 0 deletions tests/baselines/reference/substitutionTypePassedToExtends.symbols
@@ -0,0 +1,32 @@
=== tests/cases/compiler/substitutionTypePassedToExtends.ts ===
type Foo1<A,B> = [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 extends unknown[][]> = 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<A> = Set<A> extends Set<unknown[]> ? Bar2<Set<A>> : '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 extends Set<unknown[]>> = 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))

13 changes: 13 additions & 0 deletions tests/baselines/reference/substitutionTypePassedToExtends.types
@@ -0,0 +1,13 @@
=== tests/cases/compiler/substitutionTypePassedToExtends.ts ===
type Foo1<A,B> = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else'
>Foo1 : Foo1<A, B>

type Bar1<T extends unknown[][]> = T
>Bar1 : T

type Foo2<A> = Set<A> extends Set<unknown[]> ? Bar2<Set<A>> : 'else'
>Foo2 : Set<A>

type Bar2<T extends Set<unknown[]>> = T
>Bar2 : T

7 changes: 7 additions & 0 deletions tests/cases/compiler/substitutionTypePassedToExtends.ts
@@ -0,0 +1,7 @@
// @strict: true

type Foo1<A,B> = [A, B] extends unknown[][] ? Bar1<[A, B]> : 'else'
type Bar1<T extends unknown[][]> = T

type Foo2<A> = Set<A> extends Set<unknown[]> ? Bar2<Set<A>> : 'else'
type Bar2<T extends Set<unknown[]>> = T

0 comments on commit cbf4be5

Please sign in to comment.