Template diagnostics not updated in watch mode on Windows when the type-check block is unchanged

Offen
#34,725 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

  • #34733 von @Matt-code-d — ohne Merge geschlossen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
angular, typescript

Rechercherichtung

Start with the resource invalidation check in packages/angular/build/src/tools/angular/compilation/aot-compilation.ts and the modified file handling in packages/angular/build/src/tools/esbuild/angular/source-file-cache.ts. Trace how resource dependency paths are compared during ng serve watch rebuilds on Windows, then check the existing compilation tests for coverage of that path comparison. Done means template diagnostics refresh on Windows when a template changes without changing its type-check shim, while Linux behavior remains correct.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area: @angular/build
Command

serve

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

On Windows, during ng serve, a template edit that changes Angular diagnostics without changing the generated type-check code is not diagnosed: a stray </span> (NG5002) still ends with "Application bundle generation complete", and [attr.width.px] never shows NG8106. Linux and ng build report both correctly.

The resource check that invalidates diagnosticCache (aot-compilation.ts#L334) looks up forward-slash paths from getResourceDependencies() in modifiedFiles, which holds path.normalized backslash paths (source-file-cache.ts#L42), so it never matches on Windows:

modifiedFiles:        ["C:\\repro\\src\\app\\app.html"]
resourceDependencies: ["C:/repro/src/app/app.html"]
match:                false   (Linux: true)

Edits that change the .ngtypecheck.ts shim are still picked up by the TypeScript builder; the others rely on this check alone. A possible fix is hostOptions.modifiedFiles.has(path.normalize(resourceDependency)).

Minimal Reproduction

Repro: https://github.com/te-gis-dev/ng-stale-template-diagnostics (node repro.mjs runs all steps against ng serve and restores the files).

With @angular/build 22.2.7, run ng serve, then:

  1. Append </span> to src/app/app.html. Expected NG5002; actual on Windows: build completes, no error.
  2. Revert, then append <p [attr.width.px]="1"></p>. Expected NG8106 warning; actual on Windows: none.
  3. Add a blank line to src/app/app.ts. The missing diagnostics appear.
Setup Stray </span> [attr.width.px]
22.2.7, Windows 11, Node 26.12.1 not reported not reported
22.2.7, Linux (Docker node:24) correct correct
Exception or Error
Windows:
Application bundle generation complete.

Linux:
✘ [ERROR] NG5002: Unexpected closing tag "span". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags [plugin angular-compiler]
Application bundle generation failed.
Your Environment
Angular CLI       : 22.2.7
Angular           : 22.2.6
Node.js           : 26.12.1
Package Manager   : npm 11.16.0
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 22.2.7            │ 22.2.7            │
│ @angular/cli              │ 22.2.7            │ 22.2.7            │
│ @angular/common           │ 22.2.6            │ 22.2.6            │
│ @angular/compiler         │ 22.2.6            │ 22.2.6            │
│ @angular/compiler-cli     │ 22.2.6            │ 22.2.6            │
│ @angular/core             │ 22.2.6            │ 22.2.6            │
│ @angular/forms            │ 22.2.6            │ 22.2.6            │
│ @angular/platform-browser │ 22.2.6            │ 22.2.6            │
│ @angular/router           │ 22.2.6            │ 22.2.6            │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 6.0.3             │ 6.0.3             │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
  • Windows only; drive-letter casing is not involved.
  • Latent on main / 22.3.0-rc.0: #34173 marks the component affected through Angular's incremental compilation first, but the lookup is still false on Windows. The check has never matched there since #25940.
  • On 22.2.x it also locks in the stale cached error fixed by #34173: while it is served, every template edit on Windows is ignored (repro.mjs steps 1-6).
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
225

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.