Why does a void function pass as a plain object? Is this intentional or a mistake in the system?
type PlainObject = { [key: string]: any };
const foo = (value: PlainObject) => { }
const voidFn: () => void = () => { };
// Error as expected
foo(false);
foo(3);
foo('test');
foo ({ test: true }) // ok - expected usage
foo(voidFn); // Why is there no error here?
This issue only arises when the value is any
. If it were, say, { [key: string]: string };
, an error would be triggered.