ts 如何继承父类并修改属性?
相关代码
export interface ITableData {
flag: 0 | 1
measure_name: string
measure_value: number
result_desc: string
standard_deviation: number
standard_value: number
name: string
}
interface IMeasureData extends ITableData {
measure_value: number | string
}
const measureList: IMeasureData[] = [{ measure_value: "2" }]
可以使用工具类型
Omit
将需要修改的属性measure_value
剔除掉,然后继承剔除后的接口,并对该属性进行重新声名。(PS:如下代码中,我将原接口的属性改成可选属性,以避免赋值时的报错。)希望对题主有所帮助!