Skip to content

Commit

Permalink
fix: getAdapter first parameter should accepts 'undefined' type
Browse files Browse the repository at this point in the history
  • Loading branch information
geekact committed Dec 2, 2022
1 parent 66c5789 commit 52f40f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Expand Up @@ -481,7 +481,7 @@ export interface GenericHTMLFormElement {
submit(): void;
}

export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[]): AxiosAdapter;
export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;

export function toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;

Expand Down
11 changes: 7 additions & 4 deletions test/typescript/axios.ts
Expand Up @@ -515,6 +515,8 @@ axios.get('/user', {

{
// getAdapter

getAdapter(axios.create().defaults.adapter);
getAdapter([]);
getAdapter(['xhr']);
getAdapter([adapter]);
Expand All @@ -523,10 +525,11 @@ axios.get('/user', {
getAdapter([adapter, adapter]);
getAdapter('xhr');
getAdapter( adapter);
// @ts-expect-error
getAdapter('xhr', 'http');
// @ts-expect-error
getAdapter();
const _: AxiosAdapter = getAdapter('xhr');
const __: AxiosAdapter = getAdapter(['xhr']);

// @ts-expect-error
getAdapter();
// @ts-expect-error
getAdapter('xhr', 'http');
}

0 comments on commit 52f40f5

Please sign in to comment.