Fix strict TypeScript checks for server
This commit is contained in:
21
plugin/types/ws.d.ts
vendored
Normal file
21
plugin/types/ws.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
declare module "ws" {
|
||||
export type RawData = Buffer | ArrayBuffer | Buffer[] | string;
|
||||
|
||||
export class WebSocket {
|
||||
static readonly OPEN: number;
|
||||
readonly readyState: number;
|
||||
send(data: string): void;
|
||||
close(code?: number, reason?: string): void;
|
||||
on(event: "message", listener: (data: RawData) => void): this;
|
||||
on(event: "close", listener: (code: number, reason: Buffer) => void): this;
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
}
|
||||
|
||||
export class WebSocketServer {
|
||||
constructor(options: { host?: string; port: number });
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
on(event: "listening", listener: () => void): this;
|
||||
on(event: "connection", listener: (ws: WebSocket, req: import("http").IncomingMessage) => void): this;
|
||||
close(callback?: () => void): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user