Closed stasonn777 closed 2 years ago
Hi. I try to use decoder in angular app. When I importing it to component it says
Could not find a declaration file for module 'qrcode-decoder'. 'C:/WorkSpace/angular-app/test-app/node_modules/qrcode-decoder/dist/index.js' implicitly has an 'any' type.
Hot to use it?
My config "dependencies": { "@angular/animations": "~12.2.0", "@angular/common": "~12.2.0", "@angular/compiler": "~12.2.0", "@angular/core": "~12.2.0", "@angular/forms": "~12.2.0", "@angular/platform-browser": "~12.2.0", "@angular/platform-browser-dynamic": "~12.2.0", "@angular/platform-server": "~12.2.0", "@angular/router": "~12.2.0", "@fortawesome/angular-fontawesome": "^0.9.0", "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-brands-svg-icons": "^5.15.3", "@fortawesome/free-regular-svg-icons": "^5.15.3", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@nguniversal/express-engine": "^12.1.2", "angular-highcharts": "^13.0.1", "chart.js": "^3.6.2", "express": "^4.15.2", "highcharts": "^9.3.2", "json-server": "^0.17.0", "jsqr": "^1.4.0", "ng2-charts": "^3.0.2", "qrcode-decoder": "^0.2.2", "rxjs": "~6.6.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "~12.2.10", "@angular/cli": "~12.2.10", "@angular/compiler-cli": "~12.2.0", "@nguniversal/builders": "^12.1.2", "@types/express": "^4.17.0", "@types/jasmine": "~3.8.0", "@types/node": "^12.11.1", "jasmine-core": "~3.8.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "~1.7.0", "typescript": "~4.3.5" }
I managed to make it work on Angular by using required. Here is a snippet:
Require it outside your component class, but inside the same file still.
const QrCodeDecoder = require('qrcode-decoder').default;
I created a private property to hold the decoder instance, but this one is up to you.
private qrCodeDecoder = new QrCodeDecoder();
Then just use it following the README.
this.decodedQrCode = await this.qrCodeDecoder.decodeFromImage(this.qrCodeBase64Image).data;
.
Hi. I try to use decoder in angular app. When I importing it to component it says
Could not find a declaration file for module 'qrcode-decoder'. 'C:/WorkSpace/angular-app/test-app/node_modules/qrcode-decoder/dist/index.js' implicitly has an 'any' type.
Hot to use it?
My config "dependencies": { "@angular/animations": "~12.2.0", "@angular/common": "~12.2.0", "@angular/compiler": "~12.2.0", "@angular/core": "~12.2.0", "@angular/forms": "~12.2.0", "@angular/platform-browser": "~12.2.0", "@angular/platform-browser-dynamic": "~12.2.0", "@angular/platform-server": "~12.2.0", "@angular/router": "~12.2.0", "@fortawesome/angular-fontawesome": "^0.9.0", "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-brands-svg-icons": "^5.15.3", "@fortawesome/free-regular-svg-icons": "^5.15.3", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@nguniversal/express-engine": "^12.1.2", "angular-highcharts": "^13.0.1", "chart.js": "^3.6.2", "express": "^4.15.2", "highcharts": "^9.3.2", "json-server": "^0.17.0", "jsqr": "^1.4.0", "ng2-charts": "^3.0.2", "qrcode-decoder": "^0.2.2", "rxjs": "~6.6.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "~12.2.10", "@angular/cli": "~12.2.10", "@angular/compiler-cli": "~12.2.0", "@nguniversal/builders": "^12.1.2", "@types/express": "^4.17.0", "@types/jasmine": "~3.8.0", "@types/node": "^12.11.1", "jasmine-core": "~3.8.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "~1.7.0", "typescript": "~4.3.5" }