admin管理员组

文章数量:1394743

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?

Share Improve this question asked Oct 22, 2019 at 14:03 BaterkaBaterka 3,7546 gold badges38 silver badges67 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

Yes 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.

本文标签: Can I develop Nodejs (Express) app in both JavaScript and TypeScript togetherStack Overflow