Skip to main content

isNotNullish

A function that checks that the given argument is not null or undefined, and if not, narrows it down to the given argument type.


Interface

typescript
const isNotNullish: <T>(val: T | null | undefined) => val is T

Usage

import { isNotNullish } from '@devgrace/utils';

isNotNullish(1); // true
isNotNullish(false); // true
isNotNullish("str"); // true
isNotNullish({}); // true

isNotNullish(undefined); // false
isNotNullish(null); // false