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.67k stars 606 forks source link

Update typings to communicate the jsQR function exists on window #108

Open TomasHubelbauer opened 5 years ago

TomasHubelbauer commented 5 years ago

The typings file is a module file, it uses export default, which means the declare function statement is applied to the module scope, not the window scope.

I am developing a Javascript project, which only uses Typescript for type checking but doesn't have a build process or use a bundler. I am referencing the package using a script tag. I have set up Typescript to type check my Javascript files, but since the package is referenced using a script tag, I need to let Typescript know it should use jsQR typings in the project. The way to do this is to use compilerOptions.types, which is what I do, but unfortunately the typings as they are right now don't work to make Typescript know the function exists on the window scope, which is how I am accessing it at runtime.

I don't yet understand how to create typings which at the same time use export default (or otherwise export in order to be used as a module) and also correctly contribute to the window scope. I am hoping you do, or can help me understand how to do that for me to be able to create a PR. Thank you