I (only) use arguments
to throw an error when an invalid number of arguments are passed to a function.
const myFunction = (foo) => {
if (arguments.length !== 1) {
throw new Error('myFunction expects 1 argument');
}
}
Unfortunately in TypeScript I get the error The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.
when referenced in arrow function.
How can I (always) validate the number of arguments in TypeScript?