Report bindings that have no effect on ng-container, ng-template, and ng-content
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- angular, typescript
Direzione di ricerca
Start by reading the Angular compiler, compiler-cli, and core paths responsible for template type checking, extended diagnostics, language-service completions, and dev-mode binding checks. The proposed work spans diagnostics, runtime logging, parsing, and later breaking severity changes; the issue links PRs #71882, #71883, and #71884, which indicate work is already underway. Done means ignored bindings and invalid component selectors are reported as described, while bindings that take effect remain unreported.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Which @angular/* package(s) are relevant/related to the feature request?
compiler, compiler-cli, core
Description
<ng-container>, <ng-template>, and <ng-content> don't render an element. Angular accepts
bindings and attributes on them that can never take effect, and most of them compile and run
without a word:
<ng-container class="card" [class.active]="isActive" (click)="select()">...</ng-container>
<ng-template [title]="label" (click)="missing()">...</ng-template>
<ng-content selector="h1" />
Nothing on these lines does anything:
- Class, style, and event bindings on
<ng-container>and<ng-template>are ignored, unless a
directive claims them. - Bindings that no directive claims on
<ng-template>aren't type-checked, so
(click)="missing()"compiles. <ng-content>ignores every binding, and every attribute exceptselectandngProjectAs. The
selectortypo (forselect) silently makes the slot a default slot. Angular's own upgrade
examples have had this typo since 2017.NO_ERRORS_SCHEMAhides unknown properties on<ng-container>, although no schema can give it
a property.- Inside
<svg>,[attr.x]on<ng-container>skips its parse error and throws a misleading
assertion in dev mode.
Proposed solution
Report what Angular ignores, and nothing that takes effect. Code generation and runtime behavior
don't change.
Step 1, not breaking:
- NG8031
ignoredBinding, a new type-check diagnostic. It needs
strictTemplates, is a warning by default, and is configured through
extendedDiagnostics.checks, like NG8011. It reports class, style,attr., animation, and
event bindings that no directive claims, every binding on<ng-content>, and static attributes
that nothing reads. - NG8032, a template type-check warning for a component whose selector matches
<ng-container>or<ng-template>. That compiles today and fails only when the template
renders, in dev and production mode. - The language service stops suggesting DOM attributes on
<ng-container>. - NG0319, a dev-mode runtime log for class, style, and event bindings on
<ng-container>and
<ng-template>, so JIT is covered too. - The
<svg>parse fix.
Step 2, breaking: severities only, in two independent PRs.
- NG8032 is an error.
- NG8031 is an error by default, and NG0319 throws under
errorOnUnknownProperties.
Every new error points at a binding or component that never worked. NG8031 can be set back to
"warning" or "suppress".
Not reported: bindings a directive claims, directive host bindings (directives are reusable),
global event targets, and static attributes that a directive, a structural directive, a content
projection slot, or Angular itself reads.
Question for the team: are the step 2 PRs fine for a minor release, or should they wait for a
major? They can land separately.
PRs: #71882 (step 1); #71883 (NG8032 error) and #71884 (NG8031 error), each building on #71882
Alternatives considered
- A template parse error. The linker re-parses published libraries, so a parse error would
break libraries that compile today. - Only an extended diagnostic. It can warn, but step 2 needs the same check in the type
checker. One check in the type checker serves both levels. - Only a runtime error. It reports late, in dev mode only, and can't see bindings on
<ng-content>or which static attributes something reads. - Also reporting directive host bindings. A directive can apply to elements where those
bindings work, so reporting them would be noise.
- Lingua principale
- TypeScript
- Stelle
- 101k
- Fork
- 28.2k
- Merge medio
- 2g 45m
- PR unite (30g)
- 373
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/angular
-
Two-way binding documentation is missing important informationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaarea: docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
angular/angular#71796 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
resource.reload() while params is in error switches the resource to 'idle' instead of retryingApertaarea: core
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
angular/angular#71585 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Assigning to a template reference in an event binding isn't reported by the compilerForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaarea: compiler
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
angular/angular#71511 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Signal Forms: `validateStandardSchema` throws a TypeError for an issue whose path runs through a key the model lacksForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea: forms gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`Symbol.iterator in FieldTree` is always falseForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaarea: forms forms: signals
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
angular/angular#70252 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di angular/angular
Issue simili
-
truapi-release
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
paritytech/product-sdk#529 ·
I maintainer di solito rispondono entro 1 giorno
-
Environments table lists page size 5 after 30Forse già presa @raus7n l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
litmuschaos/litmus#5743 ·
I maintainer di solito rispondono entro 2 giorni
-
desktop grp:admin-donors type:graphics-bug ui-admin
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
milind-soni/OpenMausBot#6730 ·
I maintainer di solito rispondono entro 1 giorno
-
Status: Triage Type: Bug / Error
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
mermaid-js/mermaid-v13#1059 ·
I maintainer di solito rispondono entro 1 giorno