[phoenix | absinthe__socket] Update Socket types (#65636)

* Add `replaceTransport` method to `Socket` class

* Improve `Socket` event handler types

* Update Phoenix version in header

* Add `dom` TS lib to `absinthe__socket`
This commit is contained in:
Julian Luis Almandos
2023-05-31 23:11:27 +08:00
committed by GitHub
parent f620ec82ae
commit 748cf8849b
2 changed files with 10 additions and 6 deletions

View File

@@ -1,7 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,

View File

@@ -1,4 +1,4 @@
// Type definitions for phoenix 1.5
// Type definitions for phoenix 1.6
// Project: https://github.com/phoenixframework/phoenix
// Definitions by: Mirosław Ciastek <https://github.com/mciastek>
// John Goff <https://github.com/John-Goff>
@@ -68,6 +68,7 @@ export class Socket {
disconnect(callback?: () => void | Promise<void>, code?: number, reason?: string): void;
connectionState(): ConnectionState;
isConnected(): boolean;
replaceTransport(transport: new (endpoint: string) => object): void;
remove(channel: Channel): void;
channel(topic: string, chanParams?: object): Channel;
@@ -76,10 +77,10 @@ export class Socket {
log(kind: string, message: string, data: any): void;
hasLogger(): boolean;
onOpen(callback: (cb: any) => void | Promise<void>): MessageRef;
onClose(callback: (cb: any) => void | Promise<void>): MessageRef;
onError(callback: (cb: any) => void | Promise<void>): MessageRef;
onMessage(callback: (cb: any) => void | Promise<void>): MessageRef;
onOpen(callback: () => void | Promise<void>): MessageRef;
onClose(callback: (event: CloseEvent) => void | Promise<void>): MessageRef;
onError(callback: (error: Event | string | number, transport: new (endpoint: string) => object, establishedConnections: number) => void | Promise<void>): MessageRef;
onMessage(callback: (message: object) => void | Promise<void>): MessageRef;
makeRef(): MessageRef;
off(refs: MessageRef[]): void;