-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
62 lines (62 loc) · 1.71 KB
/
index.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
import * as t from 'io-ts';
import { runtime } from 'ts-transformer-interface';
import { ICaster } from 'ts-transformer-decoder-cast';
/** @since 1.5.23 */
export * from './types/';
/** @since 1.0.0 */
export { runtime } from 'ts-transformer-interface';
/** @since 1.0.0 */
export declare function schema<T extends object>(): runtime.Schema;
/** @since 1.0.0 */
export interface Caster<T = any> extends t.Type<T> {}
/** @since 1.0.0 */
export interface Casters {
[type: string]: Caster;
}
/**
* Use this to attach additional values to the interface
* other than the original source.
*
* You should mark all fields inside attrs as optional since
* they are not defined from the data source.
*
* The Decoder will think it as "any" and assign an empty
* object to it.
* @since 1.5.0
* @example
* interface User {
* name: string;
* attrs: {
* marker?: google.maps.Marker
* }
* }
*/
export declare const ATTRS_KEYWORD = 'attrs';
/** @since 1.0.0 */
export declare class Decoder implements ICaster {
/** @since 1.0.0 */
readonly casters: Casters;
private todos;
private resolves;
private withAttributes;
/** @since 1.3.0 */
constructor(schemas?: runtime.Schema[], casters?: Casters);
/** @since 1.1.0 */
decode<T>(typeName: string, data: unknown, onError?: (errors: string[]) => void): T | undefined;
/** @since 1.1.0 */
decodeArray<T>(
typeName: string,
data: unknown,
onError?: (errors: string[]) => void,
): T[] | undefined;
private processResult;
/** @since 1.0.0 */
registerSchema(spec: runtime.Schema): void;
private buildCaster;
private checkRegistry;
private getCaster;
private getArrayCaster;
private buildCasters;
private buildTypeCaster;
private errors;
}