microsoft / microsoft/TypeScript
Distribute property type union members to create union of object types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: v3.9.0-dev.20200222
Search Terms: union type object property
Code
type Test =
| { b: [false, "a"] }
| { b: [true, "b"] }
declare const b2: boolean;
const a: Test = { b: b2 ? [b2, "b"] : [b2, "a"] }
Expected behavior:
No error. I'm not exactly sure if this is a bug or feature request but, essentially, it'd be nice if TS could recognize that: { b: [true, "b"] | [false, "a"]; } is identical to { b: [true, "b"] } | { b: [false, "a"]; }
Actual behavior:
Type '{ b: [true, "b"] | [false, "a"]; }' is not assignable to type 'Test'.
Type '{ b: [true, "b"] | [false, "a"]; }' is not assignable to type '{ b: [true, "b"]; }'.
Types of property 'b' are incompatible.
Type '[true, "b"] | [false, "a"]' is not assignable to type '[true, "b"]'.
Type '[false, "a"]' is not assignable to type '[true, "b"]'.
Type 'false' is not assignable to type 'true'.
Playground Link: Playground Link
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 riproducendo l’assegnazione dell’esempio di codice TypeScript dell’issue nel Playground collegato e confronta la diagnostica riportata con il comportamento previsto. Il lavoro è completato quando l’esempio viene accettato mantenendo al contempo il controllo corretto delle union incompatibili di tuple e oggetti; nell’issue non sono identificati né un file sorgente né un percorso di test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100