Repository: axios/axios
File: index.d.ts (TypeScript)

Code before:
}

export interface CancelToken {
  promise: Promise<Cancel>;
  reason?: Cancel;
  throwIfRequested(): void;
}

export interface CancelTokenSource {
  token: CancelToken;
  cancel: Canceler;
}

export interface AxiosInterceptorManager<V> {
  use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
  eject(id: number): void;
}

export interface AxiosInstance<C extends AxiosRequestConfig=AxiosRequestConfig> {
  (config: C): AxiosPromise;
  (url: string, config?: C): AxiosPromise;
  defaults: C;
  interceptors: {
    request: AxiosInterceptorManager<C>;
    response: AxiosInterceptorManager<AxiosResponse>;
  };
  getUri(config?: C): string;
  request<T = any, R = AxiosResponse<T>> (config: C): Promise<R>;
  get<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  delete<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  head<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: C): Promise<R>;
  put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: C): Promise<R>;
  patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: C): Promise<R>;
}

export interface AxiosStatic extends AxiosInstance {
  create<C extends AxiosRequestConfig>(config?: C): AxiosInstance<C>;
  Cancel: CancelStatic;
  CancelToken: CancelTokenStatic;
  isCancel(value: any): boolean;
  all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
  spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
}

declare const Axios: AxiosStatic;

export default Axios;


Review comment (suggestion):
better to call this something like `TConfig` or just `T` for convention

Code after:
export interface Canceler {
  (message?: string): void;
}

export interface CancelTokenStatic {
  new (executor: (cancel: Canceler) => void): CancelToken;
  source(): CancelTokenSource;
}

export interface CancelToken {
  promise: Promise<Cancel>;
  reason?: Cancel;
  throwIfRequested(): void;
}

export interface CancelTokenSource {
  token: CancelToken;
  cancel: Canceler;
}

export interface AxiosInterceptorManager<V> {
  use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
  eject(id: number): void;
}

export interface AxiosInstance<C extends AxiosRequestConfig=AxiosRequestConfig> {
  (config: C): AxiosPromise;
  (url: string, config?: C): AxiosPromise;
  defaults: C;
  interceptors: {
    request: AxiosInterceptorManager<C>;
    response: AxiosInterceptorManager<AxiosResponse>;
  };

  getUri(config?: C): string;
  request<T = any, R = AxiosResponse<T>> (config: C): Promise<R>;
  get<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  delete<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  head<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  options<T = any, R = AxiosResponse<T>>(url: string, config?: C): Promise<R>;
  post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: C): Promise<R>;
  put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: C): Promise<R>;
  patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: C): Promise<R>;
}

export interface AxiosStatic extends AxiosInstance {
  create<C extends AxiosRequestConfig>(config?: C): AxiosInstance<C>;
  Cancel: CancelStatic;
  CancelToken: CancelTokenStatic;
  isCancel(value: any): boolean;
  all<T>(values: (T | Promise<T>)[]): Promise<T[]>;