microsoft / microsoft/TypeScript
Is there a way to use TypeScript to prevent accidental global access?
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
I just spent 2 hours tracking down this issue:
- We have a class with a prototype method called
focus() - Our code was calling
focus(), but it should have been callingthis.focus() - The code compiled fine, because
window.focus()shares the same signature as ourfocus()method
Is there a way to throw a compile time error when implicitly accessing global methods (on window, global, etc.)?
If not, a compiler flag would be extremely helpful. I would happily be more explicit about commonly used globals (window.setTimeout, window.document, ...) if it meant I could more easily catch insidious bugs like this one.
Full commit here: https://github.com/coatue/SlickGrid/commit/0f8bab3fa9968173d749ccdf535c88f3a526ca8b.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされているSlickGridのコミットから始めて、issueで説明されている意図しないグローバルアクセスを再現します。要求されている動作がコンパイラ診断なのか新しいflagなのかを判断するために議論を確認します。ソースファイルもテストも指定されていないため、完了には合意された設計と、それに対応するコンパイラのカバレッジが必要です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100