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?
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.
本文标签: Can I develop Nodejs (Express) app in both JavaScript and TypeScript togetherStack Overflow
版权声明:本文标题:Can I develop Node.js (Express) app in both JavaScript and TypeScript together? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744094718a2590073.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论