ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Types are not exported except for RequestHandler

dprentis opened this issue · comments

Would be great to export other types defined in https://github.com/ctimmerm/axios-mock-adapter/blob/master/types/index.d.ts

This would make them directly accessible to the application. Currently I'm working around like this, but it's unnecessarily convoluted:

import MockAdapter from 'axios-mock-adapter';

// extract types
type RequestMatcherFunc = MockAdapter['onAny'];
type RequestMatcherFuncParams = Parameters<RequestMatcherFunc>;
type Matcher = RequestMatcherFuncParams[0];
type Body = RequestMatcherFuncParams[1];
type Headers = RequestMatcherFuncParams[2];

Otherwise a great library - thanks! 👍