Typescript definition is broken if @types/express-ws is in the same package.json
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- node.js, typescript
- Ambito
- backend
Direzione di ricerca
Aggiorna le dichiarazioni in index.d.ts, concentrandoti sui sovraccarichi di Server.on mostrati nell’issue. Riproduci il problema con TypeScript e @types/express-ws, quindi esegui nuovamente tsc; il lavoro è completato quando gli errori TS2416 segnalati non si verificano più e le tipizzazioni dei callback di Server corrispondono al tipo Server previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When @types/express-ws (npm install --save-dev @types/express-ws) is added to the same Typescript project that uses websocket-stream, tsc produces the following:
> tsc
node_modules/websocket-stream/index.d.ts:13:5 - error TS2416: Property 'on' in type 'Server' is not assignable to the same property in base type 'Server'.
Type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: WebSocket, error: Error) => void): this; (event: "headers", cb: (this: WebSocket, headers: string[], request: IncomingMessage) => void): this; (event: "listening", cb: (this: WebSocket) => void): this; (event: "stream", cb: (this: WebSocket, stream: WebSocketDuplex, request: IncomingMessage) => void): this; (event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this; }' is not assignable to type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: Server, error: Error) => void): this; (event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this; (event: "close" | "listening", cb: (this: Server) => void): this; (event: string | symbol, listener: (this: Server, ...args: any[]) => void): this; }'.
Types of parameters 'event' and 'event' are incompatible.
Type '"error"' is not assignable to type '"connection"'.
13 on(event: 'connection', cb: (this: WebSocket.Server, socket: WebSocket, request: http.IncomingMessage) => void): this;
~~
node_modules/websocket-stream/index.d.ts:14:5 - error TS2416: Property 'on' in type 'Server' is not assignable to the same property in base type 'Server'.
Type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: WebSocket, error: Error) => void): this; (event: "headers", cb: (this: WebSocket, headers: string[], request: IncomingMessage) => void): this; (event: "listening", cb: (this: WebSocket) => void): this; (event: "stream", cb: (this: WebSocket, stream: WebSocketDuplex, request: IncomingMessage) => void): this; (event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this; }' is not assignable to type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: Server, error: Error) => void): this; (event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this; (event: "close" | "listening", cb: (this: Server) => void): this; (event: string | symbol, listener: (this: Server, ...args: any[]) => void): this; }'.
14 on(event: 'error', cb: (this: WebSocket, error: Error) => void): this;
~~
node_modules/websocket-stream/index.d.ts:15:5 - error TS2416: Property 'on' in type 'Server' is not assignable to the same property in base type 'Server'.
Type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: WebSocket, error: Error) => void): this; (event: "headers", cb: (this: WebSocket, headers: string[], request: IncomingMessage) => void): this; (event: "listening", cb: (this: WebSocket) => void): this; (event: "stream", cb: (this: WebSocket, stream: WebSocketDuplex, request: IncomingMessage) => void): this; (event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this; }' is not assignable to type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: Server, error: Error) => void): this; (event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this; (event: "close" | "listening", cb: (this: Server) => void): this; (event: string | symbol, listener: (this: Server, ...args: any[]) => void): this; }'.
15 on(event: 'headers', cb: (this: WebSocket, headers: string[], request: http.IncomingMessage) => void): this;
~~
node_modules/websocket-stream/index.d.ts:16:5 - error TS2416: Property 'on' in type 'Server' is not assignable to the same property in base type 'Server'.
Type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: WebSocket, error: Error) => void): this; (event: "headers", cb: (this: WebSocket, headers: string[], request: IncomingMessage) => void): this; (event: "listening", cb: (this: WebSocket) => void): this; (event: "stream", cb: (this: WebSocket, stream: WebSocketDuplex, request: IncomingMessage) => void): this; (event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this; }' is not assignable to type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: Server, error: Error) => void): this; (event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this; (event: "close" | "listening", cb: (this: Server) => void): this; (event: string | symbol, listener: (this: Server, ...args: any[]) => void): this; }'.
16 on(event: 'listening', cb: (this: WebSocket) => void): this;
~~
node_modules/websocket-stream/index.d.ts:17:5 - error TS2416: Property 'on' in type 'Server' is not assignable to the same property in base type 'Server'.
Type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: WebSocket, error: Error) => void): this; (event: "headers", cb: (this: WebSocket, headers: string[], request: IncomingMessage) => void): this; (event: "listening", cb: (this: WebSocket) => void): this; (event: "stream", cb: (this: WebSocket, stream: WebSocketDuplex, request: IncomingMessage) => void): this; (event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this; }' is not assignable to type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: Server, error: Error) => void): this; (event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this; (event: "close" | "listening", cb: (this: Server) => void): this; (event: string | symbol, listener: (this: Server, ...args: any[]) => void): this; }'.
17 on(event: 'stream', cb: (this: WebSocket, stream: WebSocketDuplex, request: http.IncomingMessage) => void): this;
~~
Type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: WebSocket, error: Error) => void): this; (event: "headers", cb: (this: WebSocket, headers: string[], request: IncomingMessage) => void): this; (event: "listening", cb: (this: WebSocket) => void): this; (event: "stream", cb: (this: WebSocket, stream: WebSocketDuplex, request: IncomingMessage) => void): this; (event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this; }' is not assignable to type '{ (event: "connection", cb: (this: Server, socket: WebSocket, request: IncomingMessage) => void): this; (event: "error", cb: (this: Server, error: Error) => void): this; (event: "headers", cb: (this: Server, headers: string[], request: IncomingMessage) => void): this; (event: "close" | "listening", cb: (this: Server) => void): this; (event: string | symbol, listener: (this: Server, ...args: any[]) => void): this; }'.
18 on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
The fix seems to be changing index.d.ts from:
on(event: 'connection', cb: (this: WebSocket.Server, 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;
to:
on(event: 'connection', cb: (this: Server, socket: WebSocket, request: http.IncomingMessage) => void): this;
on(event: 'error', cb: (this: Server, error: Error) => void): this;
on(event: 'headers', cb: (this: Server, headers: string[], request: http.IncomingMessage) => void): this;
on(event: 'listening', cb: (this: Server) => void): this;
on(event: 'stream', cb: (this: Server, stream: WebSocketDuplex, request: http.IncomingMessage) => void): this;
on(event: string | symbol, listener: (this: Server, ...args: any[]) => void): this;
which matches the typings for WebSocket.Server
- Lingua principale
- JavaScript
- Stelle
- 666
- Fork
- 110
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di max-mapper/websocket-stream
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
max-mapper/websocket-stream#168 ·
-
Security Vulnerability: CVE-2024-37890- Security Level: HIGHForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
max-mapper/websocket-stream#165 · 1 commento · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
max-mapper/websocket-stream#164 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
max-mapper/websocket-stream#163 · 2 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
max-mapper/websocket-stream#162 · 2 commenti · 1 reazione ·
Tutte le issue di max-mapper/websocket-stream
Issue simili
-
Remove: Fox Deportes SDApertacheck:passed feeds:remove
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
iptv-org/database#37176 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 9 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hawk-digital-environments/HAWKI#443 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
feedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
githubnext/gh-aw-workshop#4370 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AltimateAI/vscode-dbt-power-user#2089 ·