tslint-immutable
tslint-immutable copied to clipboard
Class member mutation in constructors is seen as initialization when it may not be. [no-object-mutation]
Within constructors, class member initialization and mutation seem to be treated as the same thing. Only initialization should be allowed.
class Foo {
readonly bar = 1;
readonly baz: string;
constructor() {
this.bar = 2; // Should violate rule.
this.baz = "hello";
this.baz = "world"; // Should violate rule.
}
}