microsoft / microsoft/TypeScript
Treatment of recursive tuples that utilize type spread.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 4.0.2
Search Terms: spread tuple in recursive tuple type
Code
I'm trying to model a type that could evaluate to any of the following:
["list", "of", "Post"];
["list", "of", "list", "of", "Post"];
["list", "of", "list", "of", "list", "of", "Post"];
// ... could go on
The following approach produces a circularity error, even though tuple types are circularity-capable since 3.7 :/
type Nested = ["list", "of", ...(["Post"] | Nested)];
Expected behavior:
To be able to type-check the following (for example):
const nested: Nested = ["list", "of", "list", "of", "Post"];
Actual behavior:
Circularity error.
Any help would be greatly appreciated! Thank you!
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
No source file or test is named. Start by reproducing the circularity error with the provided TypeScript 4.0.2 recursive tuple example, then trace the type-checker handling for recursive tuple types and type spreads. Done means the sample declaration and nested value type-check without the circularity error, with coverage added in the appropriate compiler test area.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100