Skip to content

refactor(migration): support local string tokens for inject migration - #62013

Closed
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:schematics/inject-string-var
Closed

JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:schematics/inject-string-var

Conversation

@JeanMeche

@JeanMeche JeanMeche commented Jun 11, 2025 •

Copy link
Copy Markdown
Member

The localTypeChecker allows us to at least support locally defined strings in addition to string literals.

Improves a bit the issue repported by #61982.

@pullapprove
pullapprove Bot requested a review from thePunderWoman June 11, 2025 17:19
@JeanMeche
JeanMeche force-pushed the schematics/inject-string-var branch from 1ae5894 to f2c6539 Compare June 11, 2025 17:20

@thePunderWoman thePunderWoman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@JeanMeche JeanMeche added target: patch This PR is targeted for the next patch release area: migrations Issues related to `ng update`/`ng generate` migrations labels Jun 11, 2025
@ngbot ngbot Bot modified the milestone: Backlog Jun 11, 2025
The `localTypeChecker` allows us to at least support locally defined strings in addition to string literals.
@JeanMeche
JeanMeche force-pushed the schematics/inject-string-var branch from f2c6539 to 6ba7462 Compare June 11, 2025 17:25
@JeanMeche JeanMeche added the action: merge The PR is ready for merge by the caretaker label Jun 11, 2025

@JoostK JoostK left a comment

Copy link
Copy Markdown
Member

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.

]);
});

it('should account for string tokens in @Inject()', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should account for string tokens in @Inject()', async () => {
it('should account for locally declared string tokens in @Inject()', async () => {

return result.join('this.');
}

function isStringType(node: ts.Expression, checker: ts.TypeChecker): boolean {

Copy link
Copy Markdown
Member

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

@pkozlowski-opensource

Copy link
Copy Markdown
Member

This PR was merged into the repository by commit 4040a6b.

The changes were merged into the following branches: main, 20.0.x

pkozlowski-opensource pushed a commit that referenced this pull request Jun 12, 2025
#62013)

The `localTypeChecker` allows us to at least support locally defined strings in addition to string literals.

PR Close #62013
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jul 15, 2025
@JeanMeche
JeanMeche deleted the schematics/inject-string-var branch August 29, 2025 00:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: migrations Issues related to `ng update`/`ng generate` migrations target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants