Skip to content

Warning for directive not used within the template, when it actually is #70471

Description

@Gouvernathor

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

compiler

Is this a regression?

No idea

Description

I get a warning that a directive that I put in the imports field of my component is not used, but actually it is used in the template and removing it from the imports changes/breaks the display.

In the component's template, the directive is used to pass a static string (so, in a templateId="rawvalue" syntax and not [templateId]="valueVariable"), and it is used on a <ng-template> node.

Please provide a link to a minimal reproduction of the bug

https://codeberg.org/Gouvernathor/Apportionment-angular/src/branch/repro

(notice the name of the branch)

Please provide the exception or error you saw

▲ [WARNING] NG8113: TemplateId is not used within the template of Index [plugin angular-compiler]

    src/app/+index/index.ts:9:52:
      9 │     imports: [StateName, ParliamentarchPrecomputed, TemplateId],
        ╵                                                     ~~~~~~~~~~

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

Angular CLI       : 21.2.11
Angular           : 21.2.13
Node.js           : 26.4.0 (Unsupported)
Package Manager   : npm 11.8.0
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.2.11           │ ^21.2.2           │
│ @angular/cli              │ 21.2.11           │ ^21.2.2           │
│ @angular/common           │ 21.2.13           │ ^21.2.0           │
│ @angular/compiler         │ 21.2.13           │ ^21.2.0           │
│ @angular/compiler-cli     │ 21.2.13           │ ^21.2.0           │
│ @angular/core             │ 21.2.13           │ ^21.2.0           │
│ @angular/forms            │ 21.2.13           │ ^21.2.0           │
│ @angular/platform-browser │ 21.2.13           │ ^21.2.0           │
│ @angular/router           │ 21.2.13           │ ^21.2.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.1.6             │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

No response

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 gemini

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions