TypeScript Version: 3.3.0-dev.201xxxxx
Search Terms:
Domain: Conditional Types
extends null
Code
typeCannotBeNull<T>={readonly[PinkeyofT]: T[P]extendsNonNullable<T[P]> ? true : false;};typeDoesntCheckNull<T>={readonly[PinkeyofT]: T[P]extendsnull ? false : true;};typeMyData={name: string,age: number,hasChild: boolean,childAge: null|number,childName: null|string};typeDataWhichArentNull=CannotBeNull<MyData>;typeDataAreAllTrue=DoesntCheckNull<MyData>;Expected behavior:
The DoesntCheckNull<T> should have the same result as DataWhichArentNull<T> because it re-uses the logic in NonNullable<T>
i.e. DataWhichAreAllTrue should look like:
{name: true,age: true,hasChild: true,childAge: false,childName: false,}Actual behavior:
DataWhichAreAllTrue actually looks like:
{name: true,age: true,hasChild: true,childAge: true,childName: true,}Playground Link:
playgroundN.B. turn on --strictNullChecks flag in Options
Related Issues:
Possibly related to 25413.
I thought it was related to 23843, but that was fixed in a PR that was merged 19 days ago, but I could reproduce this issue even when using typescript@next.
TypeScript Version: 3.3.0-dev.201xxxxx
Search Terms:
Domain: Conditional Types
extends null
Code
Expected behavior:
The
DoesntCheckNull<T>should have the same result asDataWhichArentNull<T>because it re-uses the logic inNonNullable<T>i.e.
DataWhichAreAllTrueshould look like:Actual behavior:
DataWhichAreAllTrueactually looks like:Playground Link:
playgroundN.B. turn on
--strictNullChecksflag in OptionsRelated Issues:
Possibly related to 25413.
I thought it was related to 23843, but that was fixed in a PR that was merged 19 days ago, but I could reproduce this issue even when using typescript@next.