-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
NonNullable<null>
is null
without strict null checks
#50519
Comments
To be honest, I think that the behavior outside of |
@DanielRosenwasser I was skeptical about this at first too, but notably, |
Well... it probably should be the case that |
I'm going to regret that comment I bet. |
Regardless of whether anyone feels |
It broke because we use export type EnsureDefined<T> = NonNullable<T> extends never ? {} : T; We need this because |
Fixes a breaking change introduced by TS: NonNullable<null> is no longer never when strict null checks are false: microsoft/TypeScript#50519
Fixes a breaking change introduced by TS: NonNullable<null> is no longer never when strict null checks are false: microsoft/TypeScript#50519
|
By the rules of assignability, shouldn’t |
It is all pretty hard to reason about, and I mixed it up a few times - but |
In 4.8 |
Fixes a breaking change introduced by TS: NonNullable<null> is no longer never when strict null checks are false: microsoft/TypeScript#50519
Bug Report
NonNullable<null>
wasnever
in all cases previously, since 4.8 it'snull
whenstrictNullChecks: false
. From reading the PR that changed the implementation ofNonNullable
I can't really tell if this is now expected or an oversight. If it's expected, maybe the blog post could be updated because I think this is a significant difference in behavior.🔎 Search Terms
NonNullable never null
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code (same behavior for 4.7, but the implementation of
NonNullable
was different there)💻 Code
🙁 Actual behavior
NonNullable<null>
returnsnull
withstrictNullChecks: false
🙂 Expected behavior
NonNullable<null>
always returnsnever
The text was updated successfully, but these errors were encountered: