TypeScript: derive map from discriminated union
I have a discriminated union type that differentiates types based on a string literal field. I would like to derive a mapped type that maps all of the types in the union to their corresponding discriminator literal values. e.g. export type Fetch = { type: 'fetch', dataType: string }; export type Fetched<T> = { type: 'fetched', value: T }; // union type discriminated on 'type' property export type Action = | Fetch | Fetched<Product>; // This produces a type 'fetch' | 'fetched' // from the type type Actions = Action['type']; // I want to produce a map type of the discriminator values to the