Skip to content

Template parser incorrectly recovers from expression errors in some cases #61792

Closed

Description

@AndrewKushnir

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

https://stackblitz.com/edit/stackblitz-starters-n1vvscar

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

Angular v20, but likely reproducible in earlier versions as well.

Activity

  1. added
    area: compiler
    ai
    on May 30, 2025
  2. modified the milestone: needsTriage on May 30, 2025
  3. added
    P3
    on May 30, 2025
  4. modified the milestones: needsTriage, Backlog on May 30, 2025
  5. self-assigned this
    on May 31, 2025
  6. JeanMeche commented on May 31, 2025

    @JeanMeche
    Member

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

  7. crisbeto commented on May 31, 2025

    @crisbeto
    Member

    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.

  8. JeanMeche commented on May 31, 2025

    @JeanMeche
    Member

    unless we special-case as expressions

    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.

  9. crisbeto commented on May 31, 2025

    @crisbeto
    Member

    We actually treat as as a keyword already, because it's supported inside template microsyntax so that's something to consider as well.

  10. added a commit that references this issue on Jun 2, 2025
    8ecb1ba
  11. added a commit that references this issue on Jun 2, 2025
    fd5a049
  12. angular-automatic-lock-bot commented on Jul 3, 2025

    @angular-automatic-lock-bot

    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.

  13. locked and limited conversation to collaborators on Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3aiarea: compilercompiler: parserstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions