Skip to Content
utilshasNonNullableValues

hasNonNullableValues

See source on Github 

Checks if values of given keys are non-nullable.

Could be useful when the Array.prototype.filter()  method doesn’t properly infer your predicate function.

Example

const entries = [ { key1: null, key2: '01-value2' as const }, { key1: '02-value1' as const, key2: '02-value2' as const } ] entries.filter((entry) => hasNonNullableValues(entry, ['key1', 'key2'])) // [{key1: '02-value1', key2: '02-value2'}]