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 commonjs module targeting. I can't get intellisense for other files local to my project nor anything in the node_modules folder. I even installed typescript files from node_modules into my typings folder and those don't work.
The only intellisense I get is for my globally installed typings.
{
"compilerOptions": {
"target": "es6",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node"
},
"exclude": [
"node_modules"
]
}
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 newprojectnpm 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With