TypeScript: is it possible to create a mapped union type?

typescript

Solution

It's a combination of keyof and lookup type

type AwaActionType = AwaActionTypes[keyof AwaActionTypes];

Problem

Is it possible to combine the "mapped types" and "union types" features to create an expression that takes the following interface as an input: ``` interface AwaActionTypes { CLICKLEFT: 'CL'; CLICKRIGHT: 'CR'; SCROLL: 'S'; ZOOM: 'Z'; RESIZE: 'R'; KEYBOARDENTER: 'KE'; KEYBOARDSPACE: 'KS'; OTHER: 'O'; } ``` And produces a type that is the equivalent of the following union type alias: ``` type AwaActionType: 'CL' | 'CR' | 'S' | 'Z' | 'R' | 'KE' | 'KS' | 'O'; ``` I tried using combinations of `keyof`, `|`, etc. Didn't land on something that worked. Didn't see anything in the handbook either.

Original source