I'm quite new to TypeScript (1.8) and I have a small issue with inheritance and static properties.
Please find below the test code I'm currently running:
class A {
public static Items = {
FOO: 'A'
};
public show() {
alert(this.constructor.Items.FOO);
}
}
class B extends A {
public static Items = {
FOO: 'B'
};
}
var a = new A();
var b = new B();
a.show(); // alert "A"
b.show(); // alert "B"
This code runs fine and the two alerts are shown as expected.
BUT the TypeScript compiler throws an error : Property "Items" does not exist on type "Function"
I understand the warning and it's totally right from a TypeScript point of view, but how can I achieve the same result while making the compiler happy? this.Items.FOO obviously does not work and I didn't find a self equivalent or something like that...
Am I missing something?
Thanks in advance!
showmethod won't work when you introduce an additional subclass that does not have a staticItemsproperty, e.g.class C extends A {}