@@ -781,10 +781,11 @@ func TestMaps(t *testing.T) {
781
781
converter := New ().
782
782
AddType (reflect .TypeOf (WithMap {})).
783
783
WithConstructor (true ).
784
+ WithPrefix ("API_" ).
784
785
WithBackupDir ("" )
785
786
786
787
desiredResult := `
787
- export class Address {
788
+ export class API_Address {
788
789
duration: number;
789
790
text?: string;
790
791
@@ -794,16 +795,16 @@ func TestMaps(t *testing.T) {
794
795
this.text = source["text"];
795
796
}
796
797
}
797
- export class WithMap {
798
+ export class API_WithMap {
798
799
simpleMap: {[key: string]: number};
799
- mapObjects: {[key: string]: Address };
800
- ptrMapObjects?: {[key: string]: Address };
800
+ mapObjects: {[key: string]: API_Address };
801
+ ptrMapObjects?: {[key: string]: API_Address };
801
802
802
803
constructor(source: any = {}) {
803
804
if ('string' === typeof source) source = JSON.parse(source);
804
805
this.simpleMap = source["simpleMap"];
805
- this.mapObjects = this.convertValues(source["mapObjects"], Address , true);
806
- this.ptrMapObjects = this.convertValues(source["ptrMapObjects"], Address , true);
806
+ this.mapObjects = this.convertValues(source["mapObjects"], API_Address , true);
807
+ this.ptrMapObjects = this.convertValues(source["ptrMapObjects"], API_Address , true);
807
808
}
808
809
809
810
` + tsConvertValuesFunc + `
@@ -817,15 +818,15 @@ func TestMaps(t *testing.T) {
817
818
}
818
819
819
820
testConverter (t , converter , true , desiredResult , []string {
820
- `new WithMap (` + jsonizeOrPanic (json ) + `).simpleMap.aaa == 1` ,
821
- `(new WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb) instanceof Address ` ,
822
- `!((new WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb) instanceof WithMap )` ,
823
- `new WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb.duration == 1` ,
824
- `new WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb.text === "txt1"` ,
825
- `(new WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc) instanceof Address ` ,
826
- `!((new WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc) instanceof WithMap )` ,
827
- `new WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc?.duration === 2` ,
828
- `new WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc?.text === "txt2"` ,
821
+ `new API_WithMap (` + jsonizeOrPanic (json ) + `).simpleMap.aaa == 1` ,
822
+ `(new API_WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb) instanceof API_Address ` ,
823
+ `!((new API_WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb) instanceof API_WithMap )` ,
824
+ `new API_WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb.duration == 1` ,
825
+ `new API_WithMap (` + jsonizeOrPanic (json ) + `).mapObjects.bbb.text === "txt1"` ,
826
+ `(new API_WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc) instanceof API_Address ` ,
827
+ `!((new API_WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc) instanceof API_WithMap )` ,
828
+ `new API_WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc?.duration === 2` ,
829
+ `new API_WithMap (` + jsonizeOrPanic (json ) + `)?.ptrMapObjects?.ccc?.text === "txt2"` ,
829
830
})
830
831
}
831
832
0 commit comments