/
registration.ts
47 lines (45 loc) · 1.19 KB
/
registration.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
import { Class } from './class';
import { ParentOptions } from './decorator/parent-options';
/**
* Registrations allow the serializer to handle inheritance,
* they have to be defined if you want to be able to handle inheritance.
*
* ## Example:
* ```typescript
* let registrations =
* [
* {
* parent: Foo,
* children:
* {
* 'bar':Bar,
* 'baz':Baz
* }
* }
* ]
* ```
*/
export interface Registration<T = any> {
/**
* The class that all children have to extend no matter what.
*
* It can contain the discrimination logic, but if you want to handle inheritance constraint and discriminator separately,
* you have to specify the handler class in `discriminatorHandler`
*/
parent: Class<T>;
/**
* Used to define which class handles the discrimination logic, defaults to `parent`'s value.
*/
discriminatorHandler?: Class;
/**
* Possible children, by key.
*/
children: { [index: string]: Class<T> };
}
/**
* @hidden
*/
export interface ProcessedRegistration extends Registration {
parentOptions: ParentOptions;
parentHasExplicitDiscriminator: boolean;
}