Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix exports type definitions #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remcohaszing
Copy link

According to the type definitions, this library had to be used like this:

// CJS
const jsQR = require('jsqr')

jsQR.default(/* … */)
// ESM
import jsQR from 'jsqr'

jsQR.default(/* … */)

However, this doesn’t match the instructions from the readme.

This issue has become more apparent since the introduction of the "module": "node16" option in TypeScript 4.7. The correct way to type module.exports = is export =.

People can still use default imports when compiling to CJS. This requires them to use the esModuleInterop option (which they need anyway if they want to use it with other libraries).

According to the type definitions, this library had to be used like
this:

```js
// CJS
const jsQR = require('jsqr')

jsQR.default(/* … */)
```

```js
// ESM
import jsQR from 'jsqr'

jsQR.default(/* … */)
```

However, this doesn’t match the instructions from the readme.

This issue has become more apparent since the introduction of the
`"module": "node16"` option in TypeScript 4.7. The correct way to type
`module.exports =` is `export =`.

People can still use default imports when compiling to CJS. This
requires them to use the `esModuleInterop` option (which they need
anyway if they want to use it with other libraries).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant