I am pulling my hair out here, literally. VSCode 1.6.0 on Mac, Typescript 2.0.2, but I have also tried 2.0.0.
I\'ve tried targeting es5, es6, with or without commonj
After lots of trial and error, I finally got Node, Typescript, VSCode (and Visual Studio for that matter), and IntelliSense working correctly. This also appears to work with WebStorm.
Create a new Typescript project from the command prompt:
mkdir newproject
(or any directory name you want)cd newproject
npm init -f
(this will create a package.json)npm install @types/node --save-dev
(this will create a nodes_module folder and a package-lock.json file)tsconfig.json
file. It could be as simple as {"files" : ["main.ts"] }
main.ts
file to get startedNow launch VS Code point it to open the folder created in the steps above.
Most important. Use the import
keyword when declaring module use. Otherwise, IntelliSense flat out won't work. It took me quite a while a lot of head banging to realize this was the missing step.
Instead of this:
var http = require("http");
Type this:
import http = require("http");
And magically, you've got a barebones Typescript + Node project with IntelliSense working.