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

Typescript defination file is missing options parameter #112

Closed isiah-lloyd closed 5 years ago

isiah-lloyd commented 5 years ago

When trying to use the jsQR function with Typescript configured in vscode, you'll get the warning "expected 3 parameters, got 4", if you try to change the inversionAttempts option. A temporary fix was to add the following to the index.d.ts file

export interface Options {
  inversionAttempts?: "dontInvert" | "onlyInvert" | "attemptBoth" | "invertFirst";
}

and edit the function to this:

declare function jsQR(data: Uint8ClampedArray, width: number, height: number, providedOptions: Options): QRCode | null;
isiah-lloyd commented 5 years ago

It seems like the package on npm is out of date with this repo. By installing it from the git, I was able to get the updated index.d.ts

"jsqr": "https://github.com/cozmo/jsQR",

cozmo commented 5 years ago

Ah good call it seems like we never bumped the version after adding that option. Just published v1.2.0 which should have that. Let me know if you still have this issue.