-
Notifications
You must be signed in to change notification settings - Fork 26.3k
refactor(migration): support local string tokens for inject migration #62013
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
Conversation
1ae5894
to
f2c6539
Compare
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.
LGTM!
The `localTypeChecker` allows us to at least support locally defined strings in addition to string literals.
f2c6539
to
6ba7462
Compare
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.
Minor nits to clarify that it is known that this support is only for locally declared symbols.
@@ -145,6 +145,35 @@ describe('inject migration', () => { | |||
]); | |||
}); | |||
|
|||
it('should account for string tokens in @Inject()', async () => { |
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.
it('should account for string tokens in @Inject()', async () => { | |
it('should account for locally declared string tokens in @Inject()', async () => { |
@@ -885,3 +885,10 @@ function replaceParameterReferencesInInitializer( | |||
|
|||
return result.join('this.'); | |||
} | |||
|
|||
function isStringType(node: ts.Expression, checker: ts.TypeChecker): boolean { |
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'd add a docblock here to mention this results in false negatives for imported declarations, which we considered acceptable
This PR was merged into the repository by commit 4040a6b. The changes were merged into the following branches: main, 20.0.x |
The
localTypeChecker
allows us to at least support locally defined strings in addition to string literals.Improves a bit the issue repported by #61982.