notNullish
@guoba-ai/utils / guard / notNullish
Function: notNullish()
function notNullish<T>(val): val is NonNullable<T>;Defined in: guard.ts:269
Check if a value is not null or undefined (type narrowing).
Parameters
val
T | null | undefined
The value to check
Returns
val is NonNullable<T>
true if the value is not null or undefined
Example
const values = [1, null, 2, undefined, 3]
const filtered = values.filter(notNullish) // [1, 2, 3] typed as number[]
notNullish(0) // true
notNullish(null) // false