0

I am new to typescript. I want to extend a class to have a function similar to this. I have this code in C# but I want it to write in typescript

public static IQueryable<T> OrderByPropertyName<T>(this IQueryable<T> query, string attribute, string direction) {
    // my logic here
}

anyone can help me?

Rashid
  • 1,700
  • 1
  • 23
  • 56
  • To be clear, you're saying you want to extend a class *separate* from the class's original definition, right? (Since what you've shown is a C# extension method.) – T.J. Crowder Jan 18 '21 at 08:33
  • Closely related, but doesn't handle the type aspect: https://stackoverflow.com/questions/9354298/how-do-i-write-an-extension-method-in-javascript – T.J. Crowder Jan 18 '21 at 08:33
  • [Possible generic approach](https://hackernoon.com/a-extension-method-experiment-on-typescript-8o44t36xy) – Wiktor Zychla Jan 18 '21 at 08:41

0 Answers0