-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not ignoring node_modules after explicitly setting --skipLibCheck flag and exclude #47387
Comments
You're most likely including the source file in your project. This might be relevant to you: #30511 |
|
cool! many thanks for the support. will take a look and close the issue for now |
Hi, @CxGarcia have you resolved this issue?? I'm getting the same issue and I haven't reached any solution yet. |
hey @beinghaziq. yeah I decided to change libs and am now using |
Thank you very much 🙏 |
Why not tho? I have a project using I would very much like to use Is there nothing I can do but to accept using a configuration that's compliant with my dependencies, and therefore restricting my ability to use strict rules in TypeScript? That seems like a design flaw in my eyes. Do you have other reasons for imposing this limitation? :) |
@felskov The correct approach for the package owner would be to release JavaScript and declaration files, not TypeScript files. See this comment: #44205 (comment) (it also mentions/links to the concerns and limitations regarding your suggestion.) |
@MartinJohns Thanks for your feedback! :) I agree, that the perfect solution in that particular case would be publishing with compiled JS files - unfortunately we don't always control third party packages. We can ask the authors nicely to compile TS to JS before publishing, but in the end we have no control over whether or not that happens. That can leave us with the choice of abandoning that dependency and either finding a new one or writing whatever it does ourselves -- or making our TypeScript config less strict to enable checking the dependency without errors, but negatively impacting type checks on our on code. Another real-life example I've encountered with this, is within mono repos where you want to incrementally adapt stricter configurations of TypeScript. You setup each package with it's own tsconfig.json file, so configurations can be changed on a per-package basis. Everything works great, until the packages start depending on each other. You now risk having a scenario, where team A want to upgrade the tsconfig.json of package A with new stricter options. Unfortunately package A depends on package B, which is not yet compliant with these options. This leaves team A with the only option of requesting team B to adjust package B accordingly, and wait for them to finish doing so. Sometimes these dependencies cascade in very big repos, making it hard to update tsconfig.json without doing a full upgrade across the entire repo. I understand from the comment you linked that the main concern is emitted files. In our case (and I think this reflects the reality in many new projects), TypeScript is not used as a compiler, only a type checker (ie. we always use --noEmit, and actual output is created by esbuild or similar). To work around the issue on our end, I've created a tiny wrapper script to mimic running The script is available here: If we suppose that {
"scripts": {
"type-check": "./type-check.mjs"
}
} And then run the type-check script from anywhere within your project folder: npm run type-check Do you have any thoughts about using such a script or any feedback to the implementation? |
I was facing the issue with node_modules not being excluded after upgrading node to 18.4.0 LTS |
I'm having similar issues, where I have stricter options set in my tsconfig.json (
However, because it also bundles its |
👏👏👏👏 @felskov you ve told everything. Even trying to fix this with ts project references is a nightmare and not sure if the best solution. There is another case besides yours. When app1 and app2 depend on lib1 in a monorepo, you re going to have issues if app1 is strict and app2 is not. Both of them will check lib1 with their tsconfigs and this will fail. Lib1 have to satisfy both configs. What a nightmare work with typescript :/. |
TS version: 4.5.2
expected behavior: to ignore node_modules
actual behavior: doesn't ignore node modules
command:
$ tsc --skipLibCheck && vite build
log:
img log:
tsconfig:
The text was updated successfully, but these errors were encountered: