关于索引中公开的lambda函数,我面临一个typescript问题。d、 ts文件。我试图做的是修饰AxiosInstance,以便在需要时取消挂起的请求。
这是索引。d、 ts文件,来自axios库:
export interface AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise; // How to override this lambda ?
(url: string, config?: AxiosRequestConfig): AxiosPromise; // How to override this lambda ?
// Omit the rest because ther is no problem with it
}
下面是我对AxiosInstance的实现
export default class CancelableAxiosInstance implements AxiosInstance {
private axiosInstance: AxiosInstance;
constructor(axiosInstance: AxiosInstance){
this.axiosInstance = axiosInstance;
}
// Another function that I want to expose on CancelableAxiosInstance
cancelRequests() {
// Omit implementation
}
// How do I override (config: AxiosRequestConfig): AxiosPromise; declared in index.d.ts file ?
}
以下是IDE中显示的typescript编译器错误:
TS2420:
键入“CancelableAxiosInstance”providesnomatchforthesignature“(配置:AxiosRequestConfig):AxiosPromise”)。
有人能帮我吗?
谢谢