Here is a minimal example.
And code copied:
class Obj {
_obj: Map<string, Obj>;
constructor() {
this._obj = new Map();
}
toString(): string {
const keys = this._obj.keys();
const objs: string[] = new Array<string>(keys.length);
// log(this.keys)
for (let i: i32 = 0; i < keys.length; i++) {
const key = keys[i];
const keyStr = `"${key}"`;
const value = this._obj.get(key);
const valStr = value.toString();
const str = `"${key}":${value.toString()}`;
objs[i] = str;
}
return `{${objs.join(",")}}`;
}
}
const obj = new Obj();
const child = new Obj();
child._obj.set("isChild", new Obj())
obj._obj.set("child", child)
export function interpolate(): string {
return obj.toString()
}
Running the example returns:
{"isChild":{"isChild":{}}}
But should be
Changing value.toString() to valStr fixes the issue.