I am using TypeScript 1.5.0-beta and I am using Visual Studio Code to create a simple Node Server using an example that Anders Hejlsberg showed at build.
///<reference path="typings/node/node.d.ts"/>
import { createServer } from "http"
export function simpleServer(port: number, message: string)
{
createServer((req, res) =>
{
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(port, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
}
I have three issues
1) With this code, whenever I try to build the ts file either using Visual Studio Code or the command $ tsc server -m commonjs, it keeps giving weird errors like these
error TS1008: Unexpected token; 'module
, class, interface, enum, import or statement' expected
2) It also tries to build node.d.ts file that I am referencing and gives additional ":" expected error messages.
3) This is more of a Visual Studio Code question. How do we get VS Code to build all ts files in a project/folder and generate js files. I followed the instructions for the typescript setup for VS Code but I still have to individually build each ts file to gen the js code.
I know grunt is one way to do it but as far as I know VS Code should be able to build all ts files in a folder like Visual Studio does. Please correct me if I am wrong.
Thanks.