Disable type checking for node_modules entirely #40426
Description
Search Terms
skipLibCheck
node_modules
ignore library
exclude
Suggestion
Either a new option or the existing option skipLibCheck
should be able to disable type checking for node_modules.
Use Cases
A library author might have a faulty import or might only provide typescript files for his library and not transpiled code. As a user of this library I want to be able to disable type checking for a library (or all) because I trust this library has been tested enough in other ways.
Another issue where I found a library shipping ts files and causing errors for the user: #15363
The response at the end is very relevant
I understand that libraries shouldn't publish
*.ts
files, but sometimes, they just do, and we can't control every other library easily.
I think typescript should not try to apply this kind of setting (herenoImplicitAny
) to thenode_modules
simply because it is meant to be applied to the user code being compiled, not the external dependencies.
Originally posted by @victornoel in #15363 (comment)
Examples
I had the case that a library came with a dist/
folder and almost all types were perfectly arranged in .d.ts files. But one file was making an import from ../index.d.ts
(which seems to be for development purposes, the lib main file is dist/index.d.ts
) which in turn then imported src/ClassA.ts
The library author used a different tsconfig and didn't use strict type checking, but I do and that's why the type check fails for me, because now the typescript source files of the library author are type checked.
Checklist
My suggestion meets these guidelines (in case of a new option):
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- 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.
Activity