Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix type exports #364

Merged
merged 1 commit into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ type ResponseSpecFunc = <T = any>(
headers?: any
) => MockAdapter;

export interface RequestHandler {
reply: ResponseSpecFunc;
replyOnce: ResponseSpecFunc;
passThrough(): MockAdapter;
abortRequest(): MockAdapter;
abortRequestOnce(): MockAdapter;
networkError(): MockAdapter;
networkErrorOnce(): MockAdapter;
timeout(): MockAdapter;
timeoutOnce(): MockAdapter;
declare namespace MockAdapter {
export interface RequestHandler {
reply: ResponseSpecFunc;
replyOnce: ResponseSpecFunc;
passThrough(): MockAdapter;
abortRequest(): MockAdapter;
abortRequestOnce(): MockAdapter;
networkError(): MockAdapter;
networkErrorOnce(): MockAdapter;
timeout(): MockAdapter;
timeoutOnce(): MockAdapter;
}
}

interface MockAdapterOptions {
Expand Down Expand Up @@ -50,7 +52,7 @@ type RequestMatcherFunc = (
matcher?: string | RegExp,
body?: string | AsymmetricRequestDataMatcher,
headers?: AsymmetricHeadersMatcher
) => RequestHandler;
) => AxiosAdapter.RequestHandler;

declare class MockAdapter {
constructor(axiosInstance: AxiosInstance, options?: MockAdapterOptions);
Expand All @@ -76,4 +78,4 @@ declare class MockAdapter {
onUnlink: RequestMatcherFunc;
}

export default MockAdapter;
export = MockAdapter;
4 changes: 2 additions & 2 deletions types/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import MockAdapter, { RequestHandler } from 'axios-mock-adapter';
import MockAdapter = require('axios-mock-adapter');

const instance = axios.create();
const mock = new MockAdapter(instance);
Expand Down Expand Up @@ -149,6 +149,6 @@ namespace SupportsChaining {
}

namespace ExportsRequestHandlerInterface {
const handler: RequestHandler = mock.onAny();
const handler: MockAdapter.RequestHandler = mock.onAny();
handler.reply(200);
}