question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: allow exclusion of node_modules when skipLibCheck is false

See original GitHub issue

Search 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 strictly, 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:open
  • Created 5 years ago
  • Reactions:53
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

28reactions
RyanCavanaughcommented, Apr 19, 2022

I’d propose a new setting

`“skipLibCheck”: “external”

which says that any .d.ts file in your files or include 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?

6reactions
RyanCavanaughcommented, Mar 26, 2019

It sounds like you’re asking for the opposite - a mode for skipLibCheck that says only skip checking of .d.ts files from node_modules?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript skipLibCheck still checking node_modules libs
skipLibCheck is not meant to prevent all type checking in node_modules. Although it may work for some projects, but it's just a coincidence....
Read more >
TSConfig Reference - Docs on every TSConfig option
Important: exclude only changes which files are included as a result of the include setting. A file specified by exclude can still become...
Read more >
grunt-ts - npm
Grunt-ts is an npm package that handles TypeScript compilation work in GruntJS build scripts. This project, much like Grunt itself, is now in...
Read more >
vue_hissikutsu/node_modules/fork-ts-checker-webpack ...
with npm npm install --save-dev fork-ts-checker-webpack-plugin # with yarn ... skipLibCheck: true, sourceMap: false, inlineSourceMap: false, ...
Read more >
TSConfig Reference - TypeScript
Allowed Values: CommonJS (default if target is ES3 or ES5 ), ES6 / ES2015 ... TypeScript also includes APIs for newer JS features...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found