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

Fix type exports #364

merged 1 commit into from
Mar 26, 2023

Conversation

remcohaszing
Copy link
Contributor

@remcohaszing remcohaszing commented Feb 13, 2023

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.

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

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

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

```js
// ESM
const MockAdapter = require('axios-mock-adapter');

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

With the updated type definitions, this is:

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

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

```js
// ESM
const MockAdapter = require('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.
Copy link
Collaborator

@marcbachmann marcbachmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll trust you on this as you have a lot of experience with typescript.

@marcbachmann marcbachmann merged commit fd982cd into ctimmerm:master Mar 26, 2023
@remcohaszing
Copy link
Contributor Author

Sorry! I made an error!

This is fixed in #368.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants