typescript - Unexpected token; 'constructor, function, accessor or variable' expected -


sorry newbie question, trying learn type script.

i have following class

class indexgridfunctions  {        //error on var      var blocksperrow: (windowwidth:number)=>number      = function (windowwidth)      {          return math.floor(windowwidth / 12);      };        var blockspercolumn: (windowheight: number) => number      = function (windowheight)      {          return math.floor(windowheight / 17);      };        shirtstodisplay: () => number      = function ()      {          return blocksperrow * blockspercolumn;      };    } 

i getting error @ first var. error "unexpected token; 'constructor, function, accessor or variable' expected".

what doing wrong?

tia

don't use var. invalid syntax within class body. fixed code :

class indexgridfunctions {      blocksperrow: (windowwidth: number) => number     = function (windowwidth) {         return math.floor(windowwidth / 12);     };      blockspercolumn: (windowheight: number) => number     = function (windowheight) {         return math.floor(windowheight / 17);     };      shirtstodisplay: () => number     =  () => {         return this.blocksperrow(123) * this.blockspercolumn(123);     };  }  

i did other fixes code in code ive presented:


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -