Remove unused imports in inject migration #57179
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates some migration utilities and adds logic to drop unused imports in the
injectmigration. Made up of the following changes:refactor(migrations): add the ability to remove imports in the change tracker
Updates the
ChangeTrackerto 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:
isReferenceToImportearly 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.getImportSpecifiers. This saves us unnecessary arrays and for loops.fix(migrations): remove unused imports in inject migration
The
injectmigration can leave some unused imports behind when it removes decorators like@Inject. These changes add some logic to remove them.