【发布时间】:2017-06-18 12:54:18
【问题描述】:
我有一个端点,它采用 string 类型的自定义 header。
我正在使用Flow 进行类型注释,但我不确定如何像这样将注释添加到本机Type 的自定义属性上。
比如我的函数是:
function(req: Request) {
const custom = req.headers.custom_header;
}
Flow 报告the property custom_header is not found in Header。
我尝试了几种不同的方式使用类型声明:
declare var Request.headers.custom_header: string
declare var req.headers.custom_header: string
但似乎两者都不会影响错误。
【问题讨论】:
标签: javascript node.js flowtype