【发布时间】:2019-02-01 18:42:32
【问题描述】:
//Person Type
type Person{
canDisplayButton:boolean,
anotherEmail:string
}
const canEdit:boolean = person.canDisplayButton && data.anotherEmail;
Flow 抛出错误,提示 anotherEmail: string (This type is incompatible with boolean)
如何解决这个问题?
【问题讨论】:
-
如果要判断是否定义了
data.anotherEmail,能不能不用!!data.anotherEmail判断变量的真实性? -
是的,
!!工作。使用Boolean()也有效。 -
在这种情况下,我已将其更改为答案 - 请@titogeo 将其标记为正确?
-
感谢 titogeo,非常感谢!