@types/knockout.mapping 2.0.33 → 2.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- knockout.mapping/LICENSE +1 -1
- knockout.mapping/README.md +6 -7
- knockout.mapping/index.d.ts +139 -33
- knockout.mapping/package.json +13 -5
knockout.mapping/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
knockout.mapping/README.md
CHANGED
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
This package contains type definitions for Knockout.Mapping (https://github.com/SteveSanderson/knockout.mapping).
|
|
6
6
|
|
|
7
7
|
# Details
|
|
8
|
-
Files were exported from https://
|
|
8
|
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/knockout.mapping.
|
|
9
9
|
|
|
10
|
-
Additional Details
|
|
11
|
-
* Last updated:
|
|
12
|
-
* Dependencies: knockout
|
|
13
|
-
* Global values: mapping
|
|
10
|
+
### Additional Details
|
|
11
|
+
* Last updated: Tue, 11 Jan 2022 16:31:41 GMT
|
|
12
|
+
* Dependencies: [@types/knockout](https://npmjs.com/package/@types/knockout)
|
|
13
|
+
* Global values: `mapping`
|
|
14
14
|
|
|
15
15
|
# Credits
|
|
16
|
-
These definitions were written by Boris Yankov
|
|
17
|
-
// Mathias Lorenzen <https://github.com/ffMathy>.
|
|
16
|
+
These definitions were written by [Boris Yankov](https://github.com/borisyankov), [Mathias Lorenzen](https://github.com/ffMathy), and [Leonardo Lombardi](https://github.com/ltlombardi).
|
knockout.mapping/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Type definitions for Knockout.Mapping 2.0
|
|
2
2
|
// Project: https://github.com/SteveSanderson/knockout.mapping
|
|
3
|
-
// Definitions by: Boris Yankov <https://github.com/borisyankov
|
|
3
|
+
// Definitions by: Boris Yankov <https://github.com/borisyankov>
|
|
4
4
|
// Mathias Lorenzen <https://github.com/ffMathy>
|
|
5
|
+
// Leonardo Lombardi <https://github.com/ltlombardi>
|
|
5
6
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
6
|
-
// TypeScript Version: 2.
|
|
7
|
+
// TypeScript Version: 2.8
|
|
7
8
|
|
|
8
9
|
/// <reference types="knockout" />
|
|
9
10
|
|
|
@@ -12,11 +13,48 @@ export as namespace mapping;
|
|
|
12
13
|
declare var self: KnockoutMapping;
|
|
13
14
|
export = self;
|
|
14
15
|
|
|
16
|
+
type Primitives = string | number | boolean | symbol;
|
|
17
|
+
|
|
15
18
|
declare global {
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
|
|
20
|
+
type MappedType<T> =
|
|
21
|
+
[T] extends [Primitives] ? KnockoutObservable<T> :
|
|
22
|
+
[T] extends [object] ? KnockoutObservableType<T> :
|
|
23
|
+
any;
|
|
24
|
+
|
|
25
|
+
type KnockoutObservableType<T> = {
|
|
26
|
+
[P in keyof T]: T[P] extends Primitives ? KnockoutObservable<T[P]> :
|
|
27
|
+
T[P] extends any[] ? KnockoutObservableArrayType<T[P][number]> :
|
|
28
|
+
T[P] extends ReadonlyArray<any> ? KnockoutReadonlyObservableArrayType<T[P][number]> :
|
|
29
|
+
MappedType<T[P]>;
|
|
18
30
|
};
|
|
19
|
-
|
|
31
|
+
|
|
32
|
+
// Could not get this to return any when T is any. It returns a Union type of the possible values.
|
|
33
|
+
type KnockoutObservableArrayType<T> = T extends Primitives ? KnockoutObservableArray<T> : KnockoutObservableArray<KnockoutObservableType<T>>;
|
|
34
|
+
|
|
35
|
+
type KnockoutReadonlyObservableArrayType<T> = T extends Primitives ? KnockoutReadonlyObservableArray<T> : KnockoutReadonlyObservableArray<KnockoutObservableType<T>>;
|
|
36
|
+
|
|
37
|
+
type KnockoutMappingOptions<T> = KnockoutMappingSpecificOptions<T> | KnockoutMappingStandardOptions;
|
|
38
|
+
|
|
39
|
+
interface KnockoutMappingStandardOptions {
|
|
40
|
+
ignore?: string[] | undefined;
|
|
41
|
+
include?: string[] | undefined;
|
|
42
|
+
copy?: string[] | undefined;
|
|
43
|
+
observe?: string[] | undefined;
|
|
44
|
+
mappedProperties?: string[] | undefined; // Undocumented
|
|
45
|
+
deferEvaluation?: boolean | undefined; // Undocumented
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type KnockoutMappingSpecificOptions<T> = {
|
|
49
|
+
[P in keyof T]?: KnockoutPropertyMappingCallBack
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface KnockoutPropertyMappingCallBack {
|
|
53
|
+
create?: ((options: KnockoutMappingCreateOptions) => void) | undefined;
|
|
54
|
+
update?: ((options: KnockoutMappingUpdateOptions) => void) | undefined;
|
|
55
|
+
key?: ((data: any) => any) | undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
20
58
|
interface KnockoutMappingCreateOptions {
|
|
21
59
|
data: any;
|
|
22
60
|
parent: any;
|
|
@@ -26,39 +64,107 @@ declare global {
|
|
|
26
64
|
data: any;
|
|
27
65
|
parent: any;
|
|
28
66
|
target: any;
|
|
29
|
-
observable?: KnockoutObservable<any
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface KnockoutMappingOptions {
|
|
33
|
-
ignore?: string[];
|
|
34
|
-
include?: string[];
|
|
35
|
-
copy?: string[];
|
|
36
|
-
mappedProperties?: string[];
|
|
37
|
-
deferEvaluation?: boolean;
|
|
38
|
-
create?: (options: KnockoutMappingCreateOptions) => void;
|
|
39
|
-
update?: (options: KnockoutMappingUpdateOptions) => void;
|
|
40
|
-
key?: (data: any) => any;
|
|
67
|
+
observable?: KnockoutObservable<any> | undefined;
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
interface KnockoutMapping {
|
|
71
|
+
/**
|
|
72
|
+
* Checks if an object was created using KnockoutMapping
|
|
73
|
+
* @param viewModel View model object to be checked.
|
|
74
|
+
*/
|
|
44
75
|
isMapped(viewModel: any): boolean;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Creates an observable array view model. Objects on the source array are also converted to observables. Primitive types and arrays are not.
|
|
78
|
+
* If 'target' is supplied, instead, target's observable properties are updated.
|
|
79
|
+
* @param source Array to be mapped.
|
|
80
|
+
* @param options Options on mapping behavior.
|
|
81
|
+
* @param target View model object previosly mapped to be updated.
|
|
82
|
+
*/
|
|
83
|
+
fromJS<T>(source: T[], options?: KnockoutMappingOptions<T[]>, target?: KnockoutObservableArrayType<T>): KnockoutObservableArrayType<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Updates target's observable properties with those of the sources.
|
|
86
|
+
* @param source Array to be mapped.
|
|
87
|
+
* @param target View model object previosly mapped to be updated.
|
|
88
|
+
*/
|
|
89
|
+
fromJS<T>(source: T[], target: KnockoutObservableArrayType<T>): KnockoutObservableArrayType<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Creates an readonly observable array view model. Objects on the source array are also converted to observables. Primitive types and arrays are not.
|
|
92
|
+
* If 'target' is supplied, instead, target's observable properties are updated.
|
|
93
|
+
* @param source Array to be mapped.
|
|
94
|
+
* @param options Options on mapping behavior.
|
|
95
|
+
* @param target View model object previosly mapped to be updated.
|
|
96
|
+
*/
|
|
97
|
+
fromJS<T>(source: ReadonlyArray<T>, options?: KnockoutMappingOptions<ReadonlyArray<T>>, target?: KnockoutReadonlyObservableArrayType<T>): KnockoutReadonlyObservableArrayType<T>;
|
|
98
|
+
/**
|
|
99
|
+
* Updates target's observable properties with those of the sources.
|
|
100
|
+
* @param source Array to be mapped.
|
|
101
|
+
* @param target View model object previosly mapped to be updated.
|
|
102
|
+
*/
|
|
103
|
+
fromJS<T>(source: ReadonlyArray<T>, target: KnockoutReadonlyObservableArrayType<T>): KnockoutReadonlyObservableArrayType<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a view model object with observable properties for each of the properties on the source.
|
|
106
|
+
* If 'target' is supplied, instead, target's observable properties are updated.
|
|
107
|
+
* @param source Plain JavaScript object to be mapped.
|
|
108
|
+
* @param options Options on mapping behavior.
|
|
109
|
+
* @param target View model object previosly mapped to be updated.
|
|
110
|
+
*/
|
|
111
|
+
fromJS<T>(source: T, options?: KnockoutMappingOptions<T>, target?: MappedType<T>): MappedType<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Updates target's observable properties with those of the sources.
|
|
114
|
+
* @param source Plain JavaScript object to be mapped.
|
|
115
|
+
* @param target View model object previosly mapped to be updated.
|
|
116
|
+
*/
|
|
117
|
+
fromJS<T>(source: T, target: MappedType<T>): MappedType<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a view model object with observable properties for each of the properties on the source.
|
|
120
|
+
* If 'target' is supplied, instead, target's observable properties are updated.
|
|
121
|
+
* @param source JSON of a JavaScript object to be mapped.
|
|
122
|
+
* @param options Options on mapping behavior.
|
|
123
|
+
* @param target View model object previosly mapped to be updated.
|
|
124
|
+
*/
|
|
125
|
+
fromJSON(source: string, options?: KnockoutMappingOptions<any>, target?: any): any;
|
|
126
|
+
/**
|
|
127
|
+
* Updates target's observable properties with those of the sources.
|
|
128
|
+
* @param source JSON of a JavaScript object to be mapped.
|
|
129
|
+
* @param target View model object previosly mapped to be updated.
|
|
130
|
+
*/
|
|
131
|
+
fromJSON(source: string, target: any): any;
|
|
132
|
+
/**
|
|
133
|
+
* Creates an unmapped object containing only the properties of the mapped object that were part of your original JS object.
|
|
134
|
+
* @param viewModel View model object previosly mapped.
|
|
135
|
+
* @param options Options on mapping behavior.
|
|
136
|
+
*/
|
|
137
|
+
toJS<T>(viewModel: KnockoutObservable<T>, options?: KnockoutMappingOptions<T>): T;
|
|
138
|
+
toJS<T>(viewModel: KnockoutObservableArray<T>, options?: KnockoutMappingOptions<T>): T[];
|
|
139
|
+
toJS<T>(viewModel: KnockoutObservableType<T>, options?: KnockoutMappingOptions<T>): T;
|
|
140
|
+
toJS(viewModel: any, options?: KnockoutMappingOptions<any>): any;
|
|
141
|
+
/**
|
|
142
|
+
* Creates an unmapped object containing only the properties of the mapped object that were part of your original JS object. Stringify the result.
|
|
143
|
+
* @param viewModel Object with observables to be converted.
|
|
144
|
+
* @param options Options on mapping behavior.
|
|
145
|
+
*/
|
|
146
|
+
toJSON<T>(viewModel: T, options?: KnockoutMappingOptions<T>): string;
|
|
147
|
+
/**
|
|
148
|
+
* Get the default mapping options
|
|
149
|
+
*/
|
|
150
|
+
defaultOptions(): KnockoutMappingStandardOptions;
|
|
151
|
+
/**
|
|
152
|
+
* Undocumented. Reset Mapping default options.
|
|
153
|
+
*/
|
|
59
154
|
resetDefaultOptions(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Undocumented. Custom implementation of JavaScript's typeof.
|
|
157
|
+
* @param x object to check type
|
|
158
|
+
*/
|
|
60
159
|
getType(x: any): any;
|
|
61
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Undocumented.
|
|
162
|
+
*/
|
|
163
|
+
visitModel(
|
|
164
|
+
rootObject: any,
|
|
165
|
+
callback: Function,
|
|
166
|
+
options?: { visitedObjects?: any; parentName?: string | undefined; ignore?: string[] | undefined; copy?: string[] | undefined; include?: string[] | undefined; }
|
|
167
|
+
): any;
|
|
62
168
|
}
|
|
63
169
|
|
|
64
170
|
interface KnockoutObservableArrayFunctions<T> {
|
|
@@ -75,7 +181,7 @@ declare global {
|
|
|
75
181
|
mappedDestroyAll(): void;
|
|
76
182
|
}
|
|
77
183
|
|
|
78
|
-
interface KnockoutStatic {
|
|
184
|
+
interface KnockoutStatic { // this is a declaration merging with knockout's interface
|
|
79
185
|
mapping: KnockoutMapping;
|
|
80
186
|
}
|
|
81
187
|
}
|
knockout.mapping/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/knockout.mapping",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.37",
|
|
4
4
|
"description": "TypeScript definitions for Knockout.Mapping",
|
|
5
|
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/knockout.mapping",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"contributors": [
|
|
7
8
|
{
|
|
@@ -10,20 +11,27 @@
|
|
|
10
11
|
"githubUsername": "borisyankov"
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
|
-
"name": "
|
|
14
|
+
"name": "Mathias Lorenzen",
|
|
14
15
|
"url": "https://github.com/ffMathy",
|
|
15
16
|
"githubUsername": "ffMathy"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Leonardo Lombardi",
|
|
20
|
+
"url": "https://github.com/ltlombardi",
|
|
21
|
+
"githubUsername": "ltlombardi"
|
|
16
22
|
}
|
|
17
23
|
],
|
|
18
24
|
"main": "",
|
|
25
|
+
"types": "index.d.ts",
|
|
19
26
|
"repository": {
|
|
20
27
|
"type": "git",
|
|
21
|
-
"url": "https://
|
|
28
|
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
|
29
|
+
"directory": "types/knockout.mapping"
|
|
22
30
|
},
|
|
23
31
|
"scripts": {},
|
|
24
32
|
"dependencies": {
|
|
25
33
|
"@types/knockout": "*"
|
|
26
34
|
},
|
|
27
|
-
"typesPublisherContentHash": "
|
|
28
|
-
"typeScriptVersion": "
|
|
35
|
+
"typesPublisherContentHash": "6ba47fc51cd64cd605a372e38acf9a3e911e9b9bea060732350546087f8efd55",
|
|
36
|
+
"typeScriptVersion": "3.8"
|
|
29
37
|
}
|