Merge pull request #24081 from orblazer/patch-1

[UWS] Fix "this" context on "on" functions
This commit is contained in:
Armando Aguirre
2018-03-06 12:30:45 -08:00
committed by GitHub

17
types/uws/index.d.ts vendored
View File

@@ -1,6 +1,7 @@
// Type definitions for uWS 0.13
// Project: https://github.com/uWebSockets/uWebSockets
// Definitions by: York Yao <https://github.com/plantain-00>
// Orblazer <https://github.com/orblazer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -59,13 +60,13 @@ declare class WebSocket extends events.EventEmitter {
addEventListener(method: string, listener?: (...args: any[]) => void): void;
// Events
on(event: 'error', cb: (err: Error) => void): this;
on(event: 'close', cb: (code: number, message: string) => void): this;
on(event: 'message', cb: (data: any, flags: { binary: boolean }) => void): this;
on(event: 'ping', cb: (data: any, flags: { binary: boolean }) => void): this;
on(event: 'pong', cb: (data: any, flags: { binary: boolean }) => void): this;
on(event: 'open', cb: () => void): this;
on(event: string, listener: (...args: any[]) => void): this;
on(event: 'error', cb: (this: this, err: Error) => void): this;
on(event: 'close', cb: (this: this, code: number, message: string) => void): this;
on(event: 'message', cb: (this: this, data: any, flags: { binary: boolean }) => void): this;
on(event: 'ping', cb: (this: this, data: any, flags: { binary: boolean }) => void): this;
on(event: 'pong', cb: (this: this, data: any, flags: { binary: boolean }) => void): this;
on(event: 'open', cb: (this: this) => void): this;
on(event: string, listener: (this: this, ...args: any[]) => void): this;
addListener(event: 'error', cb: (err: Error) => void): this;
addListener(event: 'close', cb: (code: number, message: string) => void): this;
@@ -141,7 +142,7 @@ declare namespace WebSocket {
// Events
on(event: 'error', cb: (err: Error) => void): this;
on(event: 'headers', cb: (headers: string[]) => void): this;
on(event: 'connection', cb: (client: WebSocket) => void): this;
on(event: 'connection', cb: (this: WebSocket, client: WebSocket) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
addListener(event: 'error', cb: (err: Error) => void): this;