4 ms·
I've got (too many) years of JS experience too, and I started a project in TS last November to see what the fuss is all about. I have to say I'm a convert. Not
by sanitycheck 5y ago
I've got (too many) years of JS experience too, and I started a project in TS last November to see what the fuss is all about.
I have to say I'm a convert. Not so much because it's catching a ton of errors for me, more that it brings such a massive improvement in IDE autocomplete behaviour. TypeScript in VS Code starts to feel almost like C# in 'real' visual studio. (The errors it does catch in my code are usually potential null references which would probably have been fine, but I'm sure it's avoided a few bugs.)
The most interesting thing for me is that it allows me to feel safe doing things I would avoid in plain JS, like using literal union types (which would be magic numbers/strings without the typing).
I still write JS for small stuff, but when you're next starting a new project that'll go over a few thousand lines of code I definitely recommend giving it a try.
- claytongulick 5y agoHave you tried type annotations in jsdoc? Inline /* @type */ statements and jsdoc type declarations coupled with .d.ts files for complex types achieves the same thing for me without the extra compilation step.
- LAC-Tech 5y agoYeah that's what I do as well. I actually find TS uglier now. It ends up being full of really long lines like: const myFunction(a: Long<TypeName>, b: Another<LongType>): FooBar