Typescript 类型脚本堆叠接口
Typescript是否有子集接口的概念 有一个父界面Typescript 类型脚本堆叠接口,typescript,Typescript,Typescript是否有子集接口的概念 有一个父界面parent,看起来像: interface parent { a?: string; b?: string; } 还有其他接口一个和两个 interface one { a: string } one和two都不能添加父界面中不存在的字段。这可能吗 1和2都不能添加父接口中不存在的字段 这在某种程度上与TypeScript的结构化类型哲学背道而驰,但如果您确实需要此功能,请参阅 要点的来源可能也有助于增加上下文
parent
,看起来像:
interface parent {
a?: string;
b?: string;
}
还有其他接口一个
和两个
interface one {
a: string
}
one
和two
都不能添加父界面中不存在的字段。这可能吗
1和2都不能添加父接口中不存在的字段
这在某种程度上与TypeScript的结构化类型哲学背道而驰,但如果您确实需要此功能,请参阅
要点的来源可能也有助于增加上下文
interface two {
b: string
}