How to mix Node.js and Typescript in the same Visual Studio project?

南笙酒味 提交于 2019-12-04 04:23:52

Yes, it is possible, but in a somewhat awkward way (I hope Node.js Tools will support this better in the future).

You should create Node.js project and add a new file. Choose new text file and enter its name with .ts extension. It will create a typescript file.

At this point you will have a typescript files without compiled javascript.

To fix this go to VS "Tools" menu, open "Options" and go to "Text editor" > "TypeScript" > "Project" and under "Compile on Save" check "Automatically compile TypeScript files which are not part of a project and choose "Use commonjs...".

After that open each .ts file and save it - tsc will compile it to javascript.

Downside of this solution is that you have to remember to save manually each .ts you edit, but I think its not a big deal.

Here's a link to the post that helped me with the same problem: http://blog.ctaggart.com/2013/11/nodejs-tools-with-typescript-console-app.html

Update

If you grab the latest dev build of Node.js Tools you will see that TypeScript support is added. you can create TypeScript project (and this includes debugging .ts files feature)

https://nodejstools.codeplex.com/discussions/531222

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!