-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15011 from Microsoft/limitDeepInstantiations
Limit deep generic type instantiations
- Loading branch information
Showing
5 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/limitDeepInstantiations.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2550: Generic type instantiation is excessively deep and possibly infinite. | ||
tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. | ||
|
||
|
||
==== tests/cases/compiler/limitDeepInstantiations.ts (2 errors) ==== | ||
// Repro from #14837 | ||
|
||
type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T]; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2550: Generic type instantiation is excessively deep and possibly infinite. | ||
let f1: Foo<"true", {}>; | ||
let f2: Foo<"false", {}>; | ||
~~~~~~~ | ||
!!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//// [limitDeepInstantiations.ts] | ||
// Repro from #14837 | ||
|
||
type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T]; | ||
let f1: Foo<"true", {}>; | ||
let f2: Foo<"false", {}>; | ||
|
||
|
||
//// [limitDeepInstantiations.js] | ||
// Repro from #14837 | ||
var f1; | ||
var f2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Repro from #14837 | ||
|
||
type Foo<T extends "true", B> = { "true": Foo<T, Foo<T, B>> }[T]; | ||
let f1: Foo<"true", {}>; | ||
let f2: Foo<"false", {}>; |