[MatDialog]: Infer return-type `R` of `MatDialogRef<T, R>` based on component passed into `MatDialog.open()`
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
### Feature Description
If I call:
```
MatDialog
.open(ADialogComponent)
.afterClosed()
.subscribe((result) => {
// result should have a type rather than `any`
});
```
It would be nice if `result` could be typed based on what `ADialogComponent` is known to return. Perhaps some work would need to be done for a component to be able to specify its return type. Maybe it would need to implement an interface `MatDialogComponent` or something. I don't know the solution...I just know the current way leaves a lot of room for error.
As things are currently, the caller must specify the return type when calling `MatDialog.open()` like this:
```
MatDialog
.open(ADialogComponent)
.afterClosed()
.subscribe((result: ReturnTypeHere) => {
// result is typed as ReturnTypeHere because it was specified when calling MatDialog.open()
});
```
The gives the caller the opportunity to incorrectly specify the return type...or to not specify one at all.
### Use Case
_No response_
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo i typings di MatDialog.open() e MatDialogRef descritti nell'issue, quindi traccia la relazione tra il componente passato a open() e il risultato di afterClosed(). Il lavoro è completato quando il tipo del risultato viene dedotto dal componente senza richiedere ai chiamanti di fornire un generico esplicito per il tipo restituito e il contratto del componente supportato è documentato o testato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100