You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
9 lines
337 B
TypeScript
9 lines
337 B
TypeScript
/**
|
|
* type-guarded function that tells TypeScript (in strictNullChecks mode) that you're filtering out null/undefined items.
|
|
* example: array.filter(isNotNull)
|
|
*/
|
|
export const isNotNull = <T>(item: T): item is NonNullable<T> => item != null;
|
|
|
|
// alternative
|
|
// const const isNotNull = <T>(item: T | null): item is T => item !== null;
|