typescript - cannot find parent tsconfig.json

Hello,

I am using IntelliJ IDEA version 2108.1.3 with its bundled typescript compiler 2.8.1.

I have a basic Web Project with a tsconfig.json in the project root folder, that looks like this:

{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"inlineSourceMap": true,
"inlineSources": true,
"noImplicitAny": true,
"outDir": "out",
"removeComments": true,
"jsx": "react"
},
"include": [
"/src/**/*",
"/types/*"
]
}

My project structure looks like this:

/src -> various subfolders
/types
/out
tsconfig.json

In the types folder I store *.d.ts files.

Whenever I open a .ts or .tsx file from within the src folder, I get an icon in the typescript panel and when I open the typescript panel, It says:

C:\Users\<username>\Documents\<myproject>\src\views\myfile.tsx
Information:Cannot find parent 'tsconfig.json'

I cannot figure out, what's wrong. The project compiles just fine, when I do tsc -p .  from the command line in the project folder.

 

2
19 comments

can't recreate using the same config and project structure... Can you reproduce the issue in a new project? Also, do you have any symlinks/junctions in the project path?

0
Avatar
Permanently deleted user

Will try with a new project. No, I don't use symlinks.

1
Avatar
Permanently deleted user

I also have the same info message. I have just moved to webstorm from VS Code. I have no issues, but this warning now appears, so it must be an IDE related issue.

Also, typescript is now not finding basic Jest types, maybe some mismatched typescript and ide config?

0

TypeScript compiler service uses the nearest tsconfig.*.json current file is included in for compiling your files. The message 

Cannot find parent 'tsconfig.json'

indicates that no tsconfig.*.json files current file is included in are found.

How many tsconfig.*.json files do you have in your project, what do they look like? Is the error reported for all .ts files, or for some certain ones only?

0

Same here. WS version 2018.2.1. Cannot find this tsconfig.

0

Try adding `tsconfig.webpack.json` to the list of Typescript Config file type patterns in Settings | Editor | File Types

 

1
Avatar
Permanently deleted user

I was previously seeing this message, however it is not appearing anymore, and the Jest types are being resolved. Here is my working tsconfig file.

Not sure if this will help, I cant say exactly what caused the message to stop showing up, we made a number of changes to the tsconfig file.

{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"noImplicitAny": true,
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"rootDir": ".",
"paths": {
"*": ["node_modules/*", "src/types/*"]
},
"lib": ["es2016", "dom", "esnext.asynciterable", "es2017.object"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts", "dist"]
}
0
Avatar
Permanently deleted user

I was having the same problem here. I have a monorepo project where the "Cannot find parent 'tsconfig.json' " message was showing up.

I've managed to mitigate this error by setting '--project "<path totsconfig.json>" ' in the options field at "Languages & frameworks > Typescript". It shouldn't be necessary to set it this way thought. 

2

Same problem with the newest Idea 2018.3 - I had to add `--project typescript/tsconfig.json` in the options for a monorepo, where the typerscript code is in /typescript/

1

can you share a sample project that can be used to recreate the issue?

0

Create a project where `tsconfig.json` is inside a folder /foo

Create a file /foo/bar.ts with content `const a = async function(){};`

Typescript compiler will complain about Promise lib missing, even if  you have listed `es2015` in libs. 

0

here you are:

as you can ssee, no problems are reported, and no warnings about not found config are there

0

I honestly dont know - I removed the --project typescript/tsconfig.json and now it works even without it, but yesterday it didnt.

Maybe just add an option to see which is the effective typescript/tsconfig.json and allow the user to select an alternative one - this should do it! 

0

Please vote for https://youtrack.jetbrains.com/issue/WEB-18963;

 

Normally it's a config nearest to current file: WebStorm follows the compiler logic here - it uses the nearest tsconfig.json current file is included in for compiling, traversing the folders hierarchy from current folder up to the IDE project root. 

0

I had the same problem, the problems started when I renamed both the folder and project name. I trashed the .idea folder, restarted the ide and it fixed the issue.

0
Avatar
Permanently deleted user

I too am having this issue.

i have a monorepo with yarn workspaces.  so there are a handful of tsconfig files.

in one space:

tsconfig.json

/modules/account/account.entity.ts

^ the account.entity.ts was complaining that is could not fine the tsconfig.json

 

when I moved it up a level to /modules/tsconfig.json

it worked  BUT -- i rather not have that there

 

 

 

0

Please see above - the IDE uses the nearest tsconfig.json current file is included in (check "include": [], "files": [], etc.), traversing the folders hierarchy from current folder up to the IDE project root. Sibling folders are not processed

0
Avatar
Permanently deleted user

That did it -- there was something funky in my "include": []  

 

Thanks!!!

0
Avatar
Permanently deleted user

I had the same issue, fixed with using the `--project` option.

0

Please sign in to leave a comment.