-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
Suggestion
I suggest a better error message telling that arguments is a reserved keyword or something that cannot be used in TS in strict mode.
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
I suggest a better error message telling that arguments is a reserved keyword or something and cannot be used as variable name.
📃 Motivating Example
I'm coming from languages that allow using words like "arguments" as a variable name.
I wrote a simple line of code: let arguments = targetTask.arguments ?? {} and got a confusing error: "Invalid use of 'arguments'. Modules are automatically in strict mode.ts(1215)". It would be less confusing if it told me what it thought the arguments is. E.g. "Invalid use of reserved keyword 'arguments'" or "Invalid use of disabled builtin function 'arguments'" etc.
💻 Use Cases
P.S. Ideally I wish TS supported the name "arguments" for local variables.