I have this:
type Two = {
one: number,
two: string,
three: boolean
}
I want it to create a type that would look like this:
You need to use a mapped type for the renamed property as well:
type Two = {
one: number,
two: string,
three: boolean
}
type Rename<T, K extends keyof T, N extends string> = Pick<T, Exclude<keyof T, K>> & { [P in N]: T[K] }
type Renamed = Rename<Two, 'three', 'four'>
Note that this will not work as expected if you provide more properties:
type Renamed = Rename<Two, 'two' |'three' , 'four' | 'five'> // will be Pick<Two, "one"> & {
// four: string | boolean;
// five: string | boolean;
// }