It looks like this.foo still works, only it was made private in the super class so it looked like it didn't.


Ondra



--
Ondrej Zizka, Windup project, Brno
On 19.10.2016 07:15, Ondrej Zizka wrote:

Hi devs,

I am looking for a mechanism to have some static methods operating on data which can be overriden.

U used to do it with an overriden static member, but it seems that TypeScript got stricter and doesn't allow that anymore.

How would you implement that?  Is there some singleton concept in TypeScript?


Thanks, Ondra


class A {
    static foo = [-1];
    static getLastFoo(){ return A.foo[A.foo.length-1]; } 
}

class B extends A {
    static foo = [1,2,3]; // Did this work in TS 1.8?
}

B.getLastFoo(); // <--- gives 3


Ondra


-- 
--
Ondrej Zizka, Windup project, Brno


_______________________________________________
windup-dev mailing list
windup-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/windup-dev