Skip to content

Code duplication when declaring an ambient class implementing an interface #2653

Closed
@knuton

Description

@knuton

Ambient class declarations implementing an interface require the user to repeat the type members declared in the interface.

For example with the interface

interface IFoo {
    bar: string;
    qux(): number;
}

an ambient declaration of Foo as

declare class Foo implements IFoo {}

fails with Class 'Foo' incorrectly implements interface 'IFoo'. Property 'bar' is missing in type 'Foo', while the following works as expected, but duplicates all declarations:

declare class Foo implements IFoo {
    bar: string;
    qux(): number;
}

While it should be possible to specialise when declaring an ambient class, it would be very convenient if unchanged type members would not need to be redeclared.

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