type Original = {
bar: string;
foo: number;
fooBar: string;
};
type Replacement = ReplaceKeys<Original, 'bar', { bar: number }>;
// Result: { bar: number; foo: number; fooBar: string; }
type AnotherReplacement = ReplaceKeys<Original, 'foo', { foo: boolean }>;
// Result: { bar: string; foo: boolean; fooBar: string; }
Constructs a new type by replacing keys of type
T
in object typeU
with corresponding keys from object typeY
.