mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
Types for eventsource
This commit is contained in:
15
types/eventsource/eventsource-tests.ts
Normal file
15
types/eventsource/eventsource-tests.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as EventSource from "eventsource";
|
||||
|
||||
const eventSource = new EventSource("http://foobar");
|
||||
eventSource.onmessage = (x: any) => {};
|
||||
eventSource.onerror = (x: any) => {};
|
||||
eventSource.onopen = (x: any) => {};
|
||||
eventSource.close();
|
||||
|
||||
import * as EventSourcePolyfill from "eventsource/lib/eventsource-polyfill";
|
||||
|
||||
const eventSourcePolyfill = new EventSourcePolyfill("http://foobar");
|
||||
eventSourcePolyfill.onmessage = (x: any) => {};
|
||||
eventSourcePolyfill.onerror = (x: any) => {};
|
||||
eventSourcePolyfill.onopen = (x: any) => {};
|
||||
eventSourcePolyfill.close();
|
||||
35
types/eventsource/index.d.ts
vendored
Normal file
35
types/eventsource/index.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Type definitions for eventsource 1.0
|
||||
// Project: http://github.com/EventSource/eventsource
|
||||
// Definitions by: Scott Lee Davis <https://github.com/scottleedavis>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare class EventSource {
|
||||
constructor(url: string, eventSourceInitDict?: EventSource.EventSourceInitDict);
|
||||
|
||||
static CLOSED: EventSource.ReadyState;
|
||||
static CONNECTING: EventSource.ReadyState;
|
||||
static OPEN: EventSource.ReadyState;
|
||||
|
||||
url: string;
|
||||
readyState: EventSource.ReadyState;
|
||||
onopen: EventListener;
|
||||
onmessage: EventListener;
|
||||
onerror: EventListener;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
declare namespace EventSource {
|
||||
enum ReadyState {CONNECTING = 0, OPEN = 1, CLOSED = 2}
|
||||
|
||||
interface EventSourceInitDict {
|
||||
withCredentials?: boolean;
|
||||
headers?: object;
|
||||
proxy?: string;
|
||||
https?: object;
|
||||
rejectUnauthorized?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = EventSource;
|
||||
export as namespace EventSource;
|
||||
29
types/eventsource/lib/eventsource-polyfill/index.d.ts
vendored
Normal file
29
types/eventsource/lib/eventsource-polyfill/index.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
declare class EventSource {
|
||||
constructor(url: string, eventSourceInitDict?: EventSource.EventSourceInitDict);
|
||||
|
||||
static CLOSED: EventSource.ReadyState;
|
||||
static CONNECTING: EventSource.ReadyState;
|
||||
static OPEN: EventSource.ReadyState;
|
||||
|
||||
url: string;
|
||||
readyState: EventSource.ReadyState;
|
||||
onopen: EventListener;
|
||||
onmessage: EventListener;
|
||||
onerror: EventListener;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
declare namespace EventSource {
|
||||
enum ReadyState {CONNECTING = 0, OPEN = 1, CLOSED = 2}
|
||||
|
||||
interface EventSourceInitDict {
|
||||
withCredentials?: boolean;
|
||||
headers?: object;
|
||||
proxy?: string;
|
||||
https?: object;
|
||||
rejectUnauthorized?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = EventSource;
|
||||
export as namespace EventSource;
|
||||
25
types/eventsource/tsconfig.json
Normal file
25
types/eventsource/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"eventsource-tests.ts",
|
||||
"lib/eventsource-polyfill/index.d.ts"
|
||||
]
|
||||
}
|
||||
1
types/eventsource/tslint.json
Normal file
1
types/eventsource/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user