Background
To address the issue of checking whether a specific variable is null or undefined, I created the isNullish
function. The implementation of this function is shown below.
type Nullish = null | undefined;
const isNullish = (target: unknown): target is Nullish => target == null;
Challenge
Although I have utilized this utility in various parts of my codebase, it becomes tedious when dealing with multiple variables.
if (isNullish(v1) || isNullish(v2) || isNullish(v3)......) {}
I am seeking a more efficient solution for handling this situation. Since I am not proficient in TypeScript, I realize this may be a simple question. Thank you for taking the time to read and assist.