typescript 如何解决WebStorm中“对应文件未包含在tsconfig.json中”的错误?

kxxlusnw  于 2023-06-24  发布在  TypeScript
关注(0)|答案(2)|浏览(659)

我正在使用highland.js,并安装了它的类型定义:

  1. jq .dependencies package.json | grep highland
  2. "@types/highland": "https://registry.npmjs.org/@types/highland/-/highland-1.14.30.tgz",
  3. "highland": "^2.9.0",

我正在使用PhpStorm(它使用WebStorm组件的TypeScript)。
当我输入提示:

  1. Highland.Stream<any>

PhpStorm抱怨Stream:

  1. Corresponding file not included in tsconfig.json

然而,go to声明工作,它跳转到node_modules/@types/highland/index.d.ts:367

  1. interface Stream<R> extends NodeJS.EventEmitter { ... }

我可以用tsc很好地编译代码,没有错误,并且它按预期工作。PhpStorm/ WebStorm的问题是什么?

  1. $ jq . tsconfig.json
  2. {
  3. "compilerOptions": {
  4. "module": "commonjs",
  5. "lib": [
  6. "es2016",
  7. "dom"
  8. ],
  9. "target": "es6",
  10. "noImplicitAny": true,
  11. "sourceMap": true,
  12. "outDir": "dist",
  13. "strictNullChecks": true,
  14. "skipLibCheck": true,
  15. "types": [
  16. "node",
  17. "mocha",
  18. "chai",
  19. "sinon"
  20. ]
  21. },
  22. "exclude": [
  23. "node_modules",
  24. "src/typings-custom/main.d.ts"
  25. ]
  26. }

我试着将highland添加到types中,但没有成功,我不知道错误告诉我什么。

6g8kf2rb

6g8kf2rb1#

我在Webstorm 2018上遇到了同样的问题。我关闭并重新打开Webstorm,瞧:红线不见了!我只是需要更新Webstorm我猜。由于Webstorm和PHPStorm都在同一个保护伞下,也许这对你也有用。

yebdmbv4

yebdmbv42#

只要去File > Repair IDE和工作以及。

相关问题