microsoft / microsoft/TypeScript
Inconsistent object literal key completion for enum keys
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
### 🔎 Search Terms
`enum AND object AND keys`
### 🕗 Version & Regression Information
I tried various versions up to nightly (`v6.0.0-dev.20251030`) with no results
### ⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.0-dev.20251030#code/KYOwrgtgBAsgngUXNA3gKCpqAxA8rgGgywCEBBAJSIF800BjAexAGcAXKAM0cYC4oKwJgCcAJgB54SSASjthASxABzAHxQAvFHRYoAej1Q2wuEcZQmEAA4AbYG2BQA1sDgsoSowAsF7xgCMAKyE2YkwDKGAAD2ArEOBRKABtKWQAOjxcAF1ZFMR08gossP1DAEN6NjAymygAIgAGOtk6gEY6tGogA
### 💻 Code
```ts
enum MyEnum {
FOO,
BAR,
}
const foo: Record = {
// try to complete keys in this object
// expected [MyEnum.FOO], [MyEnum.BAR]
// actual "0", "1"
}
```
### 🙁 Actual behavior
`"0"` and `"1"` are suggested as completions
### 🙂 Expected behavior
`[MyEnum.FOO]` and `[MyEnum.BAR]` are suggested as completions
### Additional information about the issue
using the quick fix `Add Missing Properties` uses the correct, expected behaviour
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
Use the linked TypeScript Playground to reproduce completion for the Record object and compare it with the Add Missing Properties quick fix. Trace the completion behavior for enum-keyed object literals; done when completion suggests [MyEnum.FOO] and [MyEnum.BAR] rather than "0" and "1".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100