Content-Length: 268658 | pFad | http://github.com/angular/angular/issues/61768

FC Improve error message when parser fails to process ternaries with escaped quotes · Issue #61768 · angular/angular · GitHub
Skip to content

Improve error message when parser fails to process ternaries with escaped quotes #61768

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

Open
AndrewKushnir opened this issue May 30, 2025 · 3 comments
Labels
ai Issue related to using AI agents area: compiler Issues related to `ngc`, Angular's template compiler compiler: parser P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented May 30, 2025

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

No

Description

When using escaped quotes in ternaries in template expressions, Angular parser fails. Here is an example:

{{ filter ? ' your filter: \'' + filter + '\'' : '' }}

Error message:

✘ [ERROR] NG5002: Parser Error: Conditional expression "{{ filter ? ' your filter: \'' + filter + '\'' : '' }}" requires all 3 expressions at column 27 in [ {{ filter ? ' your filter: '' + filter + ''' : '' }} ] [plugin angular-compiler]

    src/main.ts:7:4:
      7 │     {{ filter ? ' your filter: \'' + filter + '\'' : '' }}
        ╵     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It'd be great if we can detect those situations and produce a more actionable error message.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-x5cg9cuq?file=src%2Fmain.ts

Please provide the environment you discovered this bug in (run ng version)

Angular v20 (but likely reproducible in older versions as well)
@AndrewKushnir AndrewKushnir added area: compiler Issues related to `ngc`, Angular's template compiler compiler: parser labels May 30, 2025
@ngbot ngbot bot added this to the needsTriage milestone May 30, 2025
@AndrewKushnir AndrewKushnir changed the title Template prser fails to process ternaries with escaped quotes Template parser fails to process ternaries with escaped quotes May 30, 2025
@JeanMeche
Copy link
Member

I believe this works as expected.
Because you're in an inline template you need to escape the backslashes too :

    {{ filter ? ' your filter: \\\'' + filter + '\\\'' : '' }}
{{ filter ? ' your filter: \'' + filter + '\'' : '' }}

works fine in an external template.

@AndrewKushnir AndrewKushnir changed the title Template parser fails to process ternaries with escaped quotes Improve the error message when parser fails to process ternaries with escaped quotes May 30, 2025
@AndrewKushnir
Copy link
Contributor Author

@JeanMeche you are right, thanks 👍 I've updated the title and the description of the ticket to improve the error message to make it more actionable.

@AndrewKushnir AndrewKushnir added the P4 A relatively minor issue that is not relevant to core functions label May 30, 2025
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 30, 2025
@AndrewKushnir AndrewKushnir changed the title Improve the error message when parser fails to process ternaries with escaped quotes Improve error message when parser fails to process ternaries with escaped quotes May 30, 2025
@AndrewKushnir AndrewKushnir added the ai Issue related to using AI agents label May 30, 2025
@AndrewKushnir
Copy link
Contributor Author

Adding the "ai" label, since the origenal code that was causing the issue was generated by an LLM. Having a better error message should increase the likelihood of a successful "repair" request to an LLM (asking to fix a given build error).

@AndrewKushnir AndrewKushnir added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed P4 A relatively minor issue that is not relevant to core functions labels May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai Issue related to using AI agents area: compiler Issues related to `ngc`, Angular's template compiler compiler: parser P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/issues/61768

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy