microsoft / microsoft/TypeScript
Infinite type instantiation around recursive conditional types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
infinite type instantiation excessively deep recursive conditional
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about infinite and recursive types.
⏯ Playground Link
💻 Code
type A<Q, S> = Q extends { a: any } ? A<Q["a"], S> : never;
interface B<T> {
f<Q>(q: Q): A<Q, T>;
}
type C = B<{}> extends B<infer X> ? X : never;
type X = C extends any ? true : false;
// ~ Type instantiation is excessively deep and possibly infinite.(2589)
🙁 Actual behavior
The last line errors out.
🙂 Expected behavior
The code should pass the type check.
Additional information about the issue
An alternative way to get the same error: https://www.typescriptlang.org/play/?ts=5.6.3#code/C4TwDgpgBAggPARQDRQMoD4oF4oKhAD2AgDsATAZygG8oBDALnpJCgF8oB+WRAbQCI6-ALooMUJiQgA3CACcA3ACglASxLE5AMzoBjaACE4AFUzUlUKFsToAFAEcmCAJRN4yKKeVsVZCLoAbOjloLQBXEl1gVQB7EigAWzoAawgjU1tgJmNXKHT0ZSU-QODQiKjY+OsMrM9c6RjVMkLrI2o2dDsk1INbEjCAgPoqOhZhmjZnZ2UgA
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript Playground reproducer and confirm the excessive-instantiation error on the final conditional type. No repository file or test is identified in the issue; done means the provided code type-checks without error while recursive conditional-type behavior remains covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100