-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Proposal: is.falsy()
as a type guard
#146
Comments
Sure, it could, but in what cases would it be useful though? The narrowing is still pretty wide. |
Your point is correct. If change signature to use type Falsy = false | 0 | 0n | '' | null | undefined;
is.falsy = <T>(value: T): value is Extract<Falsy, T> => !value; But, I found there are some bug in extracting from union type. If this problem is solved, It would be useful to use So, if you think this type of guard is unnecessary, I will close the issue. |
We can keep the issue open for now to gather more feedback and also wait for the TS issue. |
Although there are restrictions on using
is.truthy()
as a type guard function,is.falsy()
could be a type guard function.The text was updated successfully, but these errors were encountered: