Function assertIsPlainObject

Asserts that the input is a plain object.

An error with message 'Expected a plain object' if the input is not a plain object.

const fn = (x: Date | { foo: string } | number | string) => {
assertIsPlainObject(x);
return x; // x has inferred type { foo: string } as it is the only plain object
};