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}; Copy
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};
The value to be asserted.
Asserts that the given value is a function.
Throws
An error with message 'Expected a function' if the assertion fails.
Example