Added the definition of the "axios-cancel" package

This commit is contained in:
TheDSCPL 2019-04-10 18:07:29 +01:00 committed by Luis
parent 8977181a07
commit db82e27b78
3 changed files with 11 additions and 9 deletions

View File

@ -1,9 +1,7 @@
/*
// can't test because it depends on axios which makes Travis CI be unable to compile with the error "expect TypeScript@next compile error: Cannot find module 'axios'."
import axios, { AxiosPromise } from "axios"
import axiosCancel from "axios-cancel";
import axiosCancel, { AxiosStatic } from "axios-cancel";
axiosCancel(axios); // $ExpectType void
@ -11,10 +9,8 @@ axios.get(
'https://jsonplaceholder.typicode.com/users', {
requestId: "test id"
}
); // $ExpectType Promise<any>
); // $ExpectType AxiosPromise<any>
axios.cancel("test id"); // $ExpectType void
axios.cancelAll(); // $ExpectType void
*/

View File

@ -8,8 +8,8 @@ import {AxiosStatic} from "axios";
declare module 'axios' {
export interface AxiosRequestConfig {
requestId?: string
};
requestId?: string;
}
export interface AxiosStatic {
cancel: (requestId: string) => void;
cancelAll: () => void;
@ -21,7 +21,7 @@ interface AxiosCancelOptions {
* Enables logging
* default: false
*/
debug: boolean
debug: boolean;
}
declare function axiosCancel(axiosStatic: AxiosStatic, options?: AxiosCancelOptions): void;

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"axios": "0.15.2"
}
}