Skip to content

Conversation

@crisbeto
Copy link
Member

Updates some migration utilities and adds logic to drop unused imports in the inject migration. Made up of the following changes:

refactor(migrations): add the ability to remove imports in the change tracker

Updates the ChangeTracker to integrate the changes from #57110.

refactor(migrations): optimize some of the import utilities

Makes a few optimizations in the utilities we use for dealing with imports in migrations. I didn't end up using these in the inject migration, but they should still come in handy. Includes:

  1. Exiting isReferenceToImport early when the node being checked is an identifier and it doesn't match the identifier of the import. This saves us some type checker calls.
  2. Adds the ability to pass a single string to getImportSpecifiers. This saves us unnecessary arrays and for loops.

fix(migrations): remove unused imports in inject migration

The inject migration can leave some unused imports behind when it removes decorators like @Inject. These changes add some logic to remove them.

crisbeto added 3 commits July 29, 2024 10:40
… tracker

Updates the `ChangeTracker` to integrate the changes from angular#57110.
Makes a few optimizations in the utilities we use for dealing with imports in migrations. I didn't end up using these in the inject migration, but they should still come in handy. Includes:
1. Exiting `isReferenceToImport` early when the node being checked is an identifier and it doesn't match the identifier of the import. This saves us some type checker calls.
2. Adds the ability to pass a single string to `getImportSpecifiers`. This saves us unnecessary arrays and for loops.
The `inject` migration can leave some unused imports behind when it removes decorators like `@Inject`. These changes add some logic to remove them.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer area: migrations Issues related to `ng update`/`ng generate` migrations target: minor This PR is targeted for the next minor release labels Jul 29, 2024
@crisbeto crisbeto requested a review from devversion July 29, 2024 10:28
@ngbot ngbot bot added this to the Backlog milestone Jul 29, 2024
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 29, 2024
@dylhunn
Copy link
Contributor

dylhunn commented Jul 29, 2024

This PR was merged into the repository by commit ba0df30.

The changes were merged into the following branches: main

@dylhunn dylhunn closed this in 2ffa417 Jul 29, 2024
dylhunn pushed a commit that referenced this pull request Jul 29, 2024
Makes a few optimizations in the utilities we use for dealing with imports in migrations. I didn't end up using these in the inject migration, but they should still come in handy. Includes:
1. Exiting `isReferenceToImport` early when the node being checked is an identifier and it doesn't match the identifier of the import. This saves us some type checker calls.
2. Adds the ability to pass a single string to `getImportSpecifiers`. This saves us unnecessary arrays and for loops.

PR Close #57179
dylhunn pushed a commit that referenced this pull request Jul 29, 2024
The `inject` migration can leave some unused imports behind when it removes decorators like `@Inject`. These changes add some logic to remove them.

PR Close #57179
@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 Aug 29, 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`/`ng generate` migrations target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants