I have the following fairly basic function:
function isNil(x: T | undefined | null): x is undefined | null { return x === undefined || x === null; }