-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Primitives.ts
115 lines (93 loc) · 2.17 KB
/
Primitives.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
import {Float, Integer, prefab} from '@diez/engine';
import {Color} from '@diez/prefabs';
interface ChildComponentData {
diez: number;
}
class ChildComponent extends prefab<ChildComponentData>() {
defaults = {
diez: 0,
};
}
interface NestedPrefabComponentData {
diez: number;
child: ChildComponent;
color: Color;
}
class NestedPrefabComponent extends prefab<NestedPrefabComponentData>() {
defaults = {
diez: 0,
child: new ChildComponent(),
color: Color.hex('#fff'),
};
}
const colorBlack = Color.hex('#000');
const colorRed = Color.hex('#CE0000');
const child = new ChildComponent({
diez: 2,
});
const nestedPrefabComponent = new NestedPrefabComponent({
child,
diez: 1,
color: colorBlack,
});
const nestedPrefabComponentWithRedColor = new NestedPrefabComponent({
child,
diez: 1,
color: colorRed,
});
class EmptyComponent {}
const references = {
myRef: 10,
};
enum TEST_ENUM {
VALUE_1,
VALUE_2,
VALUE_3,
}
enum TEST_ENUM_STRING {
VALUE_1= 'VALUE_1',
VALUE_2= 'VALUE_2',
VALUE_3= 'VALUE_3',
}
/**
* Test object comment
*/
export const primitives = {
/**
* Test property comment
*/
number: 10,
integer: 10 as Integer,
float: 10.0 as Float,
string: 'ten',
boolean: !!10,
// Lists of consistent depth and typing should carry through without issue.
integers: [[1, 2], [3, 4], [5]],
strings: [[['6'], ['7']], [['8'], ['9']], [['10']]],
emptyList: [] as string[],
// This child component should override the default value.
child: new ChildComponent({diez: 10}),
// Lists of components should also succeed.
childs: [[new ChildComponent({diez: 10})]],
emptyChild: new EmptyComponent(),
// simple nested object
nested: {
propNumber: 10,
propPrefab: new ChildComponent({diez: 10}),
},
nestedPrefabs: nestedPrefabComponent,
nestedPrefabsWithOverride: nestedPrefabComponentWithRedColor,
// nested object with litteral string as property key
nestedStringProp: {
'prop string': 10,
},
// nested object with enum as property keys
nestedEnumProp: {
[TEST_ENUM.VALUE_1]: 10,
[TEST_ENUM_STRING.VALUE_1]: 10,
},
/**
* References too!
*/
referred: references.myRef,
};