I'm having trouble displaying JSON data in my Angular Material table and encountering an error that I don't quite understand.
Error: What does the type 'never' mean in this context?
ts.file
export class TableComponent implements OnInit {
ELEMENT_DATA: Itype[] = [];
displayedColumns: string[] = ['dechets.type', 'dechets.weight'];
dataSource = new MatTableDataSource<any>(this.ELEMENT_DATA);
constructor(private typeService: TypeService) { }
ngOnInit() {
this.getAllDetails();
}
public getAllDetails() {
let resp = this.typeService.getAllType();
resp.subscribe(resp => {
this.dataSource.data = resp.reduce((acc, item) => {
acc.push(...item.dechets); // issue is here
return acc;
}, []);
});
}
interface
export interface Itype {
type_collecte: string;
dechets:
{
type: string;
weight: number
}[];
code_traitement: string;
annee: number;
mois: number;
}