Just function to predicate non nullable with type guard.
$ npm install is-non-nullable
import isNonNullable from 'is-non-nullable'
isNonNullable('foo')
//=> true
isNonNullable('')
//=> true
isNonNullable(0)
//=> true
isNonNullable(false)
//=> true
isNonNullable(null)
//=> false
isNonNullable(undefined)
//=> false
Type narrowing with Array.filter
const items: (number | null | undefined)[] = [0, 1, null, undefined, 2]
const filtered = items.filter(isNonNullable)
//=> number[]