ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests
MIT License
3.45k stars 244 forks source link

Fix type exports #364

Closed remcohaszing closed 1 year ago

remcohaszing commented 1 year ago

According to the old type definitions, this was correct usage:

// CJS
const MockAdapter = require('axios-mock-adapter');

const mock = new MockAdapter.default(/* … */)
// ESM
import MockAdapter from 'axios-mock-adapter';

const mock = new MockAdapter.default(/* … */)

With the updated type definitions, this is:

// CJS
const MockAdapter = require('axios-mock-adapter');

const mock = new MockAdapter(/* … */)
// ESM
import MockAdapter from 'axios-mock-adapter';

const mock = new MockAdapter(/* … */)

This has always been an issue, but it has become more apparent with the "module": "node16" option introduced in TypeScript 4.7.

remcohaszing commented 1 year ago

Sorry! I made an error!

This is fixed in #368.