microsoft / microsoft/TypeScript
Completion should suggest enum keys on some conditions
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔍 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by reproducing the enum completion example in the TypeScript language service and trace how completions are filtered in type-expected contexts. Done means a prefix such as CRE offers State.CREATED without requiring the enum identifier first, while preserving existing JavaScript output and behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100