Skip to content

Class with getter satisfies interface with mutable property #16171

Closed
@SrTobi

Description

@SrTobi

Consider the following code:

interface Base {
    prop: number;
}


class Impl implements Base {
    get prop(): number {
        return 3;
    }
}

let base = <Base>new Impl();
base.prop = 9;

This gives no error while compiling and even runs without any error/exception.
It should only work though, if prop was declared readonly in the Base.
Otherwise it should report that a setter is missing for prop.

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