Skip to content

Commit 68ab129

Browse files
committed
Add regression test
1 parent 6909574 commit 68ab129

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2550: Generic type instantiation is excessively deep and possibly infinite.
2+
tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'.
3+
4+
5+
==== tests/cases/compiler/limitDeepInstantiations.ts (2 errors) ====
6+
// Repro from #14837
7+
8+
type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T];
9+
~~~~~~~~~~~~~~~~~~~~~~~~~
10+
!!! error TS2550: Generic type instantiation is excessively deep and possibly infinite.
11+
let f1: Foo<"true", {}>;
12+
let f2: Foo<"false", {}>;
13+
~~~~~~~
14+
!!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'.
15+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [limitDeepInstantiations.ts]
2+
// Repro from #14837
3+
4+
type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T];
5+
let f1: Foo<"true", {}>;
6+
let f2: Foo<"false", {}>;
7+
8+
9+
//// [limitDeepInstantiations.js]
10+
// Repro from #14837
11+
var f1;
12+
var f2;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Repro from #14837
2+
3+
type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T];
4+
let f1: Foo<"true", {}>;
5+
let f2: Foo<"false", {}>;

0 commit comments

Comments
 (0)