-
Notifications
You must be signed in to change notification settings - Fork 130
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
Unexpected types when using isNullish/isNonNullish in conditional #675
Comments
We've got other reports about conditional acting different than expected for people. It's most likely a bug in our typing for conditional. |
@eranhirsch I tried to modify the guards as a workaround and I think import type { NarrowedTo } from "./internal/types";
export function isNullish<T>(
data: T | null | undefined,
): data is NarrowedTo<T, null | undefined> {
return data === null || data === undefined;
} This narrowing allows for However, I am not sure what can be done about |
TS Version: 5.4.5
Example:
I checked separately if it had to do with the FirstBy type but that doesn't seem to be the case:
It looks like the conditional's
When
s must be a type guard of the formis A
whereA
is a primitive type, so not even "NonNullable". Is this correct and intended? If so, it would be good to reflect this in the documentation.The text was updated successfully, but these errors were encountered: