Checks if a given type T is unknown.
T
unknown
Values of type unknown can hold any value, similar to any, but with stricter type safety. Unlike any, you cannot perform operations directly on values of type unknown without type assertion or type narrowing.
any
true if T is unknown, otherwise false.
true
false
type IsUnknownValue = IsUnknown<unknown>; // true type IsNotUnknownValue = IsUnknown<string>; // also true Copy
type IsUnknownValue = IsUnknown<unknown>; // true type IsNotUnknownValue = IsUnknown<string>; // also true
If you want unknown to be exact, use IsExactlyUnknown
IsExactlyUnknown
Checks if a given type
T
isunknown
.Values of type
unknown
can hold any value, similar toany
, but with stricter type safety. Unlikeany
, you cannot perform operations directly on values of typeunknown
without type assertion or type narrowing.