【发布时间】:2018-09-04 02:49:10
【问题描述】:
我有以下代码:
export const makeHttpHelper = function (authToken: string) {
return function ($data: any, optz: object, cb: VoidFn) {
const data = JSON.stringify($data || '\n');
const opts : http.Request.options = Object.assign({ /// <<<< here <<<<<<
method: 'POST',
host: process.env.OPENSHIFT_NODEJS_IP || 'localhost',
port: process.env.OPENSHIFT_NODEJS_PORT || '3040',
agent: false,
headers: getHeaders()
}, optz);
const req = http.request(opts, function (res) {
if (res.statusCode > 202) {
log.error(`res status => ${res.statusMessage}, ${res.statusCode}, req url => ${opts.url || opts.path}`);
}
else {
log.info(`res status => ${res.statusMessage}, ${res.statusCode}, req url => ${opts.url || opts.path}`);
}
// ....
});
....问题是http.Request.options 不正确。有谁知道作为http.request() 第一个参数的选项对象的正确类型是什么?
【问题讨论】:
标签: node.js typescript typescript-typings typescript2.0