如何使用新方法扩充request-promise-native
以获得自己的行为。
我尝试如下,但是Typescript抱怨错误getCached is not function
const req = require('request');
import 'request-promise-native';
declare module 'request' {
interface RequestAPI<TRequest extends Request, TOptions extends CoreOptions, TUriUrlOptions> {
getCached(): number;
}
}
req.getCached = function () {
//other specific logic
}
module.exports = req