Issues with TypeScript dictionary -



Issues with TypeScript dictionary -

i'm trying create dictionary/hashmap in typescript, , read however, when trying example, errors ' = expected ' , 'invalid left-hand look ', both in line 'axis["vertical"] = 4; line x: number = axis["vertical"]; not complain however. there using within class i've misunderstood, or overlooking something?

this code:

var axis: { [id: string]: number; } = {"vertical": 0, "horizontal": 0}; export class input { x: number = axis["vertical"]; axis["vertical"] = 4; }

i've tried this, same result.

var axis: axismap = {"vertical": 4}; export class input { x: number = axis["vertical"]; axis["vertical"] = 4; } interface axismap { [id: string]: number; }

you can't have arbitrary statements in class body. can this:

var axis: { [id: string]: number; } = {"vertical": 0, "horizontal": 0}; export class input { x: number = axis["vertical"]; constructor() { axis["vertical"] = 4; } }

dictionary typescript

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -