microsoft / microsoft/TypeScript
Enhance members of literal type like const array type (e.g. string literal types should have literal length property)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
The const array type, its principle members are also be the constant. When define a const array [number, string, boolean], its length type be 3. Also, when access to special index, the type also points the exact const type.
function const_array(): void
{
let elements: [number, string, false] = [3, "something", false];
let length: 3 = elements.length;
let first: number = elements[0];
let second: string = elements[1];
let third: false = elements[2];
}
However, the literal type is not like the const array. When define a literal type "something", its length be not 9 but number. Also, when access to a special index, the type is not a special literal type but a string type.
function literal(): void
{
let word: "something" = "something" as const;
let length: number = something.length; // not 9 but number
let first: string = word[0]; // not "s" but string
let second: string = word[1]; // not "o" but string
let third: string = word[2]; // not "m" but string
}
What about enhancing the literal type to be like the const array type?
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
Non vengono indicati file o test. Inizia individuando i percorsi di controllo dei tipi per l'accesso alle proprietà tramite stringhe letterali e per l'accesso indicizzato, quindi confronta il loro comportamento con la gestione delle tuple. Il lavoro è completato quando le stringhe letterali espongono una lunghezza letterale e tipi di carattere letterali agli indici noti, con test appropriati di controllo dei tipi.
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à
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100