Type alias IsTruthy<T>

IsTruthy<T>: IfExtends<T, Exclude<T, Falsy>, true, false>

Checks if a given type T is a truthy value. A truthy value is any value that is not a falsy value.

Type Parameters

  • T

Returns

true if T is not a subtype of Falsy, otherwise false.

Example

type TruthyString = IsTruthy<string>; // => true
type TruthyNumber = IsTruthy<10>; // => true
type FalsyNull = IsTruthy<null>; // => false
type FalsyEmptyString = IsTruthy<''>; => false