UNPKG

ts-extras

Version:

Essential utilities for TypeScript projects

17 lines (12 loc) 395 B
/** Check whether a value is defined, meaning it is not `undefined`. This can be useful as a type guard, as for example, `[1, undefined].filter(Boolean)` does not always type-guard correctly. @example ``` import {isDefined} from 'ts-extras'; [1, undefined, 2].filter(isDefined); //=> [1, 2] ``` @category Type guard */ export declare function isDefined<T>(value: T | undefined): value is T;