Description
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 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 codeThis could be implemented without emitting different JS based on the types of the expressionsThis 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?
Activity
[-]Allow exclusion of node_modules from skipLibCheck[/-][+]Feature Request: allow exclusion of node_modules from skipLibCheck[/+]RyanCavanaugh commentedon 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 fromnode_modules
?bensaufley commentedon Mar 26, 2019
You're right, that wasn't the right phrasing (I was thinking of
skipLibCheck: false
—excluded from enabled libCheck).[-]Feature Request: allow exclusion of node_modules from skipLibCheck[/-][+]Feature Request: allow exclusion of node_modules when skipLibCheck is false[/+]bensaufley commentedon Jul 5, 2019
FWIW I think this ongoing issue is my biggest use case for this flag: Styled-Components automatically includes React-Native types, which duplicate Node types, so if you use Styled-Components and Node, you must
skipLibCheck
because of a long-standing problem that you have no power to fixjasonkuhrt commentedon Sep 30, 2019
Another use-case for this feature comes from nexus.
Nexus has a novel "typegen" feature wherein based on user code a TS types file is generated and via interface-merging is able to imbue static guarantees on otherwise dynamic app code.
We are currently working on making the default disk location for this typegen be
node_modules/@types/whatever/index.d.ts
. This allows nexus to provide the typegen DX without any config demands upon the user.Now, the motivation, for us, for this TS issue, is that nexus typegen would become weaker in the face of
skipLibCheck
. Advanced users can configure typegen output, but their getting it wrong whileskipLibCheck: true
would make it silently fail. This TS feature would help maintain our users' confidence in nexus typegen even in situations where they need toskipLibCheck
for just one or two libs in their project.Hope that makes sense :)
zanona commentedon Nov 27, 2020
I completely agree with the author.
I am not sure if it would make sense or whether this has any negative effect, but the only way I could make sure my declaration files didn't have any errors, was to rename all
.d.ts
to.ts
, while keepingskipLibCheck=true
.I faced many situations where I did have errors on my
.d.ts
files to only figure it out once those were then checked bytsc
after being renamed.I might be missing something though.
cbdeveloper commentedon Jan 6, 2021
My use case for this is also related to the
styled-components
and@types/react-native
issue. I'm getting 40 errors.It does not harm my code, so I would like to ignore all those errors by setting
--skipLibChecks: true
, while still checking and getting errors for my own.d.ts
files inside mysrc
folder.Any updates on this?
45 remaining items