The use of this in a static context results in undefined. Typescript doesn't seem to catch this either, but this is a problem with generation I think.
The following slightly expanded example shows how the issue can produce more obvious breakage:
public class ThingA {
void somefunc() {
new InnerX(this);
}
public static class InnerX {
InnerX(ThingA a) {
a.new InnerY();
}
}
public class InnerY {
InnerY() {}
}
}
produces the error property '__parent' does not exist on type 'InnerX' with this generated code:
/* Generated from Java with JSweet 2.4.0-SNAPSHOT - http://www.jsweet.org */
namespace jsweettest.moda {
export class ThingA {
somefunc() {
new ThingA.InnerX(this);
}
}
ThingA["__class"] = "jsweettest.moda.ThingA";
export namespace ThingA {
export class InnerX {
constructor(a : jsweettest.moda.ThingA) {
new ThingA.InnerY(this.__parent);
}
}
InnerX["__class"] = "jsweettest.moda.ThingA.InnerX";
export class InnerY {
public __parent: any;
constructor(__parent: any) {
this.__parent = __parent;
}
}
InnerY["__class"] = "jsweettest.moda.ThingA.InnerY";
}
}
produces
The use of
this
in a static context results inundefined
. Typescript doesn't seem to catch this either, but this is a problem with generation I think.The following slightly expanded example shows how the issue can produce more obvious breakage:
produces the error
property '__parent' does not exist on type 'InnerX'
with this generated code: