HACKER Q&A
📣 WolfOliver

Why is it so bad to use any in TypeScript?


I actually think Typescript is valuable asset when it comes to finding issues in my code early.

But often I find myself spending a considerable amount of time trying to make the compiler happy in situations where I think it is not that important. Mostly this is the case in which dynamically typed languages shine.


  👤 tapeloop Accepted Answer ✓
you're basically giving away the biggest benefit you get - typing

👤 qwertyuiop12
Because it’s the main benefit of using typescript.

For a playground can be excessive, but for production is a nightmare.

Otherwise, you can use only JS with JSDoc and enable the @ts-check.


👤 Zekio
at my work place we've switched to plain JS with jsdoc comments and a couple d.ts files for reused types so far it seems easier to move faster

typescript is still added to the projects but only for type checking with "allowJs" and "checkJs" configured to true


👤 RayFrankenstein
Ideally you should use types, but if you have to use any because of some complicated situation where the compiler’s bitching, it’s no big deal. Anyone who tells you otherwise is a shamey OCD a-hole.