0

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

1 Answer 1

2

try in this way

const testRoutine2 = <T, U>(myFn: myFunctionType<T,U>) => { };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.