microsoft / microsoft/TypeScript

The type of Document.documentElement could be SVGSVGElement

オープン
#29,052 コメント 4 件 リアクション 4 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Revisit Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Currently, the type of Document.documentElement is HTMLElement:

https://github.com/Microsoft/TypeScript/blob/4d74f67325d305f52a2b00b4f30b5a4f3210c649/lib/lib.dom.d.ts#L4124

But it is possible for a Document’s documentElement property to be of type SVGSVGElement which is not a subtype of HTMLElement:

Try to run the following code:

const d = (new DOMParser()).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"></svg>', 'image/svg+xml');
const k = (d instanceof Document) && (d.documentElement instanceof SVGSVGElement);

the value of k should be true.

Also, why isn’t there a SVGDocument in TypeScript?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

lib/lib.dom.d.ts、Document.documentElement にリンクされた宣言から始め、DOMParser の SVG 例を再現します。DOM typings が示された SVG documentElement を正しく受け入れ、issue の SVGDocument に関する問題が解決され、関連する宣言チェックに合格すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
frontend
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。