In my current project, I am using typescript and working on defining an interface that has the following structure:
interface SelectProps<T> {
options: T[];
labelKey: keyof T;
valueKey: keyof T;
}
The type T in this interface can vary in shape, but it must have label and key properties that are both strings. I want to ensure that T[labelKey]
and T[valueKey]
are always strings. How can I achieve this?