I have split a circle to 8 regions and want to assign a swipe direction to each. How can I best represnt this?
so far I have this:
type RegionIndexToDirectionMap = { [index: number]: string };
const regionDirectionMap: RegionIndexToDirectionMap = {
0: 'right',
1: 'top_right',
2: 'top',
3: 'top_left',
4: 'left',
5: 'bottom_left',
6: 'bottom',
7: 'bottom_right',
};
type ValueOf<T> = T[keyof T];
export type SwipeDirection = ValueOf<typeof regionDirectionMap>;
The issue with this is that SwipeDirection has type 'string' while I need it to have 'right' | 'left' | ...
How can I achieve this without needing to repeat 'right', 'left' and other direction names?