3 ms·
Ask HN: 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 3y agoyou're basically giving away the biggest benefit you get - typing
- WolfOliver 3y agoI'm not saying doing it all the time, at least not for public interfaces of a library
- qwertyuiop12 3y agoBecause 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 3y agoat 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 3y agoIdeally 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.