Brilliant. Спасибо.

я есть различаемый тип объединения, который различает типы на основе строкового литерального поля. Я хотел бы получить отображенный тип, который отображает все типы в объединении в соответствующие им литеральные значения дискриминатора.

например

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 types 
// comprising the union type but in an automated fashion similar to how I
// derived my Actions type.
// e.g.
type WhatIWant = {
    fetch: Fetch,
    fetched: Fetched<Product>
}

Это возможно в TypeScript?

Ответы на вопрос(1)

Ваш ответ на вопрос