-
Notifications
You must be signed in to change notification settings - Fork 27k
More inject follow-up fixes #57389
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
More inject follow-up fixes #57389
Conversation
Fixes that the migration was duplicating the doc strings of members that don't have modifiers.
Updates the migration so that it passes the type as a generic in the case of `@Inject(SOME_TOKEN) foo: SomeType`. This is done for two reasons: 1. It's a fairly common pattern and it ensures that the code can still be compiled. 2. It avoids leaving behind unused imports.
| const newProperty = ts.factory.createPropertyDeclaration( | ||
| cloneModifiers(property.modifiers), | ||
| property.name, | ||
| cloneName(property.name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a symptom of not using updatePropertyDeclaration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using updatePropertyDeclaration earlier, but it had the same issue where it was duplicating the comments. The problem is that TS attaches the comments to the first node within the property declaration. E.g. if it has modifiers, it'll be on the first modifier, otherwise it's on the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. How will the comment be preserved if there are no modifiers, and the name is "cloned" (as a synthetic node)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment gets preserved because the ChangeTracker removes between Node.getStart() and Node.getEnd() which doesn't include the comment ranges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. I was only seeing the getFullStart below.
|
This PR was merged into the repository by commit 58a79b6. The changes were merged into the following branches: main, 18.2.x |
Updates the migration so that it passes the type as a generic in the case of `@Inject(SOME_TOKEN) foo: SomeType`. This is done for two reasons: 1. It's a fairly common pattern and it ensures that the code can still be compiled. 2. It avoids leaving behind unused imports. PR Close #57389
Updates the migration so that it passes the type as a generic in the case of `@Inject(SOME_TOKEN) foo: SomeType`. This is done for two reasons: 1. It's a fairly common pattern and it ensures that the code can still be compiled. 2. It avoids leaving behind unused imports. PR Close #57389
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes a couple more issues that came up from testing the
injectmigration.fix(migrations): account for members with doc strings and no modifiers
Fixes that the migration was duplicating the doc strings of members that don't have modifiers.
fix(migrations): preserve type when using inject decorator
Updates the migration so that it passes the type as a generic in the case of
@Inject(SOME_TOKEN) foo: SomeType. This is done for two reasons: