Bug Report
NonNullable<null> was never in all cases previously, since 4.8 it's null when strictNullChecks: false. From reading the PR that changed the implementation of NonNullable 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
- This changed between versions 4.7 and 4.8
⏯ Playground Link
Playground link with relevant code (same behavior for 4.7, but the implementation of NonNullable was different there)
💻 Code
type NonNullableNew<T> = T & {};
type NonNullableOld<T> = T extends null | undefined ? never : T;
type IsNullWithoutStrictNullChecks = NonNullableNew<null>;
type IsAlwaysNever = NonNullableOld<null>;
🙁 Actual behavior
NonNullable<null> returns null with strictNullChecks: false
🙂 Expected behavior
NonNullable<null> always returns never
Bug Report
NonNullable<null>wasneverin all cases previously, since 4.8 it'snullwhenstrictNullChecks: false. From reading the PR that changed the implementation ofNonNullableI 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
NonNullablewas different there)💻 Code
🙁 Actual behavior
NonNullable<null>returnsnullwithstrictNullChecks: false🙂 Expected behavior
NonNullable<null>always returnsnever