@@ -19,8 +19,12 @@ type ComplexStruct struct {
19
19
T time.Time `json:"t,omitempty"` // automatically handled
20
20
NullOther * OtherStruct `json:"o,omitempty"`
21
21
NoNullOther * OtherStruct `json:"nno,omitempty" ts:",no-null"`
22
+ Data Data `json:"d"`
23
+ DataPtr * Data `json:"dp"`
22
24
}
23
25
26
+ type Data map [string ]interface {}
27
+
24
28
func ExampleComplexStruct () {
25
29
s2ts := struct2ts .New (nil )
26
30
s2ts .Add (ComplexStruct {})
@@ -74,7 +78,7 @@ func ExampleComplexStruct() {
74
78
// for (const k of Object.keys(o)) {
75
79
// const v: any = o[k];
76
80
// if (!v) continue;
77
- // d[k] = ToObject(v, typeOrCfg[k] || '' , true);
81
+ // d[k] = ToObject(v, typeOrCfg[k] || {} , true);
78
82
// }
79
83
//
80
84
// return d;
@@ -106,6 +110,8 @@ func ExampleComplexStruct() {
106
110
// t: Date;
107
111
// o: ComplexStructOtherStruct | null;
108
112
// nno: ComplexStructOtherStruct;
113
+ // d: { [key: string]: any };
114
+ // dp: { [key: string]: any } | null;
109
115
//
110
116
// constructor(data?: any) {
111
117
// const d: any = (data && typeof data === 'object') ? ToObject(data) : {};
@@ -116,6 +122,8 @@ func ExampleComplexStruct() {
116
122
// this.t = ('t' in d) ? ParseDate(d.t) : new Date();
117
123
// this.o = ('o' in d) ? new ComplexStructOtherStruct(d.o) : null;
118
124
// this.nno = new ComplexStructOtherStruct(d.nno);
125
+ // this.d = ('d' in d) ? d.d as { [key: string]: any } : {};
126
+ // this.dp = ('dp' in d) ? d.dp as { [key: string]: any } : null;
119
127
// }
120
128
//
121
129
// toObject(): any {
@@ -128,10 +136,12 @@ func ExampleComplexStruct() {
128
136
// }
129
137
//
130
138
// // exports
131
- // export ComplexStructOtherStruct;
132
- // export ComplexStruct;
133
- // export ParseDate;
134
- // export ParseNumber;
135
- // export FromArray;
136
- // export ToObject;
139
+ // export {
140
+ // ComplexStructOtherStruct,
141
+ // ComplexStruct,
142
+ // ParseDate,
143
+ // ParseNumber,
144
+ // FromArray,
145
+ // ToObject,
146
+ // };
137
147
}
0 commit comments