Currently on my Typescript learning journey, I encountered an error that states
Generic type 'BallInterface' requires 2 type argument(s)
in relation to tennisBall. How can I properly call a function with an object parameter containing multiple generic types? What is causing this error to be thrown? Below is the complete code snippet:
const addId = <T extends object>(obj: T) =>{
const id = 3;
return {
...obj,
id
}
}
interface BallInterface<T, V>{
name: string
data: T
meta: V
}
const ball: BallInterface<{meta: string}, string> = {
name: "Tennis",
data:{meta: "for playing"},
meta: "Mario"
}
const tennisBall = addId<BallInterface>(ball);