Jake
Jake

Reputation: 422

typescript getter functions and visual studio

I am writing getter function in my typescript classes in visual studio. I like getter function because I feel it cleans up my code, there is one situation I want to fix though.

class Foo {

  doWork(){
    console.log(this.bar);
    this.bar = 2;
  }

  get bar(){
    return 1;
  }

}

the first line in doWork is correct and there is no complaints from visual studio. Its the second line that I want to fix. When the code is transpiled it throws an error in the client like it should but visual studio doesnt know to complain and underline the second line. I was wondering if there was some visual studio setting that could get it to say that the second line is incorrect

Upvotes: 0

Views: 49

Answers (1)

Misaz
Misaz

Reputation: 3985

This bug was solved in TypeScript version 2.0. For more insformations read TypeScript's GitHub issue https://github.com/Microsoft/TypeScript/issues/12.

You need to upgrade your TypeScript compiler. Download new TypeScript installer from http://www.typescriptlang.org/index.html#download-links (Visual Studio 2015 link) and just install.

Upvotes: 1

Related Questions