-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Make literals work with null #698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I have said, null is not a value categorized in atomic, but a type of object.
Therefore, this PR and related issue need to consider about that.
Can you explain why that matters in the context of this issue/pr? |
I repeat #685 issue's comment.
The |
No problem then, null is a literal
Also typeof null is considered a bug that was never fixed https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null And even if it wasn't a literal I would say that that it's an unnecessary self-imposed constraint. I don't think undefined is a literal (although typeof undefined === 'undefined' so going by that standard it might be), but I would argue that literals should work with that as well. Let me talk about my use case. We use Joi for validation and want to provide a list of valid values for it. Because literals doesn't support null we have to instead do something like the following type ValidValues = 'A' | 'B' | null;
const validValues = [...literals<Exclude<ValidValues, null>>(), null] And this is why I want null to be included |
Wow, the Got it. Your PR would be published as a next version Thanks for contribution. |
Closes #685