jsQR icon indicating copy to clipboard operation
jsQR copied to clipboard

Fix exports type definitions

Open remcohaszing opened this issue 2 years ago • 1 comments

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

remcohaszing avatar Feb 13 '23 09:02 remcohaszing

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

syarul avatar May 28 '24 04:05 syarul