microsoft / microsoft/TypeScript
Define 'tagName' values in Element interfaces to prevent misleading type acceptance.
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
🔎 Search Terms
- HTML Element Interfaces
- Element tagName
- Element Interfaces
- Incorrect element types accepted
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Element interfaces
⏯ Playground Link
Playground link with relevant code
💻 Code
// Elements can be assigned to variables of other element types because of interface overlaps being sufficient.
let element: HTMLSpanElement = document.createElement("div");
// If the interfaces included the appropriate 'tagName' property this could be avoided...
let spanElement: HTMLSpanElement & { tagName: "SPAN" } = document.createElement("div") as HTMLDivElement & { tagName: "DIV" };
🙁 Actual behavior
e.g. 'HTMLDivElement' instance can be assigned to variables of type 'HTMLSpanElement'.
🙂 Expected behavior
This should fail the type checking to avoid accidentally assigning elements of an incorrect type.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の再現例から始め、関連する HTML Element インターフェース、特に HTMLSpanElement と HTMLDivElement の tagName を調べます。HTMLDivElement が HTMLSpanElement として受け入れられなくなり、示されている tagName の交差の挙動が正確に表現されたままであれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 38/100