1

问题

在此处输入图像描述

  • 导入 NPM 模块时,VS Code 无法显示有关 NPM 模块的导入信息。[TS] Cannot find module 'lodash'/'react'/'etc'.
  • 导入用 TypeScript 编写的 NPM 模块(或其中包含typings属性的 NPM 模块package.json)时,我没有看到这个问题。
  • WebPack 仍然可以毫无问题地编译,这让我相信这是 VS Code 或 Typings 工具的问题。

设置

tsc我今天早上跑了1.8。我后来升级到tsc2.0.0。

VS 代码 1.4.0 6276dcb0ae497766056b4c09ea75be1d76a8b679

节点 5.10.0

tsc -v: === "版本 2.0.0"

tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "jsx": "react",
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true,
    "noUnusedLocals": true,
    "strictNullChecks": true
  },
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "buildOnSave": false
}

完整的项目源代码在这里。免责声明:这是一个相当大的代码库。

4

1 回答 1

1

我能够通过添加以下内容来解决问题/.vscode/settings.json

{
    "typescript.tsdk": "node_modules/typescript/lib",
}
于 2016-08-05T16:37:51.163 回答