I am trying to refactor a generic function into accepting parameters as a single object
function test<T>(a: string, b: T, c: number)
Instead, I want the function to receive an object like this:
function test(params: {a: string; b: T, c: number})
I understand that I can create a generic object type using TypeScript
type MyObject<T> = {a: string; b: T, c: number}
However, I am struggling with how to handle the generic parameter when using this type as a function parameter
function test(params: MyObject<T>) // Where should I define T?
I have attempted to destructure the params type to specify the generic parameter, but it did not work as expected
function test<{_, T, __}>(params: MyObject<T>) // This approach did not achieve the intended result
Any advice or suggestions would be greatly appreciated. Thank you.