最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can I develop Node.js (Express) app in both JavaScript and TypeScript together? - Stack Overflow

programmeradmin6浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论