Skip to content

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

Closed

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

Activity

  1. added this to the needsTriage milestone on Aug 29, 2026
  2. added this to the needsTriage milestone on Aug 29, 2026
  3. JeanMeche commented on Aug 29, 2026

    @JeanMeche
  4. JeanMeche commented on Aug 29, 2026

    @JeanMeche
    Member

    Actually this is related to the nested use of ng-template inside a svg block.

    Minimal repro:

        <ng-template #foo>foo</ng-template>
        <svg>
          <ng-template [ngTemplateOutlet]="foo"></ng-template>
        </svg>
    

    And #69640 does not fix that yet.

  5. added 5 commits that reference this issue on Aug 30, 2026
    01aa7d1
    acd37b8
    6a76c0e
    8ee3e84
    a8550db
  6. added 4 commits that reference this issue on Sep 20, 2026
    46c9f3b
    06c8088
    d131a8a
    aa9df6e
  7. added a commit that references this issue on Oct 1, 2026
    a9d6b2f
  8. added a commit that references this issue on Oct 1, 2026
    97e5715
  9. angular-automatic-lock-bot commented on Nov 1, 2026

    @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.

  10. locked and limited conversation to collaborators on Nov 1, 2026
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: compilerIssues related to `ngc`, Angular's template compiler

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions