Well quite simply, TS 5.5 seems to have removed the ability to ignore these errors.
https://github.com/microsoft/TypeScript/issues/51909 more specifically this option suppressImplicitAnyIndexErrors
I don’t like it, it’s too verbose, it adds complexity for nothing and is a net waste of time in my opinion. I’m thinking about staying on 5.4 because I utterly dislike this. Any suggestions? I don’t wanna refactor my code because the typescript gods decided to do so… ugh
Fix: Add an index signature to the relevant type (or use a type assertion at the indexing location).
suggestions from this post are appending as keyof type
which is most of the time redundant (coding 101) and doesn’t always work, I get this Type any is not assignable to type never
:
Object.keys(userTemp).forEach(key => {
user[key as keyof UserModel] = userTemp[key as keyof UserJson]
});
//UserModel is class containing various methods/properties
//UserJson is a run-time type checker I use to validate my API data
//This method is an easy way to hydrate my object
3