Override JavaScript NAME property on Angular2 (typescript)

195 Views Asked by At

I'm using draw2d on angular2 (draw2d-wrapper). I'm trying extend a class from them.

export class Table extends (draw2d.shape.layout.VerticalLayout as { new(): any }) {
    static NAME: "Table";
    /*Some code*/
}

on my code when I do var t = new Table();

the t.NAME property came as "draw2d.shape.layout.VerticalLayout".

Can I override this JavaScript property in a angular2 typescript code?

1

There are 1 best solutions below

1
Titian Cernicova-Dragomir On

Since you are trying to access the property on your table instance, it's not really a static property. Simplifying your example, this works:

class VerticalLayout {
  NAME = "VerticalLayout";
}

class Table extends VerticalLayout  {  
  NAME = "Table";
}

new Table().NAME; // Table

I would expect the same to work for deriving from draw2d.shape.layout.VerticalLayout