Skip to content

Warn on == / != in templates #44872

Closed as not planned
Closed as not planned

Description

@dgp1130

Which @angular/* package(s) are relevant/releated to the feature request?

compiler-cli

Description

In Angular templates, ==, !=, ===, and !== all map to their JavaScript equivalents. However the JS community has generally standardized on === and !== as the go to comparison operators, with many tools banning == and != outright from codebases. This is because == and != have unintuitive type conversion semantics which can be hard to reason about and lead to bugs. We should consider emitting a warning/error for these operators in Angular templates to catch these mistakes immediately and save the developer an hour of debugging.

Proposed solution

An extended diagnostic could easily identify this case and emit a warning. Users would also be free to configure the diagnostic as a hard error if they desired and truly purge == and != from their codebase.

Alternatives considered

You could expect me to remember not to do this, but that ain't happenin'.

Activity

  1. added
    feature
    area: compiler
    on Jan 28, 2022
  2. modified the milestone: Backlog on Jan 28, 2022
  3. angular-robot commented on Jan 28, 2022

    @angular-robot
    Contributor

    This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

    You can find more details about the feature request process in our documentation.

  4. added
    feature: under consideration
    and removed on Jan 28, 2022
  5. DaSchTour commented on Feb 1, 2022

    @DaSchTour
  6. added 4 commits that reference this issue on Oct 19, 2022
    18d84a5
    3005a84
    45d011f
    a9a18ff
  7. JeanMeche commented on Sep 25, 2025

    @JeanMeche
    Member

    I'd say this one is of the scope of linters. (It's perfectly valid to use them, we shouldn't warn by default).

  8. angular-automatic-lock-bot commented on Oct 26, 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilercompiler: extended diagnosticsfeaturefeature: under consideration

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions