yugasun / qrcode-decoder

🤘Tool for decoding qrcode by image,video or camera.
https://yugasun.github.io/qrcode-decoder/
MIT License
97 stars 35 forks source link

Fix type def of decodeFromImage() param #23

Closed dyoshikawa closed 1 year ago

dyoshikawa commented 1 year ago

The decodeFromImage() function accepts a string type as an argument. And this works as expected. However, when use TypeScript, actually setting the string type causes a type definition error.

Example:

const qrCodeBase64Str = 'data:image/png;base64...'
const qrCodeDecoder = new QrCodeDecoder()
qrCodeDecoder.decodeFromImage(qrCodeBase64Str).then((result) => console.log(result))
// => Error: "Argument of type 'string' is not assignable to parameter of type 'HTMLImageElement'."

This PR prevents the type definition error from occurring.