Anyways, I was working on a project which uses Objects - and a strange error appeared. I’ve encountered it before, but under these circumstances I wasn’t able to get around it.
Here I have a defined object:
const CUBE_VERTICIES = {
A: new Vertex(0, LENGTH, LENGTH), //A
B: new Vertex(LENGTH, LENGTH, LENGTH), //B
C: new Vertex(LENGTH, 0, LENGTH), //C
D: new Vertex(0, 0, LENGTH), //D
E: new Vertex(0, LENGTH, 0), //E
F: new Vertex(LENGTH, LENGTH, 0), //F
G: new Vertex(0, 0, 0), //G
H: new Vertex(LENGTH, 0, 0), //H
}
Within a method which takes in the ‘Object’ type as an argument (the ‘vertices’ variable), I have the following setup:
let vertex
let keys = Object.keys(vertices)
for (let i = 0; i < keys.length; i++) {
vertex = vertices[keys[i]]
}
After trying to compile, this line returns an error:
vertex = vertices[keys[i]]
Element implicitly has an 'any' type because type 'Object' has no index signature
Does anyone have any idea as to what is going on or a possible solution? This is pretty important, because I’ll have to swap out an object for something else if this error doesn’t get resolved, which will significantly slow my code.