Encountering an issue while working on a component, specifically during ng serve/build process. Please note that this error is different from any console errors, despite what some may think. The expected outcome is for the code to successfully build and run.
TS error TS2349: Cannot invoke an expression whose type lacks a call signature
The error occurs within the foreach function in ngOnInit()
import { Component, OnInit, Input } from '@angular/core';
import { ChartInput, MultiChartInput, ChartColorScheme } from "@shared/models/chart-input";
@Component({
selector: 'chart-legend',
templateUrl: './chart-legend.component.html',
styleUrls: ['./chart-legend.component.css']
})
export class ChartLegendComponent implements OnInit {
@Input()
public chartInput: ChartInput[] | MultiChartInput[];
@Input()
public legendColors: ChartColorScheme;
public legends: Map<string, string> = new Map<string, string>();
constructor() { }
ngOnInit() {
this.chartInput.forEach(
(item, index) => {
this.legends.set(item.name, this.legendColors.domain[index]);
});
}
}
export class ChartInput {
name: string;
value: number;
}
export class MultiChartInput {
name: string;
series: ChartInput[];
}
export class ChartColorScheme {
domain: string[];
}
Any assistance in resolving this issue is greatly appreciated. If anyone believes it may be related to this question, please clarify why you think so as I am uncertain.