@@ -19,8 +19,12 @@ type ComplexStruct struct {
1919 T time.Time `json:"t,omitempty"` // automatically handled
2020 NullOther * OtherStruct `json:"o,omitempty"`
2121 NoNullOther * OtherStruct `json:"nno,omitempty" ts:",no-null"`
22+ Data Data `json:"d"`
23+ DataPtr * Data `json:"dp"`
2224}
2325
26+ type Data map [string ]interface {}
27+
2428func ExampleComplexStruct () {
2529 s2ts := struct2ts .New (nil )
2630 s2ts .Add (ComplexStruct {})
@@ -74,7 +78,7 @@ func ExampleComplexStruct() {
7478 // for (const k of Object.keys(o)) {
7579 // const v: any = o[k];
7680 // if (!v) continue;
77- // d[k] = ToObject(v, typeOrCfg[k] || '' , true);
81+ // d[k] = ToObject(v, typeOrCfg[k] || {} , true);
7882 // }
7983 //
8084 // return d;
@@ -106,6 +110,8 @@ func ExampleComplexStruct() {
106110 // t: Date;
107111 // o: ComplexStructOtherStruct | null;
108112 // nno: ComplexStructOtherStruct;
113+ // d: { [key: string]: any };
114+ // dp: { [key: string]: any } | null;
109115 //
110116 // constructor(data?: any) {
111117 // const d: any = (data && typeof data === 'object') ? ToObject(data) : {};
@@ -116,6 +122,8 @@ func ExampleComplexStruct() {
116122 // this.t = ('t' in d) ? ParseDate(d.t) : new Date();
117123 // this.o = ('o' in d) ? new ComplexStructOtherStruct(d.o) : null;
118124 // 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;
119127 // }
120128 //
121129 // toObject(): any {
@@ -128,10 +136,12 @@ func ExampleComplexStruct() {
128136 // }
129137 //
130138 // // 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+ // };
137147}
0 commit comments