I am struggling with implementing a function that can handle a list of generic types, but for some reason, it's not accepting the arguments as expected.
interface TheInterface<T extends string> {
theRecord: Record<T, unknown>
}
const theFunction = <T extends string>(...arrayOfInterfaceType:TheInterface<T>[]) => {
return (key: keyof typeof arrayOfInterfaceType[number]['theRecord']) => key
}
const values1 = {theRecord:{value1: ""}}
const values2 = {theRecord:{value2: ""}}
const values1TheInterface: TheInterface<keyof typeof values1.theRecord> = values1
const values2TheInterface: TheInterface<keyof typeof values2.theRecord> = values2
//Works perfectly
const functionWithOneInterface = theFunction(values1TheInterface)
//Intelisense works for key
functionWithOneInterface("value1")
//Does not work
const functionWithTwoInterfaces = theFunction(values1TheInterface, values2TheInterface)
//Intellisense only works for value1
functionWithTwoInterfaces("value1", "value2")
The code snippet above is simplified but represents the same issue encountered in the actual code.