forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmithril.d.ts
69 lines (61 loc) · 2.22 KB
/
mithril.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Type definitions for Mithril
// Project: http://lhorie.github.io/mithril/
// Definitions by: Leo Horie <https://github.com/lhorie>, Chris Bowdon <https://github.com/cbowdon>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//Mithril type definitions for Typescript
interface MithrilStatic {
(selector: string, attributes: Object, children?: any): MithrilVirtualElement;
(selector: string, children?: any): MithrilVirtualElement;
prop(value?: any): (value?: any) => any;
withAttr(property: string, callback: (value: any) => void): (e: Event) => any;
module(rootElement: Node, module: MithrilModule): void;
trust(html: string): String;
render(rootElement: Element, children?: any): void;
render(rootElement: HTMLDocument, children?: any): void;
redraw(): void;
route(rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void;
route(rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void;
route(path: string, params?: any, shouldReplaceHistory?: boolean): void;
route(): string;
route(element: Element, isInitialized: boolean): void;
request(options: MithrilXHROptions): MithrilPromise;
deferred(): MithrilDeferred;
sync(promises: MithrilPromise[]): MithrilPromise;
startComputation(): void;
endComputation(): void;
}
interface MithrilVirtualElement {
tag: string;
attrs: Object;
children: any;
}
interface MithrilModule {
controller: Function;
view: Function;
}
interface MithrilDeferred {
resolve(value?: any): void;
reject(value?: any): void;
promise: MithrilPromise;
}
interface MithrilPromise {
(value?: any): any;
then(successCallback?: (value: any) => any, errorCallback?: (value: any) => any): MithrilPromise;
}
interface MithrilXHROptions {
method: string;
url: string;
user?: string;
password?: string;
data?: any;
background?: boolean;
unwrapSuccess?(data: any): any;
unwrapError?(data: any): any;
serialize?(dataToSerialize: any): string;
deserialize?(dataToDeserialize: string): any;
extract?(xhr: XMLHttpRequest, options: MithrilXHROptions): string;
type?(data: Object): void;
config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest;
}
declare var Mithril: MithrilStatic;
declare var m: MithrilStatic;