Write TypeScript and emit a library for Browser and Node

Which module syntax should I use in my code to best work with Node and Browser?

If you are targetting es5 then both syntaxes compile down to effectively the same thing. Use either, and feel free to mix and match.

Which tool-chain will solve my requirements? Is there an example project or a boilerplate where I can copy from

I use (and recommend) webpack. You get to use commonjs / nodejs as it is and then webpack can create bundles for front end. For a sample see https://github.com/basarat/tsb/tree/master

Which TypeScript and Node versions are currently supported? I'm having 1.4 embedded in IntelliJ, when referencing 1.6.2 as external I'm getting very deep cryptic error messages like "TypeError: host.fileExists is not a function" (not finding anything helpful about this). Maybe it's not optimal to use Node v4.1.1?

Use the latest TypeScript (various tools from TypeStrong e.g. atom-typescript/grunt-ts/ts-loader support that). The error you are getting is a webstorm error and should be reported to them. (I use atom-typescript).


I also have the TypeError: host.fileExists error with WebStorm 10 and a custom Typescript compiler (installed via npm).

However, this is fixed in WebStorm 11 (released Nov 2, 2015) https://www.jetbrains.com/webstorm/download/