Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Class names `eval` and `arguments` are not reported as invalid strict mode bindings

未關閉 適合新手
#64,661 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript
領域
compilers

研究方向

從 binder 中的 bindClassLikeDeclaration 開始,並將其 strict mode 檢查與 checkStrictModeFunctionName 比較;issue 指出了缺少的檢查和 ambient context 條件。找出 binder 的迴歸測試,並涵蓋類別宣告、類別運算式,以及啟用 checkJs 的 .js 檔案。完成標準是:類別名稱為 eval 和 arguments 時回報預期的 strict mode 診斷,且不變更有效案例。

由索引模型根據 Issue 內容生成。

描述

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

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: https://github.com/babel/babel/pull/18315

主要語言
Go
星號
111k
分支
15.5k
平均合併
1 天 21 小時
30 天內合併 PR
150

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。