Reputation: 664
Given interface for curried function with one parameter
interface CurriedFunction1<T1, R> {
(): CurriedFunction1<T1, R>
(t1: T1): R
}
How can I declare generic function of that type?
The following declartions don't work:
declare let myFunction: CurriedFunction1<T[], string> // Cannot find name 'T'.
declare let myFunction2:<T>CurriedFunction1<T[], string> // '( expected.
Upvotes: 1
Views: 505
Reputation: 30889
Thanks to your comment, I now understand what you're trying to do! It's not possible. The list of type parameters of the call signature is fixed when the call signature is declared in the interface, and there is no support for adding universal quantification of type variables to an existing type such as CurriedFunction1<T[], string>
. The closest you could come would be to introduce a wrapper function that has to be called with a type argument to get the actual CurriedFunction1
:
declare let myFunction: <T>() => CurriedFunction1<T[], string>
Upvotes: 2