-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add suggestion diagnostic for enum computed string keys (#42468) #61839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@yeomgahui please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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:
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:
main
branchhereby runtests
enumComputedStringSuggestion.ts
verifies the suggestionFeedback welcome 🙌