microsoft / microsoft/TypeScript
Completion should suggest enum keys on some conditions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔍 Search Terms
"enum", "enum keys", "completion"
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Suggest enum keys completions without having to spell out the enum identifier.
For example, input CRE should be offered completion State.CREATED.
This completion can be limited to places where the enum type is expected, like a function argument or an object literal.
📃 Motivating Example
enum State {
CREATED,
CLOSED,
}
function f(v : State) {}
f(CRE ) // Expect completion on CRE
💻 Use Cases
- What do you want to use this for? better DX
- What shortcomings exist with current approaches? Have to first write the enum before enum key completions are offered.
- What workarounds are you using in the meantime? no
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 viene indicato alcun file, test o punto di ingresso. Inizia riproducendo l'esempio di completamento di enum nel TypeScript language service e traccia il modo in cui i completamenti vengono filtrati nei contesti in cui è previsto un tipo. Il lavoro è completato quando un prefisso come CRE offre State.CREATED senza richiedere prima l'identificatore dell'enum, preservando al contempo l'output e il comportamento esistenti di JavaScript.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- developer-experience, tooling
- 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