Skip to content

Implementation of interface requires members redeclaration #5749

Closed
@NekR

Description

@NekR
interface A {
    foo: Function;
}

class B implements A {
    constructor() {
        this.foo = () => {};
    }
}

Here TypeScript says that B incorrectly implements A and requires B to also have foo property with the same signature. So question is: why I need duplicate definition of properties when implement interface if I cannot override that definition anyway:

interface A {
    foo: Function;
}

class B implements A {
    foo: boolean;
    constructor() {
        this.foo = true;
    }
}

Here B again incorrectly implements A. Only way to fix it is to add foo:Function to B which absolutely has no point since A already has that.

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