I have Node.js project (Express REST API) written in JavaScript. We decided to rewrite whole project to TypeScript. Is possible to do it slowly, part by part, but still be able to start server? I want rewrite just some parts so project will be partly JS partly TS. Is it possible?
Does ts-node-dev
pile ts and ignore js?
I have Node.js project (Express REST API) written in JavaScript. We decided to rewrite whole project to TypeScript. Is possible to do it slowly, part by part, but still be able to start server? I want rewrite just some parts so project will be partly JS partly TS. Is it possible?
Does ts-node-dev
pile ts and ignore js?
2 Answers
Reset to default 10Yes this should be possible based on a main principle of TypeScript: TS is a superset of JS and all JS is also legal TS.
If you want to be particularly granular in how you are migrating your project, you should configure the TS piler to only pay attention to files in which you are implementing the change from JS to TS.
It's possible to do that, this kind of operation is called Migrating javascript to typescript, but if you tend to keep it half JS and half TS then it's logically wrong, because Typescript is transpiled : translated and piled into java script, in a machinery coded manner. so having java script code with ts is basically not a good practice.
You can allow js by the using the piler flag --allowJs
.
thus I think this post has more illustration.