UNPKG

ts-extras

Version:

Essential utilities for TypeScript projects

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