From ozizka at redhat.com Wed Oct 19 01:15:06 2016 From: ozizka at redhat.com (Ondrej Zizka) Date: Wed, 19 Oct 2016 07:15:06 +0200 Subject: [windup-dev] TypeScript static data and inheritance Message-ID: <364fc58e-0c65-03a6-0cff-50389797be33@redhat.com> 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 |classA {staticfoo =[-1];staticgetLastFoo(){returnA.foo[A.foo.length-1];}}classB extends A {staticfoo =[1,2,3];// Did this work in TS 1.8?}B.getLastFoo();// <--- gives 3| Ondra -- -- Ondrej Zizka, Windup project, Brno -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/windup-dev/attachments/20161019/61cfd2c5/attachment-0001.html From ozizka at redhat.com Wed Oct 19 10:31:23 2016 From: ozizka at redhat.com (Ondrej Zizka) Date: Wed, 19 Oct 2016 16:31:23 +0200 Subject: [windup-dev] TypeScript static data and inheritance In-Reply-To: <364fc58e-0c65-03a6-0cff-50389797be33@redhat.com> References: <364fc58e-0c65-03a6-0cff-50389797be33@redhat.com> Message-ID: <efdfb840-7369-d1d5-6ce4-fb435077ccd3@redhat.com> 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 > > |classA {staticfoo > =[-1];staticgetLastFoo(){returnA.foo[A.foo.length-1];}}classB extends > A {staticfoo =[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 at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/windup-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/windup-dev/attachments/20161019/e8081714/attachment.html