Automatically compile TypeScript files on file save


Automatically compile TypeScript files on file save



I'm looking to move a vanilla node.js project to TypeScript and I'm curious about how to restart my server with the latest changes without needing to run tsc from the command line each time I make a change.



I see from this answer two options: ts-node and tsc --watch


ts-node


tsc --watch



Can someone provide a little color on the difference between these two options? I understand they accomplish the same goal, but how are they different and in which situation should I use one over the other?





See this comment on the answer: stackoverflow.com/questions/33535879/…
– Aankhen
Jul 2 at 10:21





@Aankhen that helps but it doesn't completely answer my question
– johnnyodonnell
Jul 2 at 13:21





Fair enough… my experience is mostly with ts-node, but I’ve been told on IRC that you should avoid it because it adds another, brittle layer that doesn’t buy you much. I’ve been using it anyway because so far the convenience of not needing to compile my files, and getting line numbers in stack traces that refer to the TS files, is valuable and I haven’t yet encountered any ts-node–specific issues.
– Aankhen
Jul 2 at 14:51





@Aankhen That was one of my concerns. I didn't want to add in another dependency if tsc already did the same thing. Though, getting line numbers in stack traces sounds like a pretty solid benefit over tsc. Hmm, I will have to think about this one. Thanks for your perspective!
– johnnyodonnell
Jul 2 at 17:13









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages