I'm leaning towards using node.js in backend (api) development. I'm interested in it because I really like the javascript community and ecosystem.
Despite that, I kinda hate the mess that is javascript itself. It's too permissive and don't protect me from my mistakes. That makes me very scared when writing code.
I'm looking intoTypeScript to alleviate those symptoms. I REALLY like type annotations and compile time safety, so I'm hoping it will give me some peace of mind.
What do you guys think? Will it be enough?
Even further, can I write tests and have coverage reports in a nice workflow? Is any of you already doing this stuff? What's it like?
Sébastien Portebois
Software architect at Ubisoft
Only a good testing can save a developer from his own stupidity really. no amount of languages will save that.
That being said, Typescript will definitely catch your "stupid" mistakes...
We all made em:
function add(expectingInt){
expectringInt++
}
add("crap this is a string");
typescript will definitely ensure that you are typesafe, and honestly, with ES6, i see absolutely 0 reason NOT to use typescript. you are getting an extra level of safety with little to no negatives.
If you like to get another point of view, there's some feedback from the authors or Visual Studio Code, who wrote their editors in JS, then incrementally switched to Typescript
See https://vimeo.com/174657014 (at 9:19 for that part)
I agree with most of what you stated, and You have highlighted some major flaws in top to bottom JS environments. I have looked at Typescript, but I am not certain that using and implementing Typescript solved all of those problems. Have you looked at or considered Dart?
Hey!
First, no false promise: even with better type systems (like Scale) the real safety comes with tests (unit, functional, integration, code reviews, etc.).
That said, I've used (and am using) Typescript for web services, as well as Scala, and, in a typescript-versus-javascript perspective, I would say that TS definitely helps. I mean: the type system is not strictly typed, but duck-typed, and will not save you from errors. But it does help a lot for refactor and documenting your code. Hence, it also helps a lot for code reviews, and it's easier for your peers to get into your code, because of what I'd call the "documentation by interfaces".
Please keep in mind that I was an early adopter of TS and therefore am very biased. But what was "the edge" at the beginning of Typescript 2 years ago is now standard ES6 (all that to say that if you look at the arguments of people against TS, many of them are now embracing ES6 and the syntax they were rejecting because of "not yet another new thing").
Bottom-line: Typescript is not strictly type, and will let you do errors. But when the Node stack is relevant (performance wise), from a safety perspective it's way better, especially if you're working in a team.
If you like, I could share my current dev toolbox to give you an idea.