Skip to content

Deleting readonly class members does not give type error #11730

Closed
@pablobirukov

Description

@pablobirukov

As @mhegazy said in #6717 deleting of readonly properties should follow the same rules as writing.

TypeScript Version: 2.0.3

Code

class Foo {
    public readonly bar: Bar;
    constructor() {
        this.bar = createBar(...);
    }
    public destroy() {
        delete this.bar; // here
    }
}

Expected behavior:
tsc should give a compile-time error
Actual behavior:
No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions