Context
I made isNullish function to check a specific variable is null or undefined. This function is implemented like below.
type Nullish = null | undefined;
const isNullish = (target: unknown): target is Nullish => target == null;
Problem
I use this utility in many places, but it is annoying when to check many variables.
if (isNullish(v1) || isNullish(v2) || isNullish(v3)......) {}
In this situation, how can I achieve better solution for this? I'm not good at typescript, so it maybe easy question. Sorry for this and thanks for your reading.
v1,v2orv3is/areNullish, so TypeScript cannot narrow the type of any variable toNullishtype and thus all the variables will still be infered asunknown.