在接口上使用省略的Typescript

在接口上使用省略的Typescript,typescript,Typescript,我有一系列MyType类型的产品 export type MyType = | { type: "one"; data: Product } | { type: "two"; data: Product } | { type: "three"; data: OtherProduct }; 然后我使用一个过滤器来构建一个数组 第一类和第二类 是否可以使用省略? 像 键入My=Omit;(不起作用) 类型产品={} 键入Oth

我有一系列MyType类型的产品

export type MyType = 
 | { type: "one"; data: Product } 
 | { type: "two"; data: Product } 
 | { type: "three"; data: OtherProduct };
然后我使用一个过滤器来构建一个数组 第一类和第二类

是否可以使用省略? 像

键入My=Omit;(不起作用)
类型产品={}
键入OtherProduct={}
导出类型MyType=
|{类型:“一”;数据:产品}
|{类型:“两个”;数据:产品}
|{类型:“三”;数据:OtherProduct};
类型结果=排除
使用
Exclude
而不是省略。忽略对接口属性的操作,排除对联合类型的操作

type My = Omit<MyType, '{ type: "three"; data: number }'>; (doesn't work)