cozmo / jsQR

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
https://cozmo.github.io/jsQR/
Apache License 2.0
3.63k stars 600 forks source link

Fix exports type definitions #234

Open remcohaszing opened 1 year ago

remcohaszing commented 1 year ago

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).

syarul commented 1 month ago

This is needed to fix the type imports if not there's no way to compile the TS build