Is there a way to achieve something similar in TypeScript like the following:
export type CoordinateSelector = <T>(d: Coordinate) => d[T];
export interface LinkVerticalLineProps {
x: CoordinateSelector<'x'>;
y: CoordinateSelector<'y'>;
}
I want to avoid creating individual x
and y
coordinate selectors as shown below:
export interface LinkVerticalLineProps {
x: (d: {x: number}) => d.x;
y: (d: {y: number}) => d.y;
}
Is it possible to accomplish this type of functionality?