Skip to content
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

feat: remove "| string" and "| number" from enum targeted members #1028

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Oct 12, 2023

This PR removes the open-ended union of | string and | number from shape members that targeted enums.

This improves the dev experience with the type system by

  • flagging enum value typos
  • potentially improving auto-complete in certain code editors
  • enabling IDE-generation or manual writing of exhaustive switch statements

User guide:

  • if using only JavaScript, you would not be affected by this change.
  • If using existing declared enums, no change is expected.
  • If using enums not declared in the generated model, such as when using an older version of a generated SDK, use the following overrides:
    • on inputs, use 'NEW_VALUE' as any.
    • on outputs, use e.g. if (output.enum as any === 'NEW_VALUE') {
    • in either case, you can also use a compiler comment to ignore any unenumerated fields
  • you should still write a default branch, if only to throw an error, in any switch statement on an enum value.

@kuhe kuhe requested review from a team as code owners October 12, 2023 18:43
@kuhe
Copy link
Contributor Author

kuhe commented Oct 12, 2023

@github-actions
ci / Ensure TypeScript is formatted (pull_request)

there are no typescript changes in this PR

@kuhe kuhe merged commit d7f5cda into smithy-lang:main Oct 13, 2023
7 checks passed
@kuhe kuhe deleted the feat/enums branch October 13, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants