我正在尝试下面的代码,不确定是否可以告诉打字稿从任一接口假定类型
export interface CellA {
text: string;
}
export interface CellB {
date: Date;
}
var cell = {};
const { date, text } = cell as (CellA | CellB);
console.log(date, text);
TS 错误:类型“CellA | ”上不存在属性“日期” 细胞B'。(2339)
我所追求的是让打字稿假设被破坏的变量存在于任一接口中。
炎炎设计
茅侃侃
慕村9548890
饮歌长啸
相关分类