Looking to define a new structure here
type DataTableCol<T, K extends keyof T> = {
title: string;
key: K;
render?: (value: T[K]) => ReactElement;
};
In need of creating a type called DataTableRow<T>
based on the above. For instance, with
type MyData = { name: string; value: number; }
, it should look like this:
type DataTableRow<MyData> = (DataTableCol<MyData, 'name'> | DataTableCol<MyData, 'value'>)[]
This will essentially involve an array of multiple types, customized for each property in T using generics for reusability purposes. Is it achievable?