2017-09-29 43 views
1

我已经设置了一个node.js项目,我想使用VS-Code + Typescript。 如果我使用平滑的Javascript intellisense工作正常,VS-Code甚至会从缓存(例如〜/.cache/typescript/2.5/node_modules/@types/rethinkdb/index.d.ts)加载Typescript定义。但在.ts文件中,这根本不起作用。VS代码智能感知适用于Javascript文件,但不适用于TypeScript文件

的.js文件(instellisense工作) .js file (instellisense working) 的.ts文件(智能感知不工作) .ts file (intellisense not working)

这两个文件都在同一个文件夹中。 我tsconfig.json样子:

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

我缺少一个配置选项还是什么?

+0

如果你的鼠标悬停在“rethinkdb”,它会给你一个文件路径吗?你尝试过“三重砍”吗? /// https://www.typescriptlang.org/docs/handbook/triple-刀耕火种directives.html –

回答

0

回答我的问题:

安迪的评论给我提示,因为没有.d.ts在rethinkdb的模块文件夹中。 所以我将.d.ts文件从缓存文件夹复制到模块文件夹。我还需要从DefinitelyTyped安装类型:

npm install --save-dev @types/node 

我不知道这是否是解决这个问题,或者为什么VS码不能自动解决的定义文件的推荐方式,但至少它现在为我工作。

相关问题