【发布时间】:2020-04-20 13:14:21
【问题描述】:
任务是重命名接口键。嵌套级别可能会有所不同。例如:
interface Foo {
_id: string
nested: {
_id: string
nested: {
_id: number
}
}
}
// how to create another type that looks like type below?
type Bar = {
id: string
nested: {
id: string,
nested: {
id: number
}
}
}
因此,在本例中,我想将所有 _id 键重命名为 id,但类型应保持不变。
【问题讨论】:
标签: typescript types