Skip to content

Interface inheritance - extend/implement only directly implemented interfaces #282

@zolakt

Description

@zolakt

I know the title is weird, but I don't know how to describe it better.
Here is a simple example:

This C# code:

public interface A { }

public interface B : A { }

public interface C : B { }

public interface D { }

public class MyClass : C, D { }

Will generate this TS:

export interface A { }

export interface B extends A { }

export interface C extends A, B { } // A is redundant

export interface D { }

export class MyClass implements A, B, C, D { } // A and B are redundant

So when you inherit an interface, it explicitly extends all the interfaces in the tree, instead only the directly extended ones.
Similar when a class implements an interface, it explicitly implements the whole interface tree.

I know it's not a function issue, but it's needless redundancy. I have long inheritance chains, and when I add something in the middle I need to update a whole bunch of classes. Does anyone have an idea how to get rid of the redundancy?

So just to be clear, the output I'm looking for is:

export interface A { }

export interface B extends A { }

export interface C extends B { }

export interface D { }

export class MyClass implements C, D { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions