microsoft / microsoft/TypeScript
Variadic tuple constraint incoherent ?
Offen
@ahejlsberg arbeitet bereits daran.
Seit 23.7.2020.
Awaiting More Feedback
Suggestion
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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?)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.