Quantcast
Channel: Node.js Tools for Visual Studio
Viewing all articles
Browse latest Browse all 4630

Commented Feature: TypeScript Support [291]

$
0
0
Hey there, I tried so hard trying to use TypeScript, but using nodeJS project doesn't seem to support TypeScript VS builders.

I tried modifying the project file:

```
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptSourceMap> --module AMD</TypeScriptSourceMap>
</PropertyGroup>
<Target Name="BeforeBuild">
<Message Text="Compiling TypeScript files" />
<Message Text="Executing tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
```

I believe the ProjectExtensions is what conflicting:

```
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:2361/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
```

The code I am running is the following:

```
///<reference path='node.d.ts'/>

import http = module('http');

var port = process.env.port || 1337;

http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port, () => {
console.log("Listening on", port);
});
```

Please make integration with TypeScript possible before release, It becomes a hassle for me to compile stuff outside VS everytime. If I wanted to do that, then I could just use webmatrix or sublime.

Thanks :)
Comments: I've added zipped up projects and an updated .targets file which should help enable this. That'll let you invoke msbuild on the Node.js project and it'll go off and generate the JavaScript code by invoking the TypeScript compiler. I don't think this will work w/ current builds with an F5 experience due to some issues where we're not invoking build on F5. The sample project is just a simple console project but you can grow it into whatever you'd like. You'll also need to replace Microsoft.NodejsTools.Targets in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Node.js Tools with the attached one - that fixes some issues so that our targets file works with the TypeScript compiler's targets file. There's still a lot more to do before this is a satisfactory experience such as source map support for debugging and profiling and having an appropriate .dts file for Node.js. But this might let people who are interested start playing around with it.

Viewing all articles
Browse latest Browse all 4630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>