Skip to content

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

@RebeccaStevens

Description

@RebeccaStevens

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions