Limit usage of property setters

Prefer explicit set/get functions (e.g. setBar and getBar functions) over setters/getters.

Consider the following code:

  1. foo.bar = {
  2. a: 123,
  3. b: 456
  4. };

In the presence of setter/getters:

  1. class Foo {
  2. a: number;
  3. b: number;
  4. set bar(value:{a:number,b:number}) {
  5. this.a = value.a;
  6. this.b = value.b;
  7. }
  8. }
  9. let foo = new Foo();

This is not a good use of property setters. The person reading the first code sample has no context about all the things that will change. Where as someone calling foo.setBar(value) might have an idea that something might change on foo.

Bonus points: Find references works better if you have different functions. In TypeScript tools if you find references for a getter or a setter you get both whereas with explicit function calls you only get references to the relevant function.