Reputation: 2811
I'm getting stuck with a type error in typescript:
this is a sample code:
type myFunctionType<T, U> = (t: T, u: U) => U;
const testRoutine = <T, U>(myFn: (t: T, u: U) => U) => { };
const testRoutine2 = <T, U>(myFn: myFunctionType) => { };
I get the following error from typescript compiler on testRoutine2
error TS2314: Generic type 'myFunctionType' requires 2 type argument(s).
testRoutine look exactly as testRoutine2 so why that error from compiler? anybody can help? thanks
Upvotes: 0
Views: 59
Reputation: 30545
try in this way
const testRoutine2 = <T, U>(myFn: myFunctionType<T,U>) => { };
Upvotes: 2