type Various = number | string | object;
// Expect: object
type Cleaned = Exclude<Various, Primitive>;
const isPrimitive = (
value: unknown
): value is Primitive => {
if (value === null || value === undefined) {
return true;
}
switch (typeof value) {
case "string":
case "number":
case "bigint":
case "boolean":
case "symbol": {
return true;
}
default: {
return false;
}
}
};