mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Converting TypeScript definitions to ES2015 module syntax
This commit is contained in:
Vendored
+62
-62
@@ -1,65 +1,65 @@
|
|||||||
// Type definitions for Axios v0.8.1
|
export interface Thenable<V> {
|
||||||
// Project: https://github.com/mzabriskie/axios
|
then<R>(onFulfilled?: (value: V) => R | Thenable<R>, onRejected?: (reason: any) => R | Thenable<R>): Thenable<R>;
|
||||||
|
then<R>(onFulfilled?: (value: V) => R | Thenable<R>, onRejected?: (reason: any) => void): Thenable<R>;
|
||||||
|
catch<R>(onRejected?: (reason: any) => R | Thenable<R>): Thenable<R>;
|
||||||
|
|
||||||
declare var axios: axios.AxiosStatic
|
|
||||||
|
|
||||||
declare module axios {
|
|
||||||
interface AxiosRequestMethods {
|
|
||||||
get(url: string, config?: any): axios.Promise;
|
|
||||||
delete(url: string, config?: any): axios.Promise;
|
|
||||||
head(url: string, config?: any): axios.Promise;
|
|
||||||
post(url: string, data: any, config?: any): axios.Promise;
|
|
||||||
put(url: string, data: any, config?: any): axios.Promise;
|
|
||||||
patch(url: string, data: any, config?: any): axios.Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AxiosStatic extends AxiosRequestMethods {
|
|
||||||
(options: axios.RequestOptions): axios.Promise;
|
|
||||||
create(defaultOptions?: axios.InstanceOptions): AxiosInstance;
|
|
||||||
all(iterable: any): axios.Promise;
|
|
||||||
spread(callback: any): axios.Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AxiosInstance extends AxiosRequestMethods {
|
|
||||||
request(options: axios.RequestOptions): axios.Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Response {
|
|
||||||
data?: any;
|
|
||||||
status?: number;
|
|
||||||
statusText?: string;
|
|
||||||
headers?: any;
|
|
||||||
config?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Promise {
|
|
||||||
then(onFulfilled:(response: axios.Response) => void): axios.Promise;
|
|
||||||
catch(onRejected:(response: axios.Response) => void): axios.Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InstanceOptions {
|
|
||||||
transformRequest?: (data: any) => any;
|
|
||||||
transformResponse?: (data: any) => any;
|
|
||||||
headers?: any;
|
|
||||||
timeout?: number;
|
|
||||||
withCredentials?: boolean;
|
|
||||||
responseType?: string;
|
|
||||||
xsrfCookieName?: string;
|
|
||||||
xsrfHeaderName?: string;
|
|
||||||
paramsSerializer?: (params: any) => string;
|
|
||||||
baseURL?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RequestOptions extends InstanceOptions {
|
|
||||||
url: string;
|
|
||||||
method?: string;
|
|
||||||
params?: any;
|
|
||||||
data?: any;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "axios" {
|
export interface AxiosDataTransformer {
|
||||||
export = axios;
|
(data: any): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AxiosRequestConfig {
|
||||||
|
url?: string;
|
||||||
|
method?: string;
|
||||||
|
baseURL?: string;
|
||||||
|
transformRequest?: AxiosDataTransformer | AxiosDataTransformer[];
|
||||||
|
transformResponse?: AxiosDataTransformer | AxiosDataTransformer[];
|
||||||
|
headers?: any;
|
||||||
|
params?: any;
|
||||||
|
paramsSerializer?: (params: any) => string;
|
||||||
|
data?: any;
|
||||||
|
timeout?: number;
|
||||||
|
withCredentials?: boolean;
|
||||||
|
adapter?: any;
|
||||||
|
auth?: any;
|
||||||
|
responseType?: string;
|
||||||
|
xsrfCookieName?: string;
|
||||||
|
xsrfHeaderName?: string;
|
||||||
|
progress?: (progressEvent: any) => void;
|
||||||
|
maxContentLength?: number;
|
||||||
|
validateStatus?: (status: number) => boolean;
|
||||||
|
maxRedirects?: number;
|
||||||
|
httpAgent?: any;
|
||||||
|
httpsAgent?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AxiosResponse {
|
||||||
|
data: any;
|
||||||
|
status: number;
|
||||||
|
statusText: string;
|
||||||
|
headers: any;
|
||||||
|
config: AxiosRequestConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AxiosInstance {
|
||||||
|
defaults: AxiosRequestConfig;
|
||||||
|
request(config: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
get(url: string, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
delete(url: string, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
head(url: string, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
post(url: string, data?: any, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
put(url: string, data?: any, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
patch(url: string, data?: any, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AxiosStatic extends AxiosInstance {
|
||||||
|
(config: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
(url: string, config?: AxiosRequestConfig): Thenable<AxiosResponse>;
|
||||||
|
create(config?: AxiosRequestConfig): AxiosInstance;
|
||||||
|
all(iterable: any): Thenable<any>;
|
||||||
|
spread(callback: any): Thenable<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare const Axios: AxiosStatic;
|
||||||
|
|
||||||
|
export default Axios;
|
||||||
|
|||||||
+6
-1
@@ -24,7 +24,7 @@ function createInstance(defaultConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the default instance to be exported
|
// Create the default instance to be exported
|
||||||
var axios = module.exports = createInstance();
|
var axios = createInstance();
|
||||||
|
|
||||||
// Expose Axios class to allow class inheritance
|
// Expose Axios class to allow class inheritance
|
||||||
axios.Axios = Axios;
|
axios.Axios = Axios;
|
||||||
@@ -39,3 +39,8 @@ axios.all = function all(promises) {
|
|||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
};
|
};
|
||||||
axios.spread = require('./helpers/spread');
|
axios.spread = require('./helpers/spread');
|
||||||
|
|
||||||
|
module.exports = axios;
|
||||||
|
|
||||||
|
// Allow use of default import syntax in TypeScript
|
||||||
|
module.exports.default = axios;
|
||||||
|
|||||||
+1
-3
@@ -69,9 +69,7 @@
|
|||||||
"browser": {
|
"browser": {
|
||||||
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typings": "./axios.d.ts",
|
||||||
"definition": "./axios.d.ts"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "0.0.7"
|
"follow-redirects": "0.0.7"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
/// <reference path="../../axios.d.ts" />
|
import axios from '../../';
|
||||||
|
|
||||||
import axios = require('axios');
|
|
||||||
|
|
||||||
axios.get('/user?ID=12345')
|
axios.get('/user?ID=12345')
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
|||||||
Reference in New Issue
Block a user