forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcomb.d.ts
420 lines (344 loc) · 9.33 KB
/
tcomb.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
// Type definitions for tcomb v0.4
// Project: http://gcanti.github.io/tcomb/guide/index.html
// Definitions by: Jed Mao <https://github.com/jedmao>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module tcomb {
export var options: {
onFail: (message: string) => void;
};
/**
* Like util.format in Node.
*/
export function format(format: string, ...values: any[]): string;
export function getKind(type: T): string;
/**
* Returns a function's name or displayName if specified; otherwise,
* fallbacks on '<function<arity>>'.
*/
export function getFunctionName(fn: Function): string;
export function getTypeName(type: T): string;
/**
* Safe version of mixin, properties can be overwritten.
*/
export function mixin(target: {}, source: {}, overwrite?: boolean): any;
export var slice: typeof Array.prototype.slice;
export function shallowCopy(x: T): T;
export function update(instance: any, spec: {}): T;
/**
* If an assert fails the debugger kicks in so you can inspect the stack
* and quickly find out what's wrong.
* @param message - Useful for debugging. Formatted with values like util.format in Node.
* @param values - Sequentially inserted into the message.
*/
export function assert(condition: boolean, message?: string, ...values: any[]): void;
export function fail(message?: string): void;
interface T {
meta: {
/**
* The type kind, equal to "irreducible" for irreducible types.
*/
kind: string;
/**
* The type name.
*/
name: string;
};
displayName: string;
is(value: any): boolean;
update(instance: any, spec: {}): T;
}
interface TypePredicate {
(x: any): Bool_Instance;
}
interface Any_Instance {
}
interface Any_Static extends T {
new (value: any): Any_Instance;
(value: any): Any_Instance;
}
export var Any: Any_Static;
interface Nil_Instance {
}
interface Nil_Static extends T {
new (value: any): Nil_Instance;
(value: any): Nil_Instance;
}
export var Nil: Str_Static;
interface Str_Instance extends String {
}
interface Str_Static extends T {
new (value: string): Str_Instance;
(value: string): Str_Instance;
meta: {
/**
* The type kind, equal to "irreducible" for irreducible types.
*/
kind: string;
/**
* The type name.
*/
name: string;
/**
* The type predicate.
*/
is: TypePredicate;
};
}
export var Str: Str_Static;
interface Num_Instance extends Number {
}
interface Num_Static extends T {
new (value: number): Num_Instance;
(value: number): Num_Instance;
}
export var Num: Num_Static;
interface Bool_Instance extends Boolean {
}
interface Bool_Static extends T {
new (value: boolean): Bool_Instance;
(value: boolean): Bool_Instance;
}
export var Bool: Bool_Static;
interface Arr_Instance extends Array<any> {
}
interface Arr_Static extends T {
new (value: any[]): Arr_Instance;
(value: any[]): Arr_Instance;
}
export var Arr: Arr_Static;
interface Obj_Instance extends Object {
}
interface Obj_Static extends T {
new (value: Object): Obj_Instance;
(value: Object): Obj_Instance;
}
export var Obj: Obj_Static;
interface Func_Instance extends Function {
}
interface Func_Static extends T {
new (value: Function): Func_Instance;
(value: Function): Func_Instance;
}
export var Func: Func_Static;
interface Err_Instance extends Error {
}
interface Err_Static extends T {
new (value: Error): Err_Instance;
(value: Error): Err_Instance;
}
export var Err: Err_Static;
interface Re_Instance extends RegExp {
}
interface Re_Static extends T {
new (value: RegExp): Re_Instance;
(value: RegExp): Re_Instance;
}
export var Re: Re_Static;
interface Dat_Instance extends Date {
}
interface Dat_Static extends T {
new (value: Date): Dat_Instance;
(value: Date): Dat_Instance;
}
export var Dat: Dat_Static;
interface Type_Instance {
}
interface Type_Static extends T {
new (value: any): Type_Instance;
(value: any): Type_Instance;
}
export var Type: Type_Static;
/**
* @param name - The type name.
* @param is - A predicate.
*/
export function irreducible(name: string, is: TypePredicate): T;
/**
* @param props - A hash whose keys are the field names and the values are the fields types.
* @param name - Useful for debugging purposes.
*/
export function struct(props: Object, name?: string): typeof Struct;
export interface Struct_Static extends T {
new (value: any, mutable?: boolean): Struct_Instance;
(value: any, mutable?: boolean): Struct_Instance;
meta: {
kind: string;
name: string;
props: any[];
};
/**
* @param mixins - Contains the new props.
* @param name - Useful for debugging purposes.
*/
extend(mixins: Object, name?: string): Struct_Static;
/**
* @param mixins - Contains the new props.
* @param name - Useful for debugging purposes.
*/
extend(mixins: Struct_Static, name?: string): Struct_Static;
/**
* @param mixins - Contains the new props.
* @param name - Useful for debugging purposes.
*/
extend(mixins: Object[], name?: string): Struct_Static;
/**
* @param mixins - Contains the new props.
* @param name - Useful for debugging purposes.
*/
extend(mixins: Struct_Static[], name?: string): Struct_Static;
}
interface Struct_Instance {
}
export var Struct: Struct_Static;
/**
* @param map - A hash whose keys are the enums (values are free).
* @param name - Useful for debugging purposes.
*/
export function enums(map: Object, name?: string): T;
export module enums {
/**
* @param keys - Array of enums.
* @param name - Useful for debugging purposes.
*/
export function of(keys: string[], name?: string): T;
/**
* @param keys - String of enums separated by spaces.
* @param name - Useful for debugging purposes.
*/
export function of(keys: string, name?: string): T;
}
/**
* @param name - Useful for debugging purposes.
*/
export function union(types: T[], name?: string): Union_Static;
interface Union_Static extends T {
new (value: any, mutable?: boolean): Union_Instance;
(value: any, mutable?: boolean): Union_Instance;
meta: {
kind: string;
name: string;
types: T[];
};
dispatch(x: any): T;
}
interface Union_Instance {
}
export var Union: Union_Static;
/**
* @param type - The wrapped type.
* @param name - Useful for debugging purposes.
*/
export function maybe(type: T, name?: string): Maybe_Static;
export interface Maybe_Static extends T {
new (value: any, mutable?: boolean): Maybe_Instance;
(value: any, mutable?: boolean): Maybe_Instance;
meta: {
kind: string;
name: string;
typee: T;
};
}
interface Maybe_Instance {
}
export var Maybe: Maybe_Static;
/**
* @param name - Useful for debugging purposes.
*/
export function tuple(types: T[], name?: string): Tuple_Static;
interface Tuple_Static extends T {
new (value: any, mutable?: boolean): Tuple_Instance;
(value: any, mutable?: boolean): Tuple_Instance;
meta: {
kind: string;
name: string;
types: T[];
};
}
interface Tuple_Instance {
}
export var Tuple: Tuple_Static;
/**
* Combines old types into a new one.
* @param type - A type already defined.
* @param name - Useful for debugging purposes.
*/
export function subtype(type: T, predicate: TypePredicate, name?: string): typeof Subtype;
interface Subtype_Static extends T {
new (value: any, mutable?: boolean): Subtype_Instance;
(value: any, mutable?: boolean): Subtype_Instance;
meta: {
kind: string;
name: string;
type: T;
predicate: TypePredicate;
};
}
interface Subtype_Instance {
}
export var Subtype: Subtype_Static;
/**
* @param type - The type of list items.
* @param name - Useful for debugging purposes.
*/
export function list(type: T, name?: string): List_Static;
interface List_Static extends T {
new (value: any, mutable?: boolean): List_Instance;
(value: any, mutable?: boolean): List_Instance;
meta: {
kind: string;
name: string;
'type': T;
};
}
interface List_Instance {
}
export var List: List_Static;
/**
* @param domain - The type of keys.
* @param codomain - The type of values.
* @param name - Useful for debugging purposes.
*/
export function dict(domain: T, codomain: T, name?: string): Dict_Static;
interface Dict_Static extends T {
new (value: any, mutable?: boolean): Dict_Instance;
(value: any, mutable?: boolean): Dict_Instance;
meta: {
kind: string;
name: string;
domain: T;
codomain: T;
};
}
interface Dict_Instance {
}
export var Dict: Dict_Static;
/**
* @param type - The type of the function's argument.
* @param codomain - The type of the function's return value.
* @param name - Useful for debugging purposes.
*/
export function func(domain: T, codomain: T, name?: string): Func_Static;
/**
* @param type - The list of types of the function's arguments.
* @param codomain - The type of the function's return value.
* @param name - Useful for debugging purposes.
*/
export function func(domain: T[], codomain: T, name?: string): Func_Static;
interface Func_Static extends T {
new (value: any, mutable?: boolean): Func_Instance;
(value: any, mutable?: boolean): Func_Instance;
meta: {
kind: string;
name: string;
domain: any;
codomain: T;
};
of(fn: Function): Function;
}
interface Func_Instance {
}
export var Func: Func_Static;
}
declare module "tcomb" {
export = tcomb;
}