In many Node/ React Typescript repos I have seen, the authors have opted to disable the popular linting rule that complains about using the any type.
I don’t think this is a good idea, why is that? Because Typescript is just syntactic sugar I think there is sometimes a temptation to try to “get round it” or “shut it up” because unlike c# for example, Javascript doesn’t really need it deep down. We should actually take the opposite attitude to this and work with Typescript with every opportunity that we get. Using any is not a good way to go about this because by using it we might as-well be going back to standard Javascript and start coding through those dynamically typed eyes again.
Because Typescript is a pretend layer on top that means there will always be quirks, maybe everything doesn’t work perfectly. As every day passes the library improves but if you do run into something that can’t be solved because of a quirk – rather than just admitting defeat and enabling any repo wide, use a suppression and consider it a rare exception. This employs the right amount of pragmatism I believe, because the alternative of disabling the rule altogether and just getting comfortable with any – a little too pragmatic in my opinion.
Check out my post on type mocking in tests to see how you can avoid having to use any and keep your type safety when stubbing complex types.