Acknowledgement
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
https://www.typescriptlang.org/play/?ts=6.0.0-dev.20260416#code/MYGwhgzhAEYE4HMCuBbApgOwC4wN4F9ojiiB6U6DAe2jTjirgBpaAPABzWCzQBNoAKgGUAjACYRABgBQoSDDQA3MCGgESGkuUo06DZm07c+g0RJnAqGCFmgBhaAF5ocqLWWqCAbjIVqtekYWNA4uHn5hcSlpXi5wODQXcDclFTVCbX89IMMwk0jzaWltADFGFyoUdngASwgrFhVVKiwACzpoGzga7gBaFCpY6AAjGoxeMYQYeESE9kZwgC5pADMkDG4aq2gVgAoASjVpIlcYABE1aBRd+GR0bAhFylRhukP1DIoC6PxpEPm4LZvNIgA
💻 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: babel/babel#18315
Acknowledgement
Comment
🔎 Search Terms
class name eval arguments, class arguments strict mode, TS1210 class name, TS1215 class declaration, checkStrictModeEvalOrArguments class
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.0-dev.20260416#code/MYGwhgzhAEYE4HMCuBbApgOwC4wN4F9ojiiB6U6DAe2jTjirgBpaAPABzWCzQBNoAKgGUAjACYRABgBQoSDDQA3MCGgESGkuUo06DZm07c+g0RJnAqGCFmgBhaAF5ocqLWWqCAbjIVqtekYWNA4uHn5hcSlpXi5wODQXcDclFTVCbX89IMMwk0jzaWltADFGFyoUdngASwgrFhVVKiwACzpoGzga7gBaFCpY6AAjGoxeMYQYeESE9kZwgC5pADMkDG4aq2gVgAoASjVpIlcYABE1aBRd+GR0bAhFylRhukP1DIoC6PxpEPm4LZvNIgA
💻 Code
🙁 Actual behavior
No errors are reported for the class names. The emitted JavaScript is rejected at runtime:
The same happens in a
.jsfile withcheckJsenabled.🙂 Expected behavior
Each class name
eval/argumentsshould 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 aBindingIdentifierin strict mode code to beevalorarguments(§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 callcheckStrictModeEvalOrArguments.bindClassLikeDeclarationnever does, so class names skip this check.bindWorkeralready setsinStrictMode = trueforClassDeclaration/ClassExpressionbefore it callsbindClassLikeDeclaration. So a fix could followcheckStrictModeFunctionName: callcheckStrictModeEvalOrArguments(node, node.name)inbindClassLikeDeclarationwhen not in an ambient context.Found this issue while fixing the same bug in Babel's parser: babel/babel#18315