Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij can't find tsconfig.json

I'm having an issue with Intellij not being able to find my tsconfig.json file. My folder structure is this:

/ui
  /src (all typescript files in here)
  tsconfig.json

In my tsconfig.json file I have:

{
  "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/**/*"
  ]
}

Intellij knows how to navigate from "src" to my src folder with command + B (go to declaration). If I close Intellij and reopen it and click "compile all" in Typescript it even compiles everything to Javascript. Then it reports the error Error: Cannot find parent 'tsconfig.json'. It still compiles to Typescript after that sometimes, but never when I click "compile all".

Is this an Intellij bug? It seems like one. I just upgraded to Intellij 2017.3, although I'm not sure if I was having this issue before.

Typescript version is 2.6.2, but I had the same issue when using 2.5.3.

like image 354
CorayThan Avatar asked Jan 30 '23 02:01

CorayThan


1 Answers

I just had the same problem. I worked around it by explicitly setting the path to the tsconfig.json in the Settings under Typescript (there is an Options input field):

-p ./tsconfig.json

Where ./ is the root directory in my project. It probably is different in your case, like probably

-p ./ui/tsconfig.json
like image 52
ghost23 Avatar answered Jan 31 '23 23:01

ghost23