Skip to content

bug(compiler): strictTemplates fails to report unknown property binding when a standalone directive is missing from component imports #69322

@sysmat

Description

@sysmat

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

compiler

Is this a regression?

Yes

Description

  • When using a standalone attribute directive in a template via property binding syntax (e.g., [myDirective]="value"), the Angular compiler completely ignores the binding if the directive is forgotten in the @Component.imports array.

  • Even with strictTemplates: true and extended diagnostics enabled, the compiler does not throw an error or warning about an unknown property on standard HTML elements (like div), provided the bound expression is a method call or a valid property.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

import { Directive, Input } from '@angular/core';

@Directive({
  selector: '[auiTypedOption]',
  standalone: true
})
export class TypedOptionDirective {
  @Input() auiTypedOption: any;
}



import { Component } from '@angular/core';

@Component({
  selector: 'app-test',
  standalone: true,
  imports: [], // <-- TypedOptionDirective is missing here
  template: `
    <div [auiTypedOption]="searchResult()"></div>
  `
})
export class TestComponent {
  searchResult() {
    return { query: 'test' };
  }
}



{
  "angularCompilerOptions": {
    "strictTemplates": true,
    "extendedDiagnostics": {
      "defaultCategory": "error",
      "checks": {
        "missingControlFlowDirective": "error"
      }
    }
  }
}

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

Angular CLI       : 21.2.14
Angular           : 21.2.17
Node.js           : 24.16.0
Package Manager   : npm 11.10.0
Operating System  : win32 x64

┌───────────────────────────────┬───────────────────┬───────────────────┐
│ Package                       │ Installed Version │ Requested Version │
├───────────────────────────────┼───────────────────┼───────────────────┤
│ @angular-devkit/build-angular │ 21.2.14           │ ^21.2.14          │
│ @angular/build                │ 21.2.14           │ ^21.2.14          │
│ @angular/cli                  │ 21.2.14           │ 21.2.14           │
│ @angular/common               │ 21.2.17           │ 21.2.17           │
│ @angular/compiler             │ 21.2.17           │ 21.2.17           │
│ @angular/compiler-cli         │ 21.2.17           │ 21.2.17           │
│ @angular/core                 │ 21.2.17           │ 21.2.17           │
│ @angular/forms                │ 21.2.17           │ 21.2.17           │
│ @angular/language-service     │ 21.2.17           │ 21.2.17           │
│ @angular/localize             │ 21.2.17           │ ^21.2.17          │
│ @angular/platform-browser     │ 21.2.17           │ 21.2.17           │
│ @angular/router               │ 21.2.17           │ 21.2.17           │
│ @angular/service-worker       │ 21.2.17           │ 21.2.17           │
│ rxjs                          │ 7.8.2             │ ^7.8.2            │
│ typescript                    │ 5.9.3             │ 5.9.3             │
│ zone.js                       │ 0.16.2            │ ~0.16.2           │
└───────────────────────────────┴───────────────────┴───────────────────┘

Anything else?

Because TypedOptionDirective is not imported, the template compiler should evaluate [auiTypedOption] as a plain property binding on a div element. Since HTMLDivElement does not have a auiTypedOption property, strictTemplates should catch this and throw:
NG8002: Can't bind to 'auiTypedOption' since it isn't a known property of 'div'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilergemini-triagedLabel noting that an issue has been triaged by geminineeds reproductionThis issue needs a reproduction in order for the team to investigate further

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions