microsoft / microsoft/TypeScript
Variadic tuple constraint incoherent ?
Open
@ahejlsberg is already working on this.
Since Jul 23, 2020.
Awaiting More Feedback
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 4.0.0-dev.20200722
Search Terms:
Variadic tuple
Variadic tuple constraint
Code
type A<GArgs extends [number, string, ...any[]]> = true;
type B<GArgs extends [string, ...any[]]> = A<[number, ...GArgs]>; // ERROR
type C = A<[number, ...[string, ...any[]]]>; // OK
Actual / Expected behavior:
On the type B we get an error:
TS2344: Type '[number, ...GArgs]' does not satisfy the constraint '[number, string, ...any[]]'. Element at index 1 is variadic in one type but not in the other
Sounds incorrect because on B, GArgs is properly shaped to be just like in C
Related Issues:
The variadic issues are a big jungle, and I was not able to find any related issue (but probably some exists?)
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.
Assessment
This issue has not been assessed yet.