Files
DefinitelyTyped/types/sockjs-client/index.d.ts
Dimitri Benin 797ba7281a [sockjs-client] export module-internal namespace globally (#18157)
* [sockjs-client] export module-internal namespace globally
to be able to reference all types defined by the module; found no other
way without breaking all dependants

* [sockjs-client] fix typo

* [sockjs-client] fix indentation

* [sockjs-client] eliminate enum that prevented merging of a const with a namespace
2017-07-24 14:26:49 -07:00

64 lines
1.7 KiB
TypeScript

// Type definitions for sockjs-client 1.0
// Project: https://github.com/sockjs/sockjs-client
// Definitions by: Emil Ivanov <https://github.com/vladev>
// Alexander Rusakov <https://github.com/arusakov/>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = SockJS;
export as namespace SockJS;
declare const SockJS: {
new (url: string, _reserved?: any, options?: SockJS.Options): SockJS.Socket;
(url: string, _reserved?: any, options?: SockJS.Options): SockJS.Socket;
prototype: SockJS.Socket;
CONNECTING: SockJS.CONNECTING;
OPEN: SockJS.OPEN;
CLOSING: SockJS.CLOSING;
CLOSED: SockJS.CLOSED;
};
declare namespace SockJS {
type CONNECTING = 0;
type OPEN = 1;
type CLOSING = 2;
type CLOSED = 3;
type State = CONNECTING | OPEN | CLOSING | CLOSED;
interface BaseEvent extends Event {
type: string;
}
type OpenEvent = BaseEvent;
interface CloseEvent extends BaseEvent {
code: number;
reason: string;
wasClean: boolean;
}
interface MessageEvent extends BaseEvent {
data: string;
}
type SessionGenerator = () => string;
interface Options {
server?: string;
sessionId?: number | SessionGenerator;
transports?: string | string[];
}
interface Socket extends EventTarget {
readyState: State;
protocol: string;
url: string;
onopen(e: OpenEvent): any;
onclose(e: CloseEvent): any;
onmessage(e: MessageEvent): any;
send(data: any): void;
close(code?: number, reason?: string): void;
}
}