SetTypeSubArg<T, SetKey, Val>: {
    [Property in keyof T]: SetKey extends Property
        ? Val
        : T[Property]
}

Replaces the value of a key in a complex generic type param

Type Parameters

  • T

    ModelType type param

  • SetKey extends keyof T

    name of the key whose value will be replaced

  • Val

    the value to set

Example

T = { fields: {}, identifier: "id"[] }
type Modified = SetTypeSubArg<T, "identifier", "customId"[]>
Modified => { fields: {}, identifier: "customId"[] }