Skip to content

Conversation

@yeomgahui
Copy link

Fixes #42468

This PR adds a suggestion diagnostic when an enum member key uses a computed string like ["Hello"], to encourage clearer and more compatible code.

Although such syntax is allowed in JavaScript, it can reduce readability and lead to subtle bugs. Based on the discussion in #42468, this PR introduces the following suggestion message:

Enum member keys should not use computed strings like ['A']. Use a string literal instead for clarity and compatibility.

This diagnostic is categorized as a Suggestion (code: 18062), so it does not affect existing code and is not a breaking change.

Note: The existing error for truly dynamic expressions (code 1164) remains unchanged.


Checklist:

Feedback welcome 🙌

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jun 10, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 10, 2025
@yeomgahui
Copy link
Author

@microsoft-github-policy-service agree

@yeomgahui yeomgahui closed this Jun 15, 2025
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Jun 15, 2025
@fisker
Copy link

fisker commented Sep 4, 2025

Why this closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Enum declarations should consistently disallow computed keys

3 participants