tslint-immutable icon indicating copy to clipboard operation
tslint-immutable copied to clipboard

Class member mutation in constructors is seen as initialization when it may not be. [no-object-mutation]

Open RebeccaStevens opened this issue 6 years ago • 0 comments

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.
    }
}

RebeccaStevens avatar Mar 12 '19 21:03 RebeccaStevens