0
我有一段代码,看起来像这样如何标记标记函数的返回类型为自定义类型
import * as Promise from 'bluebird';
import {Response} from '../commonInterfaces/httpService';
getCall(url: string, accessToken: string, extraHeaders: object): Promise<Response> {
let headers = this.getHeaders(accessToken, extraHeaders);
return new Promise((resolve, reject) => {
request({
url: url,
method: "GET",
withCredentials: false,
json: true,
headers: headers
}, (err: Error, response: Response) => {
if (err) {
reject(err)
} else {
resolve(response)
}
});
});
}
和响应的承诺是一个接口
interface Response {statusCode: number, body: object}
和我收到以下错误
[ts]
Type 'Bluebird<{}>' is not assignable to type 'Bluebird<Response>'.
Type '{}' is not assignable to type 'Response'.
Property 'statusCode' is missing in type '{}'.
可能是什么问题?