Skip to content

Code Generation - Line omitted from class constructor. #49854

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
troppoli opened this issue Jul 10, 2022 · 3 comments · Fixed by #49858
Closed

Code Generation - Line omitted from class constructor. #49854

troppoli opened this issue Jul 10, 2022 · 3 comments · Fixed by #49858
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@troppoli
Copy link

Bug Report

Emitted javascript omits a line of code that should be be there.

🔎 Search Terms

Code Generation, omitted line, missing, super

🕗 Version & Regression Information

This issues does not happen in 4.6.4, but does ever after.

  • This changed between versions 4.6.4 and 4.7.4

⏯ Playground Link

Playground link with relevant code

💻 Code

class Base{
}

export class Foo extends Base{
    constructor(
        private member: boolean,
    ) {
        'ngInject';
        super();
        console.log(' where did this go???'); // <<<<< this line gets omitted in generated javascript code
    }
}

🙁 Actual behavior

Javascript output does not include the console.log statement.

class Base {
}
export class Foo extends Base {
    constructor(member) {
        'ngInject';
        super();
        this.member = member;
    }
}

🙂 Expected behavior

All the code should make it through. If you duplicate the log line, then one of them will come through.

@MartinJohns
Copy link
Contributor

This issues does not happen in 4.6.4, but does ever after.

Then it was probably caused by the fix for #48671.

@fahadm
Copy link

fahadm commented Jul 14, 2022

FYI:
I can see variants of this issue also happen in 4.6.2, 4.6.3 and 4.6.4.

So basically this has been broken since 4.6.0

Would it be possible to push the fix to the new 4.7.X, as otherwise we will have to resort to ugly hacks (noop line) to get stuff working.
I think it is a very silent bug that basically all hybrid applications will have to deal with when they migrate to angular 14 ( as you can only use typescript 4.6.X+ for angular 14)

Here is an example of the issue that is present on all versions after 4.5.5.

Code

class Base{
}

export class Foo extends Base{
    public currentYear: number = new Date().getFullYear();

    constructor(
        private member: boolean,
    ) {
        'ngInject';
        super();
        console.log(' where did this go???'); // <<<<< this line gets omitted in generated javascript code
    }
}

Expected behavior

The line should not silently disappear.

@rhuitl
Copy link

rhuitl commented Jul 18, 2022

Yes, it would be really nice to get this into 4.7 so that Angular 13 users can upgrade to Angular 14.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants