I've developed a typed function that works well for most scenarios. However, I am facing an issue when trying to handle a specific type of Argument that is currently invalid. How can I adjust my code to accommodate this type?
type Argument<T> =
| keyof T
| (keyof T)[]
| Record<keyof T, any> // <- This part needs fixing
export function customizeClassNames<T>(style) {
const handleArgs = (args: Argument<T>[]) => {}
return (...args: Argument<T>[]) => handleArgs(args)
}
const sampleObject = { prop1: {}, prop2: 2 }
const customFunc = customizeClassNames<typeof sampleObject>(sampleObject)
customFunc('prop1') //works fine
customFunc('prop1', ['prop2']) //this is also valid
customFunc('prop1', ['prop2']) //another valid example
customFunc('prop1', ['prop2'], { prop2: 2 }) //however, this one is not working as expected