【发布时间】:2022-09-26 12:02:50
【问题描述】:
这就是我在 interface 中定义默认值的方式,因为有时它是字符串,有时是数组,我正在做映射,当我确定它将是数组时。但是我得到了 ts 错误 2339。
interface ABC {
defaultValue?: string | ILabelValue[];
}
// below is my code
x.defaultValue.map(e=>e.value) // I am getting error map does not exist on type string | ILabelValue[]
标签: arrays typescript compiler-errors type-safety