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