ngx-scanner icon indicating copy to clipboard operation
ngx-scanner copied to clipboard

When running ng serve shows the following error:

Open mmahan13 opened this issue 2 years ago • 5 comments
trafficstars

The installation is done correctly, following the steps proposed in the documentation.

When running ng serve shows the following error:

Error: node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:305:91 - error TS2344: Type '{ autofocusEnabled: { alias: "autofocusEnabled"; required: false; }; timeBetweenScans: { alias: "timeBetweenScans"; required: false; }; delayBetweenScanSuccess: { alias: "delayBetweenScanSuccess"; required: false; }; ... 7 more ...; tryHarder: { ...; }; }' does not satisfy the constraint '{ [key: string]: string; }'.
Property '"autofocusEnabled"' is incompatible with index signature. Type '{ alias: "autofocusEnabled"; required: false; }' is not assignable to type 'string'.

305 static ɵcmp: i0.ɵɵComponentDeclaration<ZXingScannerComponent, "zxing-scanner", never, { "autofocusEnabled": { "alias": "autofocusEnabled"; "required": false; }; "timeBetweenScans": { "alias": "timeBetweenScans"; "required": false; }; "delayBetweenScanSuccess": { "alias": "delayBetweenScanSuccess"; "required": false; }; "autostart": { "alias": "autostart"; "required": false; }; "previewFitMode": { "alias": "previewFitMode"; "required": false; }; "device": { "alias": "device"; "required": false; }; "formats": { "alias": "formats"; "required": false; }; "videoConstraints": { "alias": "videoConstraints"; "required": false; }; "torch": { "alias": "torch"; "required": false; }; "enable": { "alias": "enable"; "required": false; }; "tryHarder": { "alias": "tryHarder"; "required": false; }; }, { "autostarted": "autostarted"; "autostarting": "autostarting"; "torchCompatible": "torchCompatible"; "scanSuccess": "scanSuccess"; "scanFailure": "scanFailure"; "scanError": "scanError"; "scanComplete": "scanComplete"; "camerasFound": "camerasFound"; "camerasNotFound": "camerasNotFound"; "permissionResponse": "permissionResponse"; "hasDevices": "hasDevices"; "deviceChange": "deviceChange"; }, never, never, false, never>;

Error: node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:305:91 - error

static ɵcmp: i0.ɵɵComponentDeclaration<ZXingScannerComponent, "zxing-scanner", never, { "autofocusEnabled": { "alias": "autofocusEnabled"; "required": false; }; "timeBetweenScans": { "alias": "timeBetweenScans"; "required": false; }; "delayBetweenScanSuccess": { "alias": "delayBetweenScanSuccess"; "required": false; }; "autostart": { "alias": "autostart"; "required": false; }; "previewFitMode": { "alias": "previewFitMode"; "required": false; }; "device": { "alias": "device"; "required": false; }; "formats": { "alias": "formats"; "required": false; }; "videoConstraints": { "alias": "videoConstraints"; "required": false; }; "torch": { "alias": "torch"; "required": false; }; "enable": { "alias": "enable"; "required": false; }; "tryHarder": { "alias": "tryHarder"; "required": false; }; }, { "autostarted": "autostarted"; "autostarting": "autostarting"; "torchCompatible": "torchCompatible"; "scanSuccess": "scanSuccess"; "scanFailure": "scanFailure"; "scanError": "scanError"; "scanComplete": "scanComplete"; "camerasFound": "camerasFound"; "camerasNotFound": "camerasNotFound"; "permissionResponse": "permissionResponse"; "hasDevices": "hasDevices"; "deviceChange": "deviceChange"; }, never, never, false, never>; }

If you can help me with this problem since I can't find solutions.

mmahan13 avatar Jun 08 '23 10:06 mmahan13

image

mmahan13 avatar Jun 08 '23 10:06 mmahan13

Which version of angular and ngx-scanner?

werthdavid avatar Jun 08 '23 11:06 werthdavid

Angular CLI: 15.2.8 Node: 18.14.2 Package Manager: npm 9.5.0 OS: win32 x64

Angular: 15.2.9

ngx-scanner "@zxing/browser": "^0.1.3", "@zxing/library": "^0.20.0", "@zxing/ngx-scanner": "^16.0.0",

mmahan13 avatar Jun 08 '23 11:06 mmahan13

For angular 15 you need to use version 3.9.0 (define the version without ^ character in front!!)

werthdavid avatar Jun 08 '23 11:06 werthdavid

Ooh! I have installed the dependency npm i @zxing/[email protected] and it has worked correctly. thank you!

mmahan13 avatar Jun 08 '23 11:06 mmahan13