Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Several inject migration fixes #58393

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

crisbeto
Copy link
Member

Includes the following changes that fix issues raised during internal tests of the inject migration:

refactor(migrations): hoist uninitialized members to top of class if they are not combined in the internal migration

When the internal mode for the inject migration is enabled, we find properties without initializers, we add their initializers and we prepend the inject calls before them. The remaining properties that couldn't be combined are left in place. This appears to break some internal cases.

These changes work around the issue by hoisting all the non-combined members above the inject() calls. This should be safe, because they don't have initializers and as such can't have dependencies.

fix(migrations): inject migration not inserting generated code after super call in some cases

Fixes an issue where the inject migration was generating and attempting to insert code after a super call, but the string buffering implementation was dropping it if the statement right after the super call was deleted as a result of the migration.

refactor(migrations): inject migration internal mode incorrectly migration properties initialized to identifiers

Fixes that when the inject migration in internal mode was starting to visit the nodes one level down from the root when considering whether an expression contains local references. This lead it to skip over top-level identifiers and migrate some code incorrectly.

fix(migrations): inject migration always inserting generated variables before super call

Fixes that if a class has a super call, the inject migration would always insert the generated variable before it, even if there's other code before the super call.

…they are not combined in the internal migration

When the internal mode for the `inject` migration is enabled, we find properties without initializers, we add their initializers and we prepend the `inject` calls before them. The remaining properties that couldn't be combined are left in place. This appears to break some internal cases.

These changes work around the issue by hoisting all the non-combined members above the `inject()` calls. This should be safe, because they don't have initializers and as such can't have dependencies.
…super call in some cases

Fixes an issue where the `inject` migration was generating and attempting to insert code after a `super` call, but the string buffering implementation was dropping it if the statement right after the `super` call was deleted as a result of the migration.
…ation properties initialized to identifiers

Fixes that when the `inject` migration in internal mode was starting to visit the nodes one level down from the root when considering whether an expression contains local references. This lead it to skip over top-level identifiers and migrate some code incorrectly.
…s before super call

Fixes that if a class has a `super` call, the `inject` migration would always insert the generated variable before it, even if there's other code before the `super` call.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release area: migrations Issues related to `ng update` migrations labels Oct 28, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 28, 2024
@crisbeto crisbeto requested a review from devversion October 28, 2024 15:16
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: rc This PR is targeted for the next release-candidate and removed action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 28, 2024
@alxhub
Copy link
Member

alxhub commented Oct 28, 2024

This PR was merged into the repository by commit 4434f3c.

The changes were merged into the following branches: main, 19.0.x

alxhub pushed a commit that referenced this pull request Oct 28, 2024
…they are not combined in the internal migration (#58393)

When the internal mode for the `inject` migration is enabled, we find properties without initializers, we add their initializers and we prepend the `inject` calls before them. The remaining properties that couldn't be combined are left in place. This appears to break some internal cases.

These changes work around the issue by hoisting all the non-combined members above the `inject()` calls. This should be safe, because they don't have initializers and as such can't have dependencies.

PR Close #58393
alxhub pushed a commit that referenced this pull request Oct 28, 2024
…super call in some cases (#58393)

Fixes an issue where the `inject` migration was generating and attempting to insert code after a `super` call, but the string buffering implementation was dropping it if the statement right after the `super` call was deleted as a result of the migration.

PR Close #58393
alxhub pushed a commit that referenced this pull request Oct 28, 2024
…ation properties initialized to identifiers (#58393)

Fixes that when the `inject` migration in internal mode was starting to visit the nodes one level down from the root when considering whether an expression contains local references. This lead it to skip over top-level identifiers and migrate some code incorrectly.

PR Close #58393
alxhub pushed a commit that referenced this pull request Oct 28, 2024
…s before super call (#58393)

Fixes that if a class has a `super` call, the `inject` migration would always insert the generated variable before it, even if there's other code before the `super` call.

PR Close #58393
@alxhub alxhub closed this in a2a9ac7 Oct 28, 2024
alxhub pushed a commit that referenced this pull request Oct 28, 2024
…super call in some cases (#58393)

Fixes an issue where the `inject` migration was generating and attempting to insert code after a `super` call, but the string buffering implementation was dropping it if the statement right after the `super` call was deleted as a result of the migration.

PR Close #58393
alxhub pushed a commit that referenced this pull request Oct 28, 2024
…ation properties initialized to identifiers (#58393)

Fixes that when the `inject` migration in internal mode was starting to visit the nodes one level down from the root when considering whether an expression contains local references. This lead it to skip over top-level identifiers and migrate some code incorrectly.

PR Close #58393
alxhub pushed a commit that referenced this pull request Oct 28, 2024
…s before super call (#58393)

Fixes that if a class has a `super` call, the `inject` migration would always insert the generated variable before it, even if there's other code before the `super` call.

PR Close #58393
@angular-automatic-lock-bot
Copy link

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 Nov 28, 2024
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: migrations Issues related to `ng update` migrations target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants