forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
knockout.mapping.d.ts
68 lines (58 loc) · 2.15 KB
/
knockout.mapping.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
// Type definitions for Knockout.Mapping 2.0
// Project: https://github.com/SteveSanderson/knockout.mapping
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../knockout/knockout.d.ts" />
interface KnockoutMappingCreateOptions {
data: any;
parent: any;
}
interface KnockoutMappingUpdateOptions {
data: any;
parent: any;
target: any;
observable?: KnockoutObservable<any>;
}
interface KnockoutMappingOptions {
ignore?: string[];
include?: string[];
copy?: string[];
mappedProperties?: string[];
deferEvaluation?: boolean;
create?: (options: KnockoutMappingCreateOptions) => void;
update?: (options: KnockoutMappingUpdateOptions) => void;
key?: (data: any) => any;
}
interface KnockoutMapping {
isMapped(viewModel: any): boolean;
fromJS(jsObject: any): any;
fromJS(jsObject: any, targetOrOptions: any): any;
fromJS(jsObject: any, inputOptions: any, target: any): any;
fromJSON(jsonString: string): any;
fromJSON(jsonString: string, targetOrOptions: any): any;
fromJSON(jsonString: string, inputOptions: any, target: any): any;
toJS(rootObject: any, options?: KnockoutMappingOptions): any;
toJSON(rootObject: any, options?: KnockoutMappingOptions): any;
defaultOptions(): KnockoutMappingOptions;
resetDefaultOptions(): void;
getType(x: any): any;
visitModel(rootObject: any, callback: Function, options?: { visitedObjects?: any; parentName?: string; ignore?: string[]; copy?: string[]; include?: string[]; }): any;
}
interface KnockoutObservableArrayFunctions<T> {
mappedCreate(item: T): T;
mappedRemove(item: T): T[];
mappedRemove(removeFunction: (item: T) => boolean): T[];
mappedRemoveAll(items: T[]): T[];
mappedRemoveAll(): T[];
mappedDestroy(item: T): void;
mappedDestroy(destroyFunction: (item: T) => boolean): void;
mappedDestroyAll(items: T[]): void;
mappedDestroyAll(): void;
}
interface KnockoutStatic {
mapping: KnockoutMapping;
}
declare module "knockout.mapping" {
export = mapping;
}
declare var mapping: KnockoutMapping;