I have this piece of code
const func = <T>(...args: T[]): T => {
return args[0]
}
// Expected return type: string | number
func("string", 12345)
Right now when I try doing this I will get an error on the second parameter saying
Argument of type '12345' is not assignable to parameter of type '"string"'.
How do I allow this function to take in a string and number and let the return type of func be string | number depending on the data types in the parameters?