故事比较简单,在axios返回结果中存在默认字段之外的字段,于是就出现了警告。

AxiosResponse默认字段如下:

export interface AxiosResponse<T = any, D = any>  {
  data: T;
  status: number;
  statusText: string;
  headers: AxiosResponseHeaders;
  config: AxiosRequestConfig<D>;
  request?: any;
}

众里寻他,在axios中发现了这个:issue传送门

I override AxiosResponse in my axios.d.ts:

import axios from 'axios'

declare module 'axios' {
  export interface AxiosResponse<T = any> extends Promise<T> {}
}

于是……,世界都清爽了好多

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐