Function assertIsFunction

Asserts that the given value is a function.

An error with message 'Expected a function' if the assertion fails.

const fn = (x: number | (x: number) => number) => {
assertIsFunction(x); // throws an error if x is not a function
return x; // x has inferred type (x: number) => number
};