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

fix(types): infer number enum types from schema if using enum: [0, 1] as const #12463

Merged
merged 1 commit into from Sep 22, 2022

Conversation

vkarpov15
Copy link
Collaborator

Fix #12242

Summary

#12242 shows that we can do a better job of inferring enum types for numbers, like how we infer enums from strings. You do need to use as const as @hasezoey pointed out, but otherwise this approach seems to work.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM though complex types and typescript syntax sometimes look like magic to me

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Sep 22, 2022
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. 👍

@vkarpov15 vkarpov15 merged commit 6153970 into master Sep 22, 2022
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-12242 branch September 22, 2022 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing inferred enum property when type is Number
3 participants