Class names `eval` and `arguments` are not reported as invalid strict mode bindings
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- compilers
Research direction
Start in the binder at bindClassLikeDeclaration and compare its strict-mode checks with checkStrictModeFunctionName; the issue identifies the missing check and ambient-context condition. Find the binder regression tests and cover class declarations, class expressions, and .js files with checkJs. Done means eval and arguments class names report the expected strict-mode diagnostic without changing valid cases.
Written by the indexing model from the issue text.
Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
🔎 Search Terms
class name eval arguments, class arguments strict mode, TS1210 class name, TS1215 class declaration, checkStrictModeEvalOrArguments class
🕗 Version & Regression Information
- This is the behavior in every version I tried (4.0.8, 5.0.4, 6.0.2, 7.1.0-dev.20261006.1), and I reviewed the FAQ for entries about strict mode and reserved words
⏯ Playground Link
💻 Code
class arguments {} // no error, expected TS1210
class eval {} // no error, expected TS1210
const C = class eval {}; // no error, expected TS1210
declare class eval {} // no error, expected TS1210
// For comparison, all other strict-mode bindings are reported:
function f() {
class D { m(arguments: number) {} } // TS1210
}
export {};
🙁 Actual behavior
No errors are reported for the class names. The emitted JavaScript is rejected at runtime:
$ node out.js
SyntaxError: Unexpected eval or arguments in strict mode
The same happens in a .js file with checkJs enabled.
🙂 Expected behavior
Each class name eval / arguments should be reported, as other strict mode bindings already are. Per the spec, all parts of a class are strict mode code (ECMA-262 §11.2.2), and it is an early error for a BindingIdentifier in strict mode code to be eval or arguments (§13.1.1). This applies to both class declarations and class expressions.
Additional information about the issue
In the binder, function names (checkStrictModeFunctionName), variable declarations (bindVariableDeclarationOrBindingElement) and parameters (bindParameter) all call checkStrictModeEvalOrArguments. bindClassLikeDeclaration never does, so class names skip this check.
bindWorker already sets inStrictMode = true for ClassDeclaration / ClassExpression before it calls bindClassLikeDeclaration. So a fix could follow checkStrictModeFunctionName: call checkStrictModeEvalOrArguments(node, node.name) in bindClassLikeDeclaration when not in an ambient context.
Found this issue while fixing the same bug in Babel's parser: https://github.com/babel/babel/pull/18315
- Dominant language
- Go
- Stars
- 111k
- Forks
- 15.5k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 142
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/TypeScript
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedPossibly taken @auvred claimed this 3 days ago. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/TypeScript#64618 · 1 assignee ·
Maintainers usually reply within 1 day
-
Needs Investigation
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/TypeScript#64565 · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
`EFNoLeadingComments` suppresses synthesized leading comments in tsgo; Strada only suppresses source commentsPossibly taken @weswigham claimed this 7 days ago. OpenNeeds Investigation
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/TypeScript#64453 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
enhance: Add tests for premature caching of contextual parameter typesPossibly taken @luchenxu73 claimed this 21 days ago. OpenPossible Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/TypeScript#64278 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Docs
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/TypeScript#64118 · 1 comment ·
Maintainers usually reply within 1 day
All issues in microsoft/TypeScript
Similar issues
-
status:approved type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Gentleman-Programming/gentle-ai#5326 ·
Maintainers usually reply within 1 day
-
area/testing kind/cleanup priority/backlog triage/accepted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
lexfrei/cloudflare-tunnel-gateway-controller#999 ·
Maintainers usually reply within 1 day
-
automation models
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Can the search results with Year Released be in enclosed in the ( ) like Movie/TV(Year Released)Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Dhairya3391/kari#32 ·