You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declarefunctionisNotNullish(value: unknown): value is {};declarefunctionisNullish(value: unknown): value is null|undefined;declareconstvalue: unknown;if(isNotNullish(value)){value;// ^?}if(!isNotNullish(value)){value;// ^?}if(isNullish(value)){value;// ^?}if(!isNullish(value)){value;// ^?}
π Actual behavior
value only narrows when the type predicate is called directly, not when negated with a !.
The narrowed types of value in that example are:
isNotNullish(value): {}
!isNotNullish(value): unknown β
isNullish(value): null undefined
!isNullish(value): unknown β
π Expected behavior
The narrowed types of value should be:
isNotNullish(value): {}
!isNotNullish(value): null | undefined
isNullish(value): null undefined
!isNullish(value): {}
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
{} undefined null predicate unknown narrowing
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXywGcA5HDY5CCIgCwAoA3KCZEALnjQGtUcB3VAEoOTFgiLwA3gF8A3AChQkWAhTpseAiUrVC9Uaw7deA4fAPjC8VDvgAfTqlCIsqEMAWLw0OPDB5CDHNmQ0ceflRPLER4OiJSch1aRhCQQUEpeXhgsQVsgHp8+AA9AH55aXl5aNiAQniyCipki3TM7Is8+EKS8srqmLjtZr0UsTbJLJzWLp6yiqqaunrh3X1UianOqbm+oA
π» Code
π Actual behavior
value
only narrows when the type predicate is called directly, not when negated with a!
.The narrowed types of
value
in that example are:isNotNullish(value)
:{}
!isNotNullish(value)
:unknown
βisNullish(value)
:null undefined
!isNullish(value)
:unknown
βπ Expected behavior
The narrowed types of
value
should be:isNotNullish(value)
:{}
!isNotNullish(value)
:null | undefined
isNullish(value)
:null undefined
!isNullish(value)
:{}
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: