Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

RTCDataChannel.send fails to compile

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

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

評価

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

調査の方向性

まず RTCDataChannel.send のジェネレーター入力または宣言ソースを見つけ、次に issue にリンクされている WebRTC と MDN のリファレンスと比較します。生成された lib.dom.d.ts が ArrayBufferView | string の例を狭めずに受け入れること、そして結果として生成されるオーバーロード宣言がドキュメント化された API と一致することを確認します。

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

説明

Code that should compile but doesn't

function sendIt (peerConnection: RTCPeerConnection, data: ArrayBufferView | string): void {
  const dc = peerConnection.createDataChannel('')
  dc.send(data)
}

Reason

RTCDataChannel.send accepts string | Blob | ArrayBuffer | ArrayBufferView but because the .send method is declared as multiple overrides you have to work out the type of the argument before you invoke the method, even though you don't actually do anything to the data before sending:

// lib.dom.d.ts line 18,000
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send) */
send(data: string): void;
send(data: Blob): void;
send(data: ArrayBuffer): void;
send(data: ArrayBufferView): void;
function sendIt (peerConnection: RTCPeerConnection, data: ArrayBufferView | string): void {
  const dc = peerConnection.createDataChannel('')

  if (typeof data === 'string') {
    dc.send(data)
  } else {
    dc.send(data)
  }
}

Changing it to the following works:

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send) */
send(data: string | Blob | ArrayBuffer | ArrayBufferView) void;

Reference

主要言語
TypeScript
スター
740
フォーク
474
平均マージ
2日 8時間
マージ済み PR(30日)
15

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

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

microsoft/TypeScript-DOM-lib-generator のほかの issue

microsoft/TypeScript-DOM-lib-generator の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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