Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor(client): use SourceFile to detect the Angular context in t… #2027

Merged

Conversation

ivanwonder
Copy link
Contributor

…he client

When using the typescript's scanner to parse the template literals which includes an expression, knowing the right CloseBraceToken of the expression to invoke the reScanTemplateToken function is a little complex. If don't do this, the rest of the file is temporarily "poisoned".

There is an explanation for why typescript's fast-acting lexical classifications don't work for template sting across lines.
microsoft/TypeScript#1477 (comment) https://github.com/microsoft/TypeScript/blob/a4d12a46c8b413c65a730c4ad0323459f1fc44ce/src/services/classifier.ts#L114

So this PR uses the SourceFile to detect the Angular context in the client.

@ivanwonder ivanwonder force-pushed the fix-detection-angular-context-in-client branch from 506a1f6 to 22c3422 Compare April 27, 2024 14:09
…he client

When using the typescript's scanner to parse the template literals which includes an expression,
knowing the right `CloseBraceToken` of the expression to invoke the `reScanTemplateToken`
function is a little complex. If don't do this, the rest of the file is temporarily "poisoned".

There is an explanation for why typescript's fast-acting lexical classifications don't work for
template sting across lines.
microsoft/TypeScript#1477 (comment)
https://github.com/microsoft/TypeScript/blob/a4d12a46c8b413c65a730c4ad0323459f1fc44ce/src/services/classifier.ts#L114

So this PR uses the `SourceFile` to detect the Angular context in the client.
Copy link
Collaborator

@atscott atscott left a comment

Choose a reason for hiding this comment

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

Great, thanks for doing this!

@atscott atscott added action: merge Ready to merge target: patch This PR is targeted for the next patch release labels Apr 29, 2024
@atscott atscott merged commit 13d9776 into angular:main Apr 29, 2024
5 checks passed
atscott pushed a commit that referenced this pull request Apr 29, 2024
…he client (#2027)

When using the typescript's scanner to parse the template literals which includes an expression,
knowing the right `CloseBraceToken` of the expression to invoke the `reScanTemplateToken`
function is a little complex. If don't do this, the rest of the file is temporarily "poisoned".

There is an explanation for why typescript's fast-acting lexical classifications don't work for
template sting across lines.
microsoft/TypeScript#1477 (comment)
https://github.com/microsoft/TypeScript/blob/a4d12a46c8b413c65a730c4ad0323459f1fc44ce/src/services/classifier.ts#L114

So this PR uses the `SourceFile` to detect the Angular context in the client.

(cherry picked from commit 13d9776)
@ivanwonder ivanwonder deleted the fix-detection-angular-context-in-client branch April 30, 2024 04:46
@angular-automatic-lock-bot
Copy link

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 May 31, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
action: merge Ready to merge target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants