【发布时间】:2019-06-15 15:45:30
【问题描述】:
import is from "is_js";
function handle_date_string(dateObj: Date | string): string {
const result = is.date(dateObj) ? dateObj.toDateString() : dateObj;
return result;
}
此函数的作用 - 如果它接收到 Date 对象,则将其转换为日期字符串,否则传递接收到的字符串。
Flow 报告以下错误:
错误:(21, 45) 无法调用
dateObj.toDateString,因为在String[1] 中缺少属性toDateString。
错误:(22, 10) 无法返回result,因为Date[1] 与字符串 [2] 不兼容。
【问题讨论】:
标签: javascript flowtype