microsoft / microsoft/TypeScript
spread operator for enum
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
- Spread operator
Suggestion
I would like to use the spread operator to spread the values (or maybe the keys) of an enum.
Use Cases
I want to use this to check or print available types of enum type.
Examples
enum TestStatus{
PENDING,
ACCEPTED,
WRONG_ANSWER
}
console.log(...TestStatus); // prints: "PENDING" "ACCEPTED" "WRONG_ANSEWR"
Checklist
My suggestion meets these guidelines:
- 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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
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
Start with the enum and spread-operator example in the issue, then review the linked TypeScript design goals. Clarify whether spreading should expose enum keys, values, or both, and define the expected behavior for the shown example. Done means the proposal has an agreed semantic design and satisfies the stated checklist without changing existing JavaScript runtime behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100