Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(compiler): move defer trigger assertions out of parser #61747

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

Closed

Conversation

crisbeto
Copy link
Member

When defer blocks have a reference-based trigger without a parameter, we infer it from the placeholder block. This requires some validations like ensuring that there's only one element in the placeholder. The validations are currently implemented at the parser level which can affect tools like linters that need to pass preserveWhitespaces: true in order to get accurate source mappings.

These changes move the validations into the template type checker so that they still get flagged, but much later in the process. Moving them over involves a bit more work, because the template type checker also sets preserveWhitespaces: true.

Fixes #61725.

When defer blocks have a reference-based trigger without a parameter, we infer it from the placeholder block. This requires some validations like ensuring that there's only one element in the placeholder. The validations are currently implemented at the parser level which can affect tools like linters that need to pass `preserveWhitespaces: true` in order to get accurate source mappings.

These changes move the validations into the template type checker so that they still get flagged, but much later in the process. Moving them over involves a bit more work, because the template type checker also sets `preserveWhitespaces: true`.

Fixes angular#61725.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels May 29, 2025
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label May 29, 2025
@ngbot ngbot bot added this to the Backlog milestone May 29, 2025
@@ -1120,7 +1119,7 @@ class R3BoundTarget<DirectiveT extends DirectiveMeta> implements BoundTarget<Dir
const name = trigger.reference;

if (name === null) {
let trigger: Element | null = null;
let target: Element | null = null;
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is unrelated. I just noticed that the variable name was shadowing one of the parameters.

@crisbeto crisbeto requested a review from devversion May 29, 2025 10:17
@crisbeto crisbeto marked this pull request as ready for review May 29, 2025 10:17
@pullapprove pullapprove bot requested review from alxhub and AndrewKushnir May 29, 2025 10:18
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@crisbeto
Copy link
Member Author

Passing TGP

Copy link
Contributor

@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.

reviewed-for: public-api

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 29, 2025
@kirjs
Copy link
Contributor

kirjs commented May 30, 2025

This PR was merged into the repository by commit a70f03a.

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

@kirjs kirjs closed this in a70f03a May 30, 2025
kirjs pushed a commit that referenced this pull request May 30, 2025
When defer blocks have a reference-based trigger without a parameter, we infer it from the placeholder block. This requires some validations like ensuring that there's only one element in the placeholder. The validations are currently implemented at the parser level which can affect tools like linters that need to pass `preserveWhitespaces: true` in order to get accurate source mappings.

These changes move the validations into the template type checker so that they still get flagged, but much later in the process. Moving them over involves a bit more work, because the template type checker also sets `preserveWhitespaces: true`.

Fixes #61725.

PR Close #61747
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

preserveWhitespaces can break defer placeholder detection
4 participants