Skip to content

Extension method on interfaces and objects as in C#Β #57280

Closed
@muhamedkarajic

Description

@muhamedkarajic

πŸ” Search Terms

typescript extensions for interfaces

βœ… Viability Checklist

⭐ Suggestion

I think a lot of people would like this feature of being able to simply call a method in the way we can do it in C#.

πŸ“ƒ Motivating Example

E.g. if you have

interface InterfaceA {

}

that you can assign to it an extension method e.g.

function functionA(interface: Interface) { }

Then you simply can do

object: InterfaceA;
object.functionA();

πŸ’» Use Cases

  1. What do you want to use this for?
    Everywhere cause it makes the code more simple.
  2. What shortcomings exist with current approaches?
    It could be that e.g. InterfaceA has already a method called functionA. That would have to be considered.
  3. What workarounds are you using in the meantime?
    None.

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