Skip to content
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

Remove unused imports in inject migration #57179

Closed
wants to merge 3 commits into from

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.

… 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` 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: migrations Issues related to `ng update` 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.

None yet

3 participants