You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Template parser incorrectly recovers from expression errors in some cases #61792
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentaiIssue related to using AI agentsarea: compilerIssues related to `ngc`, Angular's template compilercompiler: parserstate: has PR
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
In some cases, when a template contains expressions with invalid syntax, for example:
<input (input)="newBookmarkTags.set(($event.target as HTMLInputElement).value)">
Template parser identifies a problem, but can't recover from it, producing a build error with a lot of unrelated information.
Adding the "ai" label, since the code was originally generated by an LLM and having a clear and focused error message would increase a likelihood of a successful "repair" request to an LLM (asking to fix a given build error).
Please provide a link to a minimal reproduction of the bug
@crisbeto's improvement (#61793) goes in the right direction, but we also have an issue with the as operator which is not supported by our template syntax yet it is highlighted correctly.
It's actually because we don't recover properly for parenthesized expressions that don't end on a paren token. I think that producing only a single error here can be tricky, unless we special-case as expressions, because we want to try and recover at least partially for the sake of the language service. Attempting to recover triggers more errors as a result.
This is what I was thinking about yes. as is a common TS operator that we obviously don't support. It might be valuable to have a better error message around. I don't feel too strongly about, but I think it is worth discussing.
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentaiIssue related to using AI agentsarea: compilerIssues related to `ngc`, Angular's template compilercompiler: parserstate: has PR
Activity
fix(compiler): only report parser errors on invalid expression
JeanMeche commentedon May 31, 2025
@crisbeto's improvement (#61793) goes in the right direction, but we also have an issue with the
asoperator which is not supported by our template syntax yet it is highlighted correctly.crisbeto commentedon May 31, 2025
It's actually because we don't recover properly for parenthesized expressions that don't end on a paren token. I think that producing only a single error here can be tricky, unless we special-case
asexpressions, because we want to try and recover at least partially for the sake of the language service. Attempting to recover triggers more errors as a result.JeanMeche commentedon May 31, 2025
This is what I was thinking about yes.
asis a common TS operator that we obviously don't support. It might be valuable to have a better error message around. I don't feel too strongly about, but I think it is worth discussing.crisbeto commentedon May 31, 2025
We actually treat
asas a keyword already, because it's supported inside template microsyntax so that's something to consider as well.fix(compiler): only report parser errors on invalid expression
fix(compiler): recover invalid parenthesized expressions
fix(compiler): only report parser errors on invalid expression (#61793)
fix(compiler): recover invalid parenthesized expressions (#61815)
fix(compiler): recover invalid parenthesized expressions (angular#61815)
angular-automatic-lock-bot commentedon Jul 3, 2025
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.