Typescript 如何将一个类型的所有属性继承到另一个类型和其他类型中
我有两种类型,一种继承另一种的所有属性,所以我在子对象上重写它们。写这个有捷径吗Typescript 如何将一个类型的所有属性继承到另一个类型和其他类型中,typescript,Typescript,我有两种类型,一种继承另一种的所有属性,所以我在子对象上重写它们。写这个有捷径吗 type Parent = { a: string, b: string } type Child = { a: string, b: string, c: number } 基于 您可以这样做: 类型父项={ a:弦, b:字符串 } 键入Child=Parent&{c:number} 键入Child=Parent&{…}?这是否回答了您的问题?
type Parent = {
a: string,
b: string
}
type Child = {
a: string,
b: string,
c: number
}
基于
您可以这样做:
类型父项={
a:弦,
b:字符串
}
键入Child=Parent&{c:number}
键入Child=Parent&{…}
?这是否回答了您的问题?