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

Convert enums to constant objects with as const for better type safety #204

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

aricart
Copy link
Member

@aricart aricart commented Feb 4, 2025

Replaced TypeScript enum declarations with constant objects using as const. This change preserves the same api, but removes enums, and allows using the values directly without importing the constant. Enums are problematic because they require transpilation, with this change erasure is possible.

Replaced TypeScript `enum` declarations with constant objects using `as const`. This change preserves the same api, but removes enums, and allows using the values directly without importing the constant. Enums are problematic because they require transpilation, with this change erasure is possible.

Signed-off-by: Alberto Ricart <alberto@synadia.com>
Signed-off-by: Alberto Ricart <alberto@synadia.com>
@aricart aricart requested a review from caspervonb February 4, 2025 23:20
Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, albeit breaking would be to be consistent in the naming. e.g all caps.

@aricart aricart merged commit 747c3e5 into main Feb 7, 2025
26 checks passed
@aricart aricart deleted the enums-to-objectliterals branch February 7, 2025 23:25
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.

2 participants