Skip to content

missingStructuralDirective diagnostic ignores elements with other directives #64467

@mattlewis92

Description

@mattlewis92

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

compiler-cli

Is this a regression?

No

Description

When another directive is present on an element with a missing structural directive, the diagnostic ignores it e.g.

@Component({
  selector: 'app-root',
  template: `
   <div
    *foo="bar"
    [routerLink]="[]"
  >
    {{ bar }}
  </div>

  `,
  imports: [RouterLink],
})
export class App {
  bar = 'bar';
}

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-obb3tiia?description=An%20angular-cli%20project%20based%20on%20@angular/animations,%20@angular/common,%20@angular/compiler,%20@angular/core,%20@angular/forms,%20@angular/platform-browser,%20@angular/platform-browser-dynamic,%20@angular/router,%20core-js,%20rxjs,%20tslib%20and%20zone.js&file=src%2Fmain.ts,package.json,tsconfig.app.json&template=node&title=Angular%20Starter

Please provide the exception or error you saw

No typecheck error was reported when it should have been

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

Angular CLI: 20.3.3
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64
    

Angular: 20.3.3
... animations, build, cli, common, compiler, compiler-cli, core
... forms, platform-browser, router

Package                      Version
------------------------------------
@angular-devkit/architect    0.2003.3
@angular-devkit/core         20.3.3
@angular-devkit/schematics   20.3.3
@schematics/angular          20.3.3
rxjs                         7.8.2
typescript                   5.9.2
zone.js

Anything else?

The root cause of the issue is here:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions