Using generic type parameter as parameter
问题 I'm trying to create a generic function which calls another function with an any type parameter. This is what I tried: static GetInstance<T>(): T { return <T>injector.get(T); // get(param: any): any } The problem is this doesn't compile. I'm getting Cannot find name 'T' error. I tried get(typeof T) but typeof T is string "function" . What can I do? For clarification: get() method accept types. For example you can use it like this: import { MyService } from '..' constructor(){ let val = this