So the other day I was trying to pass in a value on an index of an array:

 this.currentUser.preferences[filtersIndex].value = JSON.stringify(queryParams);

I got this error:

error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'x'.
No index signature with a parameter of type 'number' was found on type 'x'.

Because TypeScript is strict in a sense that it would not allow to assign the integer value to the type x assigned to "preferences".


If you cast it as an array, you will be able to do so, and the error will disappear.

 (this.currentUser.preferences as Array<any>)[filtersIndex].value = JSON.stringify(queryParams);