Files
progress-test/app/javascript/utils/notEmpty.ts
2022-07-28 08:26:27 -03:00

4 lines
274 B
TypeScript

// Use a type predicate function to avoid opting out of strict type checking: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
export const notEmpty = <T>(value: T | null | undefined): value is T =>
value !== null && value !== undefined