4 ms·
I started 2 months ago a big project using TypeScript on NodeJS ( I'm freelancer and I'm building an API Service for a company ). CONS: 1. Contribute a couple
by drinchev 11y ago
I started 2 months ago a big project using TypeScript on NodeJS ( I'm freelancer and I'm building an API Service for a company ).
CONS:
1. Contribute a couple of times to DefinitelyType repo, because I needed definitions that doesn't exist or modify existing ones with their updated versions ( this is really pain in the ass at this point, because you will most certainly end up using definitions that either doesn't match your version number or are poorly written ).
2. Report a couple of bugs to WebStorm 10 team ( I'm eagerly waiting for WS 11, which they say will improve the typescript support ).
3. Explain to my clients why I am using a beta version of a software for their precious product ( this is not a problem since today :) )
4. Sometimes the flexibility of typescript can slow you down a lot if you want to go deep with the proper typings and interface declarations. I actually spend a lot of time thinking how to organize my classes and interfaces now, instead of writing code.
PROS:
1. Code looks solid and professional ( CoffeeScript on the other - I was so much faster, but in the end I see not that easy readable code. )
2. Creating documentation is way easier ( using typedoc ). I never understood JSDocs as a pro and usually I spend lots of time on properly annotating, which is unneeded in TS.
3. There is no need to write `function(options) { if ( !options ) { throw new Error("Options required"); } }`. this becomes `function(options : Object) {}`. This removes a lot of boilerplate and really cleans many of those typesafety checks from your code.
4. I'm catching far more errors in the compilation phase than ever before ( see 3 ). I'm also not writing any typesafety tests for my modules ( I was so happy, when I realised that! ).
- pvnick 11y agoAgreed on the points listed. Typescript really helps with code being more solid and professional. We have a large-ish server application written in typescript the really benefits from the OOP principles that typescript enforces. Some initial investment upfront from learning curve and thinking about proper architecture like you mentioned, but really pays dividends over time for adding features or making major changes.
- AdamTReineke 11y agoOne thing to note about your third pro (removing boilerplate type safety) is that if other code outside your TypeScript ecosystem starts calling your code, the lack of checks could hurt them.