Typescript 使用默认值分解多个类型

Typescript 使用默认值分解多个类型,typescript,default-value,destructuring,Typescript,Default Value,Destructuring,我想对具有公共属性和其他默认值的多个类型使用解构 接口软件{ id:编号; 名称:字符串; } 接口版本软件扩展了SoftwareShape{ 版本:字符串; } 我尝试了以下两种解决方案 函数post1({id,version=''}:软件| VersionedSoftware){ // ... } 函数post2({id,…versioned}:软件| VersionedSoftware){ const{version=''}=版本化; // ... } 但是有错误 类型“Softwar

我想对具有公共属性和其他默认值的多个类型使用解构

接口软件{
id:编号;
名称:字符串;
}
接口版本软件扩展了SoftwareShape{
版本:字符串;
}
我尝试了以下两种解决方案

函数post1({id,version=''}:软件| VersionedSoftware){
// ...
}
函数post2({id,…versioned}:软件| VersionedSoftware){
const{version=''}=版本化;
// ...
}
但是有错误

类型“Software | VersionedSoftware”上不存在属性“version”

我希望它能像我为version属性定义的默认值那样工作

有任何语法允许这种用法吗