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.
Is this a symptom of not using updatePropertyDeclaration?
There was a problem hiding this comment.
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.
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.
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.
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: