Minimal socket surface (the browser WebSocket satisfies this).

interface SocketLike {
    onclose: null | () => void;
    onerror?: null | () => void;
    onmessage: null | (ev: { data: string }) => void;
    onopen: null | () => void;
    readyState?: number;
    close(): void;
    send(data: string): void;
}

Properties

onclose: null | () => void
onerror?: null | () => void
onmessage: null | (ev: { data: string }) => void
onopen: null | () => void
readyState?: number

1 === OPEN (browser WebSocket.OPEN). Used to gate sends.

Methods