Error with Angular Ivy compiler
See original GitHub issueAngular version: 8.1.0
Ivy compiler enabled in tsconfig.json
with:
"angularCompilerOptions": {
"enableIvy": true
},
Error reported:
ERROR in Attempted to get members of a non-class: "class QRCodeComponent {
constructor(el, platformId) {
this.el = el;
this.platformId = platformId;
/** @internal */
this.allowEmptyString = false;
this.colordark = '#000000';
this.colorlight = '#ffffff';
this.level = 'M';
this.hidetitle = false;
this.qrdata = '';
this.size = 256;
this.usesvg = false;
this.isValidQrCodeText = (data) => {
if (this.allowEmptyString === false) {
return !(typeof data === 'undefined' || data === '');
}
return !(typeof data === 'undefined');
};
}
ngAfterViewInit() {
if (isPlatformServer(this.platformId)) {
return;
}
if (!QRCode) {
QRCode = require('qrcodejs2');
}
try {
if (!this.isValidQrCodeText(this.qrdata)) {
throw new Error('Empty QR Code data');
}
this.qrcode = new QRCode(this.el.nativeElement, {
colorDark: this.colordark,
colorLight: this.colorlight,
correctLevel: QRCode.CorrectLevel[this.level.toString()],
height: this.size,
text: this.qrdata || ' ',
useSVG: this.usesvg,
width: this.size,
});
}
catch (e) {
console.error('Error generating QR Code: ' + e.message);
}
}
ngOnChanges(changes) {
if (!this.qrcode) {
return;
}
const qrData = changes['qrdata'];
if (qrData && this.isValidQrCodeText(qrData.currentValue)) {
this.qrcode.clear();
this.qrcode.makeCode(qrData.currentValue);
}
}
}"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Compile error when building with Angular Ivy - Stack Overflow
I have an angular 8 project and when I enable angular Ivy then it is getting failed during compile time. When I check...
Read more >Angular 11 project is not compiling when IVY is enabled.
The error you show implies that the library has not been converted to Ivy compatible code by the ngcc tool, which should have...
Read more >Angular compiler options
When true , the compiler does not look at the TypeScript version and does not report an error when an unsupported version of...
Read more >Angular IVY Issues - Errors that disappear after restart of "ng ...
I am running the dev-server with ng serve and every once in a while the compiler would puke out like 20 messages that...
Read more >Angular Ivy
To revert the compiler default, set the build option aot: false in the angular.json configuration file. If you disable Ivy and the project...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
I fixed this issue today in the latest release (2.2.1). A working sample app is available for angular 9.1:
https://github.com/Cordobo/angularx-qrcode-sample-app
For angular 9.x run
npm install angularx-qrcode@^2.2.1
oryarn add angularx-qrcode@^2.2.1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.