Typescript Compiler doesn't exclude "node_modules" folder
Hi,
I'm working on an Angular 2 app with phpStorm, but what is really frustrating is that the TS compiler always keeps looking for errors in the "node_modules" folder as well and throws errors of course.
I have a tsconfig.json file where "node_modules" is being excluded, this is also set in the settings with phpStorm
So I don't get it why the TS compiler still keeps giving me these errors of stuff in my "node_modules" folder, I only want to see errors from my project, how can this be done?
Please sign in to leave a comment.
Hello,
What is your tsconfig.json?
Exclude patterns work fine for me. How many tsconfig.json files do you have in your project? Where are they located? Also, exclusion filters are not applied to files referenced (directly or indirectly) from included files. See https://github.com/Microsoft/TypeScript/issues/5509, https://youtrack.jetbrains.com/issue/WEB-19547#comment=27-1260307.
Hi Vlad,
I only have one tsconfig.json file, it located in my root directory of my project. It's pretty straight forward I think.
In my case, I do have imports to certain files of course, and I can understand that the TS compiler needs to read them, but it would be nice if the errors could be suppressed in some kind of way or made silent. Now I have to scroll all the way down to see the errors I have made in my code, because the TS compiler will first show the errors of the node_modules files.
I understand why.. because the compiler imports those files first and then of course show the errors in the following order.
But bottomline.. this isn't really productive to work this way.
Please feel free to file a request for filtering the compiler errors. Related ticket: https://youtrack.jetbrains.com/issue/WEB-19064
Hi Elena,
That issue doesn't really relate to my problem. I don't have multiple tsconfig files, I just want to be able to filter certain messages that aren't in the scope of my project files. Being folders / files located in the "node_modules" folder.
i didn't say it's your issue (and asked you to create a feature request), but it's definitely related, as this is a request to filter TSC output to show messages related to current file only
I have the same problem!
IntelliJ IDEA 2017.1.2
Build #IU-171.4249.39, built on April 25, 2017
JRE: 1.8.0_112-release-736-b16 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.4
This seems to be an ongoing issue: https://youtrack.jetbrains.com/issue/WEB-24206.
Feel free to participate (vote/comment).
@Stevo, Idea seems to behave correctly: if the module is referenced from the source file, it's processed despite being excluded in tsconfig.json. And, as your files definitely do import @angular/core, the errors are shown. You will see the same errors when running tsc in terminal.
To make things clear:
exclude
is about the compiler automatically loading all files from your folder when you runtsc
with no file list. This does not impact howimport
statements are resolved. if the compiler seesimport * from "mod"
,it will try to find
mod
innode_modules
and if it found it it will process it.See http://www.typescriptlang.org/docs/handbook/tsconfig-json.html:
"Any files that are referenced by files included via the
"files"
or"include"
properties are also included. Similarly, if a fileB.ts
is referenced by another fileA.ts
, thenB.ts
cannot be excluded unless the referencing fileA.ts
is also specified in the"exclude"
list."Is there an update on this? As Maartin said, this is a really unproductive way to work.
Update on what, sorry? As I explained in https://intellij-support.jetbrains.com/hc/en-us/community/posts/206634839/comments/115000231764, the current behavior is expected and conforms to typescript compiler rules
@Elena - So if I'm using a 3rd party library that does NOT enforce compilerOptions such as noImplicitAny or noUnusedParameters, there is no way for me to enforce those options ONLY within my own project? From what I currently understand these used to be linting options but now require type checking, and the proper way to enforce them is with compilerOptions. The problem as you can see is that I can enforce linting options only for my code, but I cannot enforce them only for my own code using compilerOptions.
@Jensbodal Please comment at https://youtrack.jetbrains.com/issue/WEB-24206 - that would be the best way to reach the developers and discuss this matter with them
Any updates? I can't filter node_modules compiler errors. I want to see only project-specific errors, not the node_modules. Because they are 3-rd party libs.
Please vote for https://youtrack.jetbrains.com/issue/WEB-44233 to be notified on any progress with it