websocket-stream's TypeScript produces errors - ws package TypeScript updated.

オープン
#156 コメント 2 件 リアクション 3 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
node.js, typescript

調査の方向性

index.d.ts を開き、Server event-handler の宣言を更新された ws TypeScript 型と比較します。callback this types を WebSocket.Server に更新するか、overloads を削除できることを確認します。完了の条件は、websocket-stream の TypeScript エラーが発生しなくなることです。

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

説明

class Server extends WebSocket.Server {
    on(event: 'connection', cb: (this: WebSocket, socket: WebSocket, request: http.IncomingMessage) => void): this;
    on(event: 'error', cb: (this: WebSocket, error: Error) => void): this;
    on(event: 'headers', cb: (this: WebSocket, headers: string[], request: http.IncomingMessage) => void): this;
    on(event: 'listening', cb: (this: WebSocket) => void): this;
    on(event: 'stream', cb: (this: WebSocket, stream: WebSocketDuplex, request: http.IncomingMessage) => void): this;
    on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
}

should become

class Server extends WebSocket.Server {
    on(event: 'connection', cb: (this: WebSocket.Server, socket: WebSocket, request: http.IncomingMessage) => void): this;
    on(event: 'error', cb: (this: WebSocket.Server, error: Error) => void): this;
    on(event: 'headers', cb: (this: WebSocket.Server, headers: string[], request: http.IncomingMessage) => void): this;
    on(event: 'listening', cb: (this: WebSocket.Server) => void): this;
    on(event: 'stream', cb: (this: WebSocket.Server, stream: WebSocketDuplex, request: http.IncomingMessage) => void): this;
    on(event: string | symbol, listener: (this: WebSocket.Server, ...args: any[]) => void): this;
}

in index.d.ts to avoid TypeScript errors. Or better yet, because Server extends WebSocket.Server, these should be removed all together (unless it is currently serving a greater purpose).

Looks like PR #152 resolves this issue.

主要言語
JavaScript
スター
667
フォーク
110
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

max-mapper/websocket-stream のほかの issue

max-mapper/websocket-stream の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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