-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassTransformer.d.ts
55 lines (55 loc) · 2.9 KB
/
ClassTransformer.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
import { ClassTransformOptions } from "./ClassTransformOptions";
export declare type ClassType<T> = {
new (...args: any[]): T;
};
export declare class ClassTransformer {
/**
* Converts class (constructor) object to plain (literal) object. Also works with arrays.
*/
classToPlain<T extends Object>(object: T, options?: ClassTransformOptions): Object;
classToPlain<T extends Object>(object: T[], options?: ClassTransformOptions): Object[];
/**
* Converts class (constructor) object to plain (literal) object.
* Uses given plain object as source object (it means fills given plain object with data from class object).
* Also works with arrays.
*/
classToPlainFromExist<T extends Object, P>(object: T, plainObject: P, options?: ClassTransformOptions): T;
classToPlainFromExist<T extends Object, P>(object: T, plainObjects: P[], options?: ClassTransformOptions): T[];
/**
* Converts plain (literal) object to class (constructor) object. Also works with arrays.
*/
plainToClass<T extends Object, V extends Array<any>>(cls: ClassType<T>, plain: V, options?: ClassTransformOptions): T[];
plainToClass<T extends Object, V>(cls: ClassType<T>, plain: V, options?: ClassTransformOptions): T;
/**
* Converts plain (literal) object to class (constructor) object.
* Uses given object as source object (it means fills given object with data from plain object).
* Also works with arrays.
*/
plainToClassFromExist<T extends Object, V extends Array<any>>(clsObject: T, plain: V, options?: ClassTransformOptions): T;
plainToClassFromExist<T extends Object, V>(clsObject: T, plain: V, options?: ClassTransformOptions): T[];
/**
* Converts class (constructor) object to new class (constructor) object. Also works with arrays.
*/
classToClass<T>(object: T, options?: ClassTransformOptions): T;
classToClass<T>(object: T[], options?: ClassTransformOptions): T[];
/**
* Converts class (constructor) object to plain (literal) object.
* Uses given plain object as source object (it means fills given plain object with data from class object).
* Also works with arrays.
*/
classToClassFromExist<T>(object: T, fromObject: T, options?: ClassTransformOptions): T;
classToClassFromExist<T>(object: T, fromObjects: T[], options?: ClassTransformOptions): T[];
/**
* Serializes given object to a JSON string.
*/
serialize<T>(object: T, options?: ClassTransformOptions): string;
serialize<T>(object: T[], options?: ClassTransformOptions): string;
/**
* Deserializes given JSON string to a object of the given class.
*/
deserialize<T>(cls: ClassType<T>, json: string, options?: ClassTransformOptions): T;
/**
* Deserializes given JSON string to an array of objects of the given class.
*/
deserializeArray<T>(cls: ClassType<T>, json: string, options?: ClassTransformOptions): T[];
}