I am using WebStorm IDE for my TypeScript project with ESLint and Prettier enabled. I am getting warning:
for this code:
import { ToastAndroid } from 'react-native';
import { TProjectsList, IProject } from '../types';
export const reduceRecursively = (data: IProject[]): TProjectsList => {
return data.reduce((acc: TProjectsList, val: IProject) => {
acc[val.id] = val;
for (let key in val) {
if (val.hasOwnProperty(key) && Array.isArray(val[key])) {
val[key] = reduceRecursively(val[key]);
}
}
return acc;
}, {});
};
There are deffinitely both TProjectsList, IProject
used here, so why I am getting this warning? Possible bug?
It was caused by my mistake.
My file was still *.js what causing some weird behaviour for ESLint!
Makre sure your file is *.ts / *.tsx!