Intellij找不到tsconfig.json

Cor*_*han 3 intellij-idea typescript tsconfig

我遇到Intellij无法找到我的tsconfig.json文件的问题.我的文件夹结构是这样的:

/ui
  /src (all typescript files in here)
  tsconfig.json
Run Code Online (Sandbox Code Playgroud)

在我的tsconfig.json档案中,我有:

{
  "compilerOptions": {
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es7", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": false,
    "suppressImplicitAnyIndexErrors": true,
    "experimentalDecorators": true,
    "types": [
      "node",
      "webpack-env"
    ]
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest"
  ],
  "include": [
    "src/**/*"
  ]
}
Run Code Online (Sandbox Code Playgroud)

Intellij知道如何使用命令+ B(转到声明)从"src"导航到我的src文件夹.如果我关闭Intellij并重新打开它并点击Typescript中的"全部编译"它甚至可以编译所有内容到Javascript.然后它报告错误Error: Cannot find parent 'tsconfig.json'.有时,它仍然会编译成Typescript,但从来没有点击"全部编译".

这是一个Intellij错误吗?看起来像是一个.我刚刚升级到Intellij 2017.3,虽然我不确定我以前是否遇到过这个问题.

打字稿版本是2.6.2,但在使用2.5.3时我遇到了同样的问题.

gho*_*t23 7

我刚遇到同样的问题.我通过在Typescript下的Settings中显式设置tsconfig.json的路径来解决它(有一个Options输入字段):

-p ./tsconfig.json
Run Code Online (Sandbox Code Playgroud)

其中./是我项目中的根目录.在你的情况下可能会有所不同,就像可能一样

-p ./ui/tsconfig.json
Run Code Online (Sandbox Code Playgroud)