microsoft / microsoft/TypeScript

Variadic tuple constraint incoherent ?

Aperta
#39,713 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@ahejlsberg ci sta già lavorando.

Dal 23/7/2020.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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

Playground Link

Related Issues:

The variadic issues are a big jungle, and I was not able to find any related issue (but probably some exists?)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.