Skip to content

falsy ​

The falsy() function is a type guard that keeps only falsy values (false, 0, "", null, undefined).

Interactive example ​

Syntax ​

typescript
function falsy<
	GenericInput extends unknown,
>(
	input: GenericInput
): input is Extract<GenericInput, FalsyValue>;

Parameters ​

  • input: Value to test.

Return value ​

A type guard that is true when input is falsy.

See also ​

Released under the MIT license.