Wednesday, December 2, 2015

TypeScript 1.5 Error–The ‘arguments’ object cannot be referenced in an arrow function

After upgrading a TypeScript project to TypeScript 1.5, the build started to fail with the following error message:

“Build: The ‘arguments’ object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.”

clip_image002

This is the code snippet where the error occured:

Starting from TypeScript 1.5 it is no longer allowed to reference the arguments object inside an arrow function. According to the specs, no argument variable is created for an arrow function.

To fix this, we can follow the suggestion as mentioned in the error and switch to a normal function expression:

More information in the following GitHub issue: https://github.com/Microsoft/TypeScript/issues/1609

No comments: