@@ -7,14 +7,14 @@ export interface Operations<T> {
7
7
clone ( ) : T ;
8
8
9
9
/// Clone and merge
10
- merge ( key : number | string , value : T ) ;
10
+ merge ( key : number | string | null , value : T ) : any ;
11
11
12
12
/// Clone the object and update a specific key inside of it
13
- update ( key : number | string , value : T ) ;
13
+ update ( key : number | string | null , value : T ) : any ;
14
14
}
15
15
16
16
export interface TraverseCallback {
17
- ( parent , key : number | string , remainingPath : string [ ] , value ?) ;
17
+ ( parent : any , key : number | string , remainingPath : string [ ] , value ?: any ) : any ;
18
18
}
19
19
20
20
export abstract class State {
@@ -37,7 +37,7 @@ export abstract class State {
37
37
deepValue = ( < Map < string , any > > < any > deepValue ) . get ( k ) ;
38
38
}
39
39
else {
40
- deepValue = deepValue [ k ] ;
40
+ deepValue = ( deepValue as any ) [ k ] ;
41
41
}
42
42
43
43
if ( typeof fn === 'function' ) {
@@ -64,7 +64,7 @@ export abstract class State {
64
64
return State . traverse ( state , path ) ;
65
65
}
66
66
67
- static assign < State > ( state : State , path : string [ ] , value ?) {
67
+ static assign < State > ( state : State , path : string [ ] , value ?: any ) {
68
68
const operations = State . inspect ( state ) ;
69
69
70
70
if ( path . length === 0 ) {
@@ -117,7 +117,7 @@ export abstract class State {
117
117
}
118
118
119
119
static inspect < K > ( object : K ) : Operations < K > {
120
- const metaOperations = ( update , merge , clone ?) => {
120
+ const metaOperations = ( update : Function , merge : Function , clone ?: Function ) => {
121
121
const operations = {
122
122
/// Clone the object (shallow)
123
123
clone : typeof clone === 'function'
@@ -130,7 +130,7 @@ export abstract class State {
130
130
/// Merge existing values with new values
131
131
merge : ( key : string , value : K ) => {
132
132
const cloned = operations . clone ( ) ;
133
- return merge ( cloned , key , value , v => update ( cloned , key , v ) ) ;
133
+ return merge ( cloned , key , value , ( v : any ) => update ( cloned , key , v ) ) ;
134
134
}
135
135
} ;
136
136
@@ -140,7 +140,7 @@ export abstract class State {
140
140
if ( Iterable . isIterable ( object ) ) {
141
141
return metaOperations (
142
142
// Replace
143
- ( parent , key : number | string , value : K ) => {
143
+ ( parent : any , key : number | string , value : K ) => {
144
144
if ( key != null ) {
145
145
return parent . set ( key , value ) ;
146
146
}
@@ -149,7 +149,7 @@ export abstract class State {
149
149
}
150
150
} ,
151
151
// Merge
152
- ( parent , key : number | string | string [ ] , value : K ) => {
152
+ ( parent : any , key : number | string | string [ ] , value : K ) => {
153
153
if ( key ) {
154
154
return parent . mergeDeepIn ( Array . isArray ( key ) ? key : [ key ] , value ) ;
155
155
}
@@ -166,7 +166,7 @@ export abstract class State {
166
166
else if ( Array . isArray ( object ) ) {
167
167
return metaOperations (
168
168
// Replace array contents
169
- ( parent , key : number , value : K ) => {
169
+ ( parent : any , key : number , value : K ) => {
170
170
if ( key != null ) {
171
171
parent [ key ] = value ;
172
172
}
@@ -177,7 +177,7 @@ export abstract class State {
177
177
} ,
178
178
179
179
// Merge
180
- ( parent , _ , value : K , setter : ( v : K ) => K ) => {
180
+ ( parent : any , _ : any , value : K , setter : ( v : K ) => K ) => {
181
181
setter ( parent . concat ( value ) ) ;
182
182
return parent ;
183
183
} ,
@@ -189,7 +189,7 @@ export abstract class State {
189
189
else if ( object instanceof Map ) {
190
190
return metaOperations (
191
191
// Update map key
192
- ( parent , key : number | string , value : K ) => {
192
+ ( parent : any , key : number | string , value : K ) => {
193
193
if ( key != null ) {
194
194
return parent . set ( key , value ) ;
195
195
}
@@ -202,7 +202,7 @@ export abstract class State {
202
202
} ,
203
203
204
204
// Merge
205
- ( parent : Map < string , any > , _ , value : K ) => {
205
+ ( parent : Map < string , any > , _ : any , value : K ) => {
206
206
const m = new Map < string , any > ( < any > value ) ;
207
207
m . forEach ( ( value , key ) => parent . set ( key , value ) ) ;
208
208
return parent ;
@@ -217,7 +217,7 @@ export abstract class State {
217
217
else if ( object instanceof WeakSet || object instanceof Set ) {
218
218
return metaOperations (
219
219
// Update element at index in set
220
- ( parent , key : number , value : K ) => {
220
+ ( parent : any , key : number , value : K ) => {
221
221
if ( key != null ) {
222
222
return parent . set ( key , value ) ;
223
223
}
@@ -230,7 +230,7 @@ export abstract class State {
230
230
} ,
231
231
232
232
// Merge
233
- ( parent : Set < any > , _ , value ) => {
233
+ ( parent : Set < any > , _ : any , value : any ) => {
234
234
for ( const element of value ) {
235
235
parent . add ( element ) ;
236
236
}
@@ -260,15 +260,15 @@ export abstract class State {
260
260
break ;
261
261
}
262
262
return metaOperations (
263
- ( parent , key , value : K ) => {
263
+ ( parent : any , key : any , value : K ) => {
264
264
if ( key != null ) {
265
265
return Object . assign ( parent , { [ key ] : value } ) ;
266
266
}
267
267
return Object . assign ( parent , value ) ;
268
268
} ,
269
- ( parent , _ , value : K ) => {
269
+ ( parent : any , _ : any , value : K ) => {
270
270
for ( const k of Object . keys ( value ) ) {
271
- parent [ k ] = value [ k ] ;
271
+ parent [ k ] = ( value as any ) [ k ] ;
272
272
}
273
273
return parent ;
274
274
} ,
@@ -284,7 +284,7 @@ export abstract class State {
284
284
'in the mutation path should be an array, an associative container, or a set' ) ;
285
285
}
286
286
287
- static empty ( value ) : boolean {
287
+ static empty ( value : any ) : boolean {
288
288
return value == null
289
289
|| ( value . length === 0
290
290
|| ( typeof value . length === 'undefined' && Object . keys ( value ) . length === 0 ) ) ;
0 commit comments