forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
immutability-helper.d.ts
41 lines (33 loc) · 1.07 KB
/
immutability-helper.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
// Type definitions for immutability-helper v2.0.0
// Project: https://github.com/kolodny/immutability-helper
// Definitions by: Sean Kelley <https://github.com/seansfkelley>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "immutability-helper" {
interface UpdateSpecCommand {
$set?: any;
$merge?: {};
$apply?(value: any): any;
[customCommand: string]: any;
}
interface UpdateSpecPath {
[pathPart: string]: UpdateSpec;
}
type UpdateSpec = UpdateSpecCommand | UpdateSpecPath;
interface UpdateArraySpec extends UpdateSpecCommand {
$push?: any[];
$unshift?: any[];
$splice?: any[][];
[customCommand: string]: any;
}
type CommandHandler = (specValue: any, originalValue: any) => any;
interface UpdateFunction {
(value: any[], spec: UpdateArraySpec): any[];
(value: {}, spec: UpdateSpec): any;
extend: (commandName: string, handler: CommandHandler) => any;
}
interface Update extends UpdateFunction {
newContext(): UpdateFunction;
}
const update: Update;
export = update;
}