One task involves renaming keys within an interface while accounting for variations in nesting levels. Consider the following example:
interface Foo {
_id: string
nested: {
_id: string
nested: {
_id: number
}
}
}
// How can a new type be created to match the structure below?
type Bar = {
id: string
nested: {
id: string,
nested: {
id: number
}
}
}
In this scenario, the goal is to change all instances of _id
to id
, while keeping the type unchanged.