Feature Request: allow exclusion of node_modules when skipLibCheck is false
See original GitHub issueSearch Terms
skipLibCheck node_modules
, skipLibCheck
All I’ve found is this lonely SO post. As that user notes, there are a lot of posts around Angular and excluding node_modules from typechecking on one dimension or another, but they all end up suggesting turning on skipLibCheck
.
Suggestion
Allow the exclusion of files in node_modules (regardless of their inclusion in the Project) from lib checking when skipLibCheck
is set to false
.
Use Cases
I want to be able to typecheck my own .d.ts
files without being responsible for all of the types my dependencies import. My local configuration is strict
and it may be that the types provided in my packages were not intended strict
ly, or other configurations in my local JSON run up against the way other packages have written theirs.
I am assuming the counterargument is that it’s all-or-nothing, but then why do .ts
files that rely on .d.ts
files typecheck fine when my .d.ts
files are not typechecked? Can’t that behavior be applied to definitions in node_modules?
Examples
Not sure how to show an example here. I would like to be able to run tsc --noEmit
on my codebase and get errors for my own definitions files without having a bunch of noise from unfixable errors in node_modules/@types
etc.
Checklist
My suggestion meets these guidelines:
- This wouldn’t be a breaking change in existing TypeScript/JavaScript code
If implemented as some additional flag? - This wouldn’t change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript’s Design Goals.
I think so?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:53
- Comments:10 (4 by maintainers)
Top GitHub Comments
I’d propose a new setting
which says that any
.d.ts
file in yourfiles
orinclude
pattern is checked, but any.d.ts
file that gets into your program via other means is not (e.g. node_modules imports, output .d.ts files from upstream project references)Thoughts?
It sounds like you’re asking for the opposite - a mode for
skipLibCheck
that says only skip checking of .d.ts files fromnode_modules
?