microsoft / microsoft/TypeScript
Completion should suggest enum keys on some conditions
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Keine Datei, kein Test und kein Einstiegspunkt ist benannt. Beginne damit, das Beispiel zur Vervollständigung von enum im TypeScript language service zu reproduzieren, und verfolge nach, wie Vervollständigungen in Kontexten gefiltert werden, in denen ein Typ erwartet wird. Als erledigt gilt die Aufgabe, wenn ein Präfix wie CRE State.CREATED anbietet, ohne dass zuerst der enum-Bezeichner erforderlich ist, während die bestehende JavaScript-Ausgabe und das bestehende Verhalten erhalten bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- developer-experience, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100