Skip to content

fix(compiler/ngcc): detect synthesized constructors that have been downleveled using TypeScript 4.2 - #41305

Closed
JoostK wants to merge 4 commits into
angular:masterfrom
JoostK:ts42-synthesized-ctors
Closed

JoostK wants to merge 4 commits into
angular:masterfrom
JoostK:ts42-synthesized-ctors

Conversation

@JoostK

@JoostK JoostK commented Mar 21, 2021 •

Copy link
Copy Markdown
Member

See individual commits.

The fix is only relevant for major (i.e. v12) as TypeScript 4.2 is not supported in v11.

Fixes #41298

@JoostK JoostK added area: core Issues related to the framework runtime target: major This PR is targeted for the next major release comp: ngcc area: compiler Issues related to `ngc`, Angular's template compiler P2 The issue is important to a large percentage of users, with a workaround labels Mar 21, 2021
@ngbot ngbot Bot added this to the Backlog milestone Mar 21, 2021
@google-cla google-cla Bot added the cla: yes label Mar 21, 2021
@JoostK
JoostK force-pushed the ts42-synthesized-ctors branch from 30b3360 to cc16deb Compare March 21, 2021 20:42
Comment thread packages/core/test/BUILD.bazel Resolved
@JoostK
JoostK marked this pull request as ready for review March 21, 2021 20:58
@pullapprove
pullapprove Bot requested a review from alxhub March 21, 2021 20:58
@JoostK JoostK added the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 21, 2021

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way you had three tests - two hard coded and one generated. Covers all our bases.

@gkalpak gkalpak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@JoostK JoostK added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 22, 2021
JoostK added 4 commits March 22, 2021 18:50
… using TS 4.2

TypeScript 4.2 has changed its emitted syntax for synthetic constructors
when using `downlevelIteration`, which affects ES5 bundles that have
been downleveled from ES2015 bundles. This is typically the case for UMD
bundles in the APF spec, as they are generated by downleveling the
ESM2015 bundle into ES5. ngcc needs to detect the new syntax in order to
correctly identify synthesized constructor functions in ES5 bundles.

Fixes angular#41298
… using TS 4.2

TypeScript 4.2 has changed its emitted syntax for synthetic constructors
when using `downlevelIteration`, which affects ES5 bundles that have
been downleveled from ES2015 bundles. This is typically the case for UMD
bundles in the APF spec, as they are generated by downleveling the
ESM2015 bundle into ES5. The reflection capabilities in the runtime need
to recognize this new form to correctly deal with synthesized
constructors, as otherwise JIT compilation could generate invalid
factory functions.

Fixes angular#41298
@JoostK
JoostK force-pushed the ts42-synthesized-ctors branch from cc16deb to c772708 Compare March 22, 2021 17:51
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 22, 2021
@AndrewKushnir

Copy link
Copy Markdown
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Mar 22, 2021
@AndrewKushnir
AndrewKushnir removed the request for review from alxhub March 22, 2021 23:15
josephperrott pushed a commit that referenced this pull request Mar 23, 2021
… using TS 4.2 (#41305)

TypeScript 4.2 has changed its emitted syntax for synthetic constructors
when using `downlevelIteration`, which affects ES5 bundles that have
been downleveled from ES2015 bundles. This is typically the case for UMD
bundles in the APF spec, as they are generated by downleveling the
ESM2015 bundle into ES5. The reflection capabilities in the runtime need
to recognize this new form to correctly deal with synthesized
constructors, as otherwise JIT compilation could generate invalid
factory functions.

Fixes #41298

PR Close #41305
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
… using TS 4.2 (angular#41305)

TypeScript 4.2 has changed its emitted syntax for synthetic constructors
when using `downlevelIteration`, which affects ES5 bundles that have
been downleveled from ES2015 bundles. This is typically the case for UMD
bundles in the APF spec, as they are generated by downleveling the
ESM2015 bundle into ES5. ngcc needs to detect the new syntax in order to
correctly identify synthesized constructor functions in ES5 bundles.

Fixes angular#41298

PR Close angular#41305
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
… using TS 4.2 (angular#41305)

TypeScript 4.2 has changed its emitted syntax for synthetic constructors
when using `downlevelIteration`, which affects ES5 bundles that have
been downleveled from ES2015 bundles. This is typically the case for UMD
bundles in the APF spec, as they are generated by downleveling the
ESM2015 bundle into ES5. The reflection capabilities in the runtime need
to recognize this new form to correctly deal with synthesized
constructors, as otherwise JIT compilation could generate invalid
factory functions.

Fixes angular#41298

PR Close angular#41305
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime cla: yes P2 The issue is important to a large percentage of users, with a workaround target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular 12: synthesized constructors compiled by TS 4.2 are not recognized

4 participants