mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
chore(types): move AxiosStatic#create to AxiosInstance#create (#5096)
* Add the bad test case. * Fix and pass the test * Update index.d.cts --------- Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+1
-1
@@ -508,6 +508,7 @@ declare namespace axios {
|
|||||||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
|
|
||||||
|
create(config?: CreateAxiosDefaults): AxiosInstance;
|
||||||
defaults: Omit<AxiosDefaults, 'headers'> & {
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
||||||
headers: HeadersDefaults & {
|
headers: HeadersDefaults & {
|
||||||
[key: string]: AxiosHeaderValue
|
[key: string]: AxiosHeaderValue
|
||||||
@@ -526,7 +527,6 @@ declare namespace axios {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AxiosStatic extends AxiosInstance {
|
interface AxiosStatic extends AxiosInstance {
|
||||||
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
||||||
Cancel: CancelStatic;
|
Cancel: CancelStatic;
|
||||||
CancelToken: CancelTokenStatic;
|
CancelToken: CancelTokenStatic;
|
||||||
Axios: typeof Axios;
|
Axios: typeof Axios;
|
||||||
|
|||||||
Vendored
+1
-1
@@ -514,6 +514,7 @@ export interface AxiosInstance extends Axios {
|
|||||||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
||||||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
||||||
|
|
||||||
|
create(config?: CreateAxiosDefaults): AxiosInstance;
|
||||||
defaults: Omit<AxiosDefaults, 'headers'> & {
|
defaults: Omit<AxiosDefaults, 'headers'> & {
|
||||||
headers: HeadersDefaults & {
|
headers: HeadersDefaults & {
|
||||||
[key: string]: AxiosHeaderValue
|
[key: string]: AxiosHeaderValue
|
||||||
@@ -548,7 +549,6 @@ export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
|||||||
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
||||||
|
|
||||||
export interface AxiosStatic extends AxiosInstance {
|
export interface AxiosStatic extends AxiosInstance {
|
||||||
create(config?: CreateAxiosDefaults): AxiosInstance;
|
|
||||||
Cancel: CancelStatic;
|
Cancel: CancelStatic;
|
||||||
CancelToken: CancelTokenStatic;
|
CancelToken: CancelTokenStatic;
|
||||||
Axios: typeof Axios;
|
Axios: typeof Axios;
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ axios.request<User, string>({
|
|||||||
// Instances
|
// Instances
|
||||||
|
|
||||||
const instance1: AxiosInstance = axios.create();
|
const instance1: AxiosInstance = axios.create();
|
||||||
const instance2: AxiosInstance = axios.create(config);
|
const instance2: AxiosInstance = instance1.create(config);
|
||||||
|
|
||||||
instance1(config)
|
instance1(config)
|
||||||
.then(handleResponse)
|
.then(handleResponse)
|
||||||
|
|||||||
Reference in New Issue
Block a user