Firpo Firpo - 3 years ago 290
TypeScript Question

VS Code Intellisense works for Javascript files but not for TypeScript files

I have set up a node.js project where I want to use VS-Code+Typescript.
If I use plain Javascript intellisense is working fine an VS-Code even loads Typescript defintions from the cache (e.g. ~/.cache/typescript/2.5/node_modules/@types/rethinkdb/index.d.ts). But in .ts files this doesn't work at all.

.js file (instellisense working)
.js file (instellisense working)
.ts file (intellisense not working)
.ts file (intellisense not working)

Both files are in the same folder.
My tsconfig.json looks like:

{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"watch": true
}
}


Am I missing a configuration option or something?

Answer Source

Answering my own question:

Andy's comment gave me a hint, because there was no .d.ts file in the module folder of rethinkdb. So I copied the .d.ts file from the cache folder to the module folder. I also needed to install the types from DefinitelyTyped:

npm install --save-dev @types/node

I don't know if this is the recommended way to fix this issue or why VS-Code doesn't resolve the definition files automatically, but at least it works for me now.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download