I've got a TSLint error which says "Invalid 'await' of a non-Promise value." for the following line:
const response: RequestResponse = <RequestResponse>await this.apiRequest(uri);
Context code:
private apiRequest: RequestAPI<request.RequestPromise, request.RequestPromiseOptions, RequiredUriUrl>;
this.apiRequest = request.defaults({
baseUrl: 'https://www.google.com/',
method: 'GET',
encoding: 'utf8'
});
According to the Type definitions the return type for this.apiRequest(uri)
is request.RequestPromise
. RequestPromise
again is defined like this in the @types/request-promise library:
interface RequestPromise extends request.Request, Promise<any> {
promise(): Promise<any>;
}
Shouldn't it be possible to await the RequestPromise then since it just extends a Promise?