Class names `eval` and `arguments` are not reported as invalid strict mode bindings
維護者通常 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
💻 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
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/TypeScript 的其他 Issue
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmed可能已有人在做 @auvred 於 4 天前認領。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 68/100
microsoft/TypeScript#64618 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Needs Investigation
難度 2/5 1-3 小時 新手友好度 84/100
microsoft/TypeScript#64565 · 1 個 reaction · 已指派 1 人 ·
維護者通常 1 天內回覆
-
`EFNoLeadingComments` suppresses synthesized leading comments in tsgo; Strada only suppresses source comments可能已有人在做 @weswigham 於 7 天前認領。 未關閉Needs Investigation
難度 2/5 1-3 小時 新手友好度 84/100
microsoft/TypeScript#64453 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
enhance: Add tests for premature caching of contextual parameter types可能已有人在做 @luchenxu73 於 22 天前認領。 未關閉Possible Improvement
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/TypeScript#64278 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
Docs
難度 2/5 1-3 小時 新手友好度 70/100
microsoft/TypeScript#64118 · 1 則留言 ·
維護者通常 1 天內回覆
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 86/100
war-and-code/dircue#200 ·
維護者通常 1 天內回覆
-
actor/human kind/bug priority/important-soon triage-accepted
難度 2/5 1-3 小時 新手友好度 66/100
kelos-dev/kelos#1804 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
`date` → `date-time` (and `time` → `date-time`) is classified as a widening, but a date is not a valid date-time可能已有人在做 @reuvenharrison 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
fix: invalid GPU spec in SparkApplication is silently ignored可能已有人在做 @pratik-naik003 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 85/100
kubeflow/spark-operator#3223 ·
維護者通常 5 天內回覆