Files
Doug Parker ac2f262e9a docs: add extended diagnostics documentation (#44704)
This includes the initial documentation for extended diagnostics with a page for each of the two initial checks. They follow the same general formula, and hopefully in the future they can be properly generated from metadata rather than copy-pasted as they are currently.

PR Close #44704
2022-01-24 10:41:13 -08:00

1.2 KiB

@name Invalid Banana-in-Box

@description

This diagnostic detects a backwards "banana-in-box" syntax for two-way bindings.

<div ([var])="otherVar"></div>

What's wrong with that?

As it stands, ([var]) is actually an event binding with the name [var]. The author likely intended this as a two-way binding to a variable named var but as written this binding has no effect.

What should I do instead?

Fix the typo. As the name suggests, the banana ( should go inside the box []. In this case:

<div [(var)]="otherVar"></div>

Configuration requirements

strictTemplates must be enabled for any extended diagnostic to emit. invalidBananaInBox has no additional requirements beyond strictTemplates.

What if I can't avoid this?

This diagnostic can be disabled by editing the project's tsconfig.json file:

{
  "angularCompilerOptions": {
    "extendedDiagnostics": {
      "checks": {
        "invalidBananaInBox": "suppress"
      }
    }
  }
}

See extended diagnostic configuration for more info.