Skip to content
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

fix(compiler): Update type check block to fix control flow source mappings #53980

Closed
wants to merge 3 commits into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Jan 18, 2024

The source mappings and types for various pieces of the control flow were not quite right and prevented the language service from providing accurate information.

fixes angular/vscode-ng-language-service#1988

…pings

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988
@atscott atscott requested a review from crisbeto January 18, 2024 20:30
@atscott atscott added target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler labels Jan 18, 2024
@ngbot ngbot bot added this to the Backlog milestone Jan 18, 2024
@atscott atscott marked this pull request as ready for review January 22, 2024 19:11
initializer = ts.factory.createAsExpression(
initializer, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword));
}
const initializer: ts.Expression = ts.factory.createAsExpression(
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to cast for all cases, should we just not pass the type in createVariableDeclaration? E.g. const _t1 = null! as Foo instead of const _t1: Foo = null! as Foo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, so I also had this thought and it mostly works. The problem is with the "find references" operation. If I find references for Foo, instead of getting the variable t1, I get the type assertion. This makes it difficult to get the correct source map for the variable. It's technically possible, but would require some adjustments in logic for references that I'm not sure is worth it. I'll add a comment about this because Alex had the same question.

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel strongly about it, but I'm concerned if it won't have any impact on type checking performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I added a fixup commit to adjust the references code to account for this. Let me know how you feel about it.

packages/compiler/src/render3/r3_control_flow.ts Outdated Show resolved Hide resolved
@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Jan 24, 2024
jessicajaniuk pushed a commit that referenced this pull request Jan 24, 2024
…pings (#53980)

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988

PR Close #53980
@jessicajaniuk
Copy link
Contributor

This PR was merged into the repository by commit eddf5da.

atscott added a commit to atscott/angular that referenced this pull request Jan 26, 2024
…pings (angular#53980)

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988

PR Close angular#53980
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…pings (angular#53980)

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988

PR Close angular#53980
danieljancar pushed a commit to danieljancar/angular that referenced this pull request Jan 26, 2024
…pings (angular#53980)

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988

PR Close angular#53980
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…pings (angular#53980)

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988

PR Close angular#53980
nikvarma pushed a commit to nikvarma/angular that referenced this pull request Jan 31, 2024
…pings (angular#53980)

The source mappings and types for various pieces of the control flow
were not quite right and prevented the language service from providing
accurate information.

fixes angular/vscode-ng-language-service#1988

PR Close angular#53980
@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 Feb 24, 2024
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: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types doesn't show in language service for @for loop items
3 participants