I am facing an issue where I cannot find any TypeScript definitions for the module superagent-proxy
. This leads to errors when compiling my TypeScript application to JavaScript, specifically:
ts: Property 'proxy' does not exist on type 'SuperAgentRequest'.
import * as request from 'superagent';
import * as withProxy from 'superagent-proxy';
withProxy(request);
request
.get(...)
.proxy(proxy)
Although I have created a file with declarations, I'm unsure of what steps to take next.
declare module 'superagent-proxy';
I believe I need to define a higher-order function that can take a superagent and return a superagent with a proxy. My current attempt looks like this:
import * as request from 'superagent';
declare module 'superagent-proxy' {
interface SuperAgentRequestWithProxy extends request.SuperAgentStatic {
proxy(url: string): SuperAgentRequestWithProxy;
}
}
However, this solution is not working and I suspect it may be far from correct.
Invalid module name in augmentation. Module 'superagent-proxy' resolves to an untyped module at '.../node_modules/superagent-proxy/index.js', which cannot be augmented