angular / angular/components

feat(table): typescript/strong typing of cell templates

Offen
#22,290 13 Kommentare 109 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: cdk/table feature P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### Feature Description

Currently, `*matCellDef` types the resulting variable as `any`:

Screenshot 2021-03-19 at 11 29 32

This issue is an attempt to bring https://github.com/angular/components/issues/16273 back in discussion, which has been closed as Ivy wasn't yet available.

There has been some progress on several fronts:

- Ivy now has `strictTemplates` mode.
- The experimental Ivy powered language server is almost ready to go.

It appears that the approach described in this comment https://github.com/angular/angular/issues/28731#issuecomment-782806178 might allow this to be implemented.

#### Use Case

As we've been converting more code to use Material Data Tables, the lack of strong typing has been really problematic, and it feels like a downgrade in developer experience compared to regular tables with `*ngFor`.

Further motivation for this has been described in:

https://github.com/angular/components/issues/16273
https://github.com/angular/angular/issues/28731

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Prüfung des Angular-Kontexts für strictTemplates und der verknüpften Diskussionen in angular/components#16273 und angular/angular#28731, insbesondere des dort referenzierten Implementierungsansatzes. Ermittle die betroffenen Einstiegspunkte für die Typisierung von Cell-Templates der Material-Tabelle und wie der Language Service damit umgeht. Als abgeschlossen gilt die Aufgabe, wenn Variablen in Cell-Templates nützliche Typen zur Compile-Zeit statt any erhalten und die relevanten Template-Fälle abgedeckt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
developer-experience, frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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