Hey there, I have some code that looks like this:
export type Options = Record<string, string>
export type CheckboxValue<T extends Options> = Partial<
Record<keyof T, boolean>
>
export type Checkbox<T extends Options> = {
value: CheckboxValue<T>
}
export function Checkbox<T extends Options>({
value,
}: Checkbox<T>) {
return value
}
export type FilterProps<T extends Options> = {
options: T
value: string[]
}
export function Filter<T extends Options>(
props: FilterProps<T>,
) {
const { value = [] } = props
const mappedValue = (() => {
const contextValue: string[] = value
const result = {}
for (const item of contextValue) {
/*
* Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
* No index signature with a parameter of type 'string' was found on type '{}'.(7053)
*/
result[item] = true
}
return result
})()
return Checkbox({value: mappedValue})
}
Can anyone tell me why this error is occurring and how to resolve it?