question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with Angular Ivy compiler

See original GitHub issue

Angular 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Cordobocommented, Apr 17, 2020

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 or yarn add angularx-qrcode@^2.2.1

0reactions
stale[bot]commented, Apr 16, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found