I have the following interfaces:
interface ColDef<Entity, Field extends keyof Entity> {
field: Field;
valueGetter(value: Entity[Field], entity: Entity): any
}
interface Options<Entity> {
colDefs: ColDef<Entity, ??>[]
}
const options: Options<{ name: string }> = {
colDefs: [{
field: 'name',
valueGetter(value) {
// how do I make value typed as string??
}
}]
}
I want to infer the entity field type in the valueGetter function. The issue is that I ColDef is required the key as the second generic, but I'm passing an array. How can I solve this?