We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
IsNothing()
Add IsNothing() type guard that can exclude Nothing from a union type.
Nothing
The following does not work:
let x: string | Nothing | undefined if (x === nothing) { // x type should be `Nothing` } else { // x type should be string }
Since the Nothing type is implemented as a class, the x === nothing will not remove the Nothing type from the control flow analysis.
x === nothing
Adding a IsNothing() type guard will solve this problem.
I can implement that easily in user-land, but this is a core concept of immer and IMO should live inside immer.
immer
I can contribute to the project. Just want to know which file should I add the tests to.
The text was updated successfully, but these errors were encountered:
isNothing()
Successfully merging a pull request may close this issue.
🚀 Feature Proposal
Add
IsNothing()
type guard that can excludeNothing
from a union type.Motivation
The following does not work:
Since the
Nothing
type is implemented as a class, thex === nothing
will not remove theNothing
type from the control flow analysis.Adding a
IsNothing()
type guard will solve this problem.Can this be solved in user-land code?
I can implement that easily in user-land, but this is a core concept of
immer
and IMO should live insideimmer
.I can contribute to the project. Just want to know which file should I add the tests to.
The text was updated successfully, but these errors were encountered: