.. I have a React app that I inherited that having problems figuring out a TS2345 “Argument of type __ is not assignable to parameter of type” error. One property that is in question from a Model assignment could be a factor
export class MyAppTheme{
Themes?:MyAppTheme[];
}
I’m wondering if there is an issue with the Options operator ? on the MyAppTheme[] array
…but this block of code (in which I am providing the error info) comes up in various areas of the app, and I’m wondering if there is a typescript fundamental (I don’t hv much typescript experience) I’m missing, I’ve tried updating the npm packages the best of my knowledge >
Argument of type '(key: keyof MyAppTheme) => void' is not assignable to parameter of type '(value: string, index: number, array: string[]) => void'.
Types of parameters 'key' and 'value' are incompatible.
Type 'string' is not assignable to type 'keyof MyAppTheme '. TS2345
5 | let theme = JSON.parse(JSON.stringify(sourceTheme)) as MyAppTheme;
6 | if(theme.Level == 0) {
> 7 | Object.keys(theme).forEach((key: keyof MyAppTheme) => {
| ^
8 | if (key !== "Themes") {
9 | prodconfig[key] = theme[key];
10 | }