@@ -781,10 +781,11 @@ func TestMaps(t *testing.T) {
781781 converter := New ().
782782 AddType (reflect .TypeOf (WithMap {})).
783783 WithConstructor (true ).
784+ WithPrefix ("API_" ).
784785 WithBackupDir ("" )
785786
786787 desiredResult := `
787- export class Address {
788+ export class API_Address {
788789 duration: number;
789790 text?: string;
790791
@@ -794,16 +795,16 @@ func TestMaps(t *testing.T) {
794795 this.text = source["text"];
795796 }
796797 }
797- export class WithMap {
798+ export class API_WithMap {
798799 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 };
801802
802803 constructor(source: any = {}) {
803804 if ('string' === typeof source) source = JSON.parse(source);
804805 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);
807808 }
808809
809810 ` + tsConvertValuesFunc + `
@@ -817,15 +818,15 @@ func TestMaps(t *testing.T) {
817818 }
818819
819820 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"` ,
829830 })
830831}
831832
0 commit comments