Incredible series, thanks so much for sharing this.
Would greatly appreciate if you could clarify the following:
In this example
type RemoveUndefinableKeys<Type> = { [Key in keyof Type]: undefined extends Type[Key] ? never : Key };
when we pass this portion of a Type
Type
property?: string;
which is the same as
property?: string | undefined
it evaluates to truthy branch of extends, and I don't quite understand how does it form undefined?
extends
undefined
type TestRemoveNullableProperties = { ... property?: undefined; }
when supposedly, it should be getting never in true branch.
never
true
Another even more confusing thing is if we explicitly pass
property: string | undefined;
skipping ? marking operator,
?
we will get
type TestRemoveNullableProperties = { ... property: never; }
Thank you.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Incredible series, thanks so much for sharing this.
Would greatly appreciate if you could clarify the following:
In this example
when we pass this portion of a
Type
which is the same as
it evaluates to truthy branch of
extends
, andI don't quite understand how does it form
undefined
?when supposedly, it should be getting
never
intrue
branch.Another even more confusing thing is if we explicitly
pass
skipping
?
marking operator,we will get
Thank you.