我的使用情況:請求的RequestResponse type definition缺少body
財產,是這樣的:如何加強在d.ts打字稿接口
declare namespace request {
// ...
export interface RequestResponse extends http.IncomingMessage {
request: Options;
}
// ...
}
declare var request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>;
export = request;
我試圖用類似創建request-fix.d.ts
文件進行修復這個:
import * as http from 'http';
declare namespace request {
export interface RequestResponse extends http.IncomingMessage {
body: any;
}
}
但它沒有效果。我的最終目標是,在我的app.ts
,我可以這樣做:
import * as rp from 'request-promise';
import { RequestResponse } from 'request';
let response = rp.get(url);
response.statusCode; // works
response.body; // doesn't compile
當然,我可能只是有助於DefinitelyTyped :),但是這問題是關於以增強RequestResponse
接口。
1. request-fix.d.ts中的RequestResponse缺少'export' 2.是'tsconfig.json'中的'request'添加了request-fix.d.ts? – artem
'.d.ts'文件即使在我廢話時也不會產生任何編譯時錯誤。在我的tsconfig.json中:'「files」:[「app.ts」,「request-fix.d.ts」]'。嘗試添加'///參考...>'我的app.ts,沒有區別。 – Borek
哦'skipLibCheck'是真的。這讓我前進,至少我可以看到更多的錯誤.. – Borek