microsoft / microsoft/TypeScript
A[] form works, but Array<A> breaks
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
🔎 Search Terms
site:github.com inurl:/microsoft/TypeScript/issues/ Array [] normalization syntactic sugar
🕗 Version & Regression Information
This works in 3.9.7, broke in 4.0.5, and remains broken in Nightly.
- This changed between versions 3.9.7 and 4.0.5
⏯ Playground Link
Playground link with relevant code
💻 Code
type R<C> = [C, ...R<C>[]] | number; // works, as expected
type S<C> = [C, ...Array<S<C>>] | number; // fails unexpectedly - should work identically
const r: R<"add"> = ["add", 2, 1];
const s: S<"add"> = ["add", 2, 1];
🙁 Actual behavior
The A[] form in the first line works, but the otherwise-identical Array<…> form on the second line breaks with the warning Type alias 'S' circularly references itself.(2456).
🙂 Expected behavior
Both of these should work, and behave identically, as they are merely syntactic sugar for each other.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con gli esempi di Playground collegati e gli alias di tipo minimi R e S, confrontando il comportamento tra TypeScript 3.9.7, 4.0.5 e Nightly. Segui il controllo degli alias di tipo circolari e la gestione di Array rispetto a T[]; il lavoro è completo quando entrambi gli alias ricorsivi equivalenti vengono compilati senza la diagnostica di riferimento circolare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100