Retain the type of mutiple Observable<T> using combineLatest() from rxjs under Angular?
First things first, you have to type your function and your HTTP call.
getMonkey(): Observable<Donkey> {
return this.http.get<Donkey>(url);
}
Once done, you have to type your array of observables :
const observables: [Monkey, Donkey] = [
this.getMonkey(),
this.getDonkey(),
];
Finally, although not necessary, you can type your callback params :
forkJoin(observables).subscribe(([monkey, donkey]: [Monkey, Donkey]) => {...});
This sounds like a use case for tuples. https://visualstudiomagazine.com/articles/2016/02/01/type-safe-structures.aspx?m=1
type animalTuple = [Donkey, Monkey];
.subscribe(([donkeyResult, monkeyResult]: animalTuple) => { ... }