I have this code. Basically, it is an object of grades of students.
let students: {
[k: number]: string[]
} = {};
students[1] = ["Student 1", "Student 2"];
students[2] = ["Student 3", "Student 4"];
console.log(students);
Object.keys(students).reduce((c, v) => {
c[v] = 111; //Im assigning some values here. THE ERROR IS POINTING HERE
return c;
}, {});
The error I’m getting:
Element implicitly has an ‘any’ type because expression of type
‘string’ can’t be used to index type ‘{}’. No index signature with a
parameter of type ‘string’ was found on type ‘{}’
.
Thanks in advance.