type FormerActionsCustom =
| {
type: "ACTION_1"
payload: string
}
| {
type: "ACTION_2"
payload: number
}
type CustomConverter = ...
type UpdatedActions = CustomConverter<FormerActionsCustom, "group", "SECTION">
//expected output
type UpdatedActions =
| {
group: 'SECTION'
type: "ACTION_1"
payload: string
}
| {
group: 'SECTION'
type: "ACTION_2"
payload: number
}
In order to achieve the desired outcome, I aim to implement a CustomConverter
"type function" that accepts the specified arguments and generates a type identical (or structurally equivalent) to UpdatedActions
.
I believe leveraging mapped types for property addition along with conditional types designed for distributive operations within the |
construct might be the way to go.