microsoft / microsoft/TypeScript
Allow `#`-private names in parameter property positions
未關閉
還沒有人認領這個 Issue。
Awaiting More Feedback
Suggestion
- 主要語言
- Go
- 星號
- 111k
- 分支
- 14.3k
- 平均合併
- 1 天 19 小時
- 30 天內合併 PR
- 117
描述
Search Terms
hard privacy https://github.com/microsoft/TypeScript/issues/31670
Suggestion
allow create hard privacy like we do private in constructor(private foo: number)
Use Cases
Examples
allow use constructor(#foo: number) {} or constructor(private #foo: number) {} or constructor(hard private #foo: number) {}
for same as
#foo: number;
constructor(foo: number) {
// This works.
this.#foo = foo;
}
class C {
constructor(#foo: number) {}
log() {
console.dir(this.#foo);
return this
}
}
let o = new C(777).log();
// error
o.#foo;
same as
class C {
#foo: number;
constructor(foo: number) {
// This works.
this.#foo = foo;
}
log() {
console.dir(this.#foo);
return this
}
}
let o = new C(777).log();
// error
o.#foo;
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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
沒有指定檔案、測試或進入點。先檢視所要求的建構函式參數形式和隨附的類別範例;支援所提議的 #foo 參數屬性語法,同時保留所示的 private 存取行為,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- typescript
- 領域
- compilers
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100