While upgrading from Angular 5.2.11 to 7.3.9, I encountered a types issue that was not present in the previous version of Angular.
After fixing the import for forkJoin, the code snippet below now throws an error:
ERROR in src/app/reports/report-measurements-options/report-measurements-options.component.ts(377,5): error TS2322: Type 'Observable<{}[]>' is not assignable to type 'Observable<Archive[][]>'.
Type '{}[]' is not assignable to type 'Archive[][]'.
Type '{}' is missing properties like length, pop, push, and more from type 'Archive[]'.
getArchives(): Observable<Archive[][]> {
if ((this.startDate) > (this.endDate)) {
let temp = this.startDate;
this.startDate = this.endDate;
this.endDate = temp;
}
let observableBatch: any[] = [];
this.selectedBins.forEach(bin => {
const definition = bin.definitions.find(d => d.type === this.selectedReadingType);
bin.selectedDefinition = definition;
bin.definitionUnits = definition.units;
observableBatch.push(this.archiveService.listArchives(definition.id, this.startDate, this.endDate)
.map((res: Archive[]) => res));
});
return forkJoin(observableBatch);
}
I anticipate that the method should return the correct type just as it did prior to the update.