You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow consumers to disable skipLibCheck by adding // @ts-ignore to imports for dependencies that might not ever be added? #14066
In our project we changed our tsconfig.jsonskipLibCheck from true (default) to false
The reason we did this was to get red underlines and type check errors in typos in our .d.ts files since we use those extensively for internal types, and especially complex type transformations. (The reason we name our internal files .d.ts instead of .ts is not to export them, but just to provide clarity to the broader team that there is no runtime code in those files.)
With skipLibCheck we couldn't get checks in those files.
Now that skipLibCheck is turned off, we have noticed a handful of libraries, including yours will block our app from type-checking/building.
Some of these we fixed by bumping our React version or @types/node version.
But for sentry (and a few others) we saw no fix because your types.d.ts file imports a dependency we don't use: webpack.
Error: node_modules/@sentry/nextjs/build/types/config/types.d.ts(3,58): error TS2307: Cannot find module 'webpack' or its corresponding type declarations.
So my proposal is to add // @ts-ignore to "optional dependency imports" if you want to support skipLibCheck: false consumers.
However if you don't want to support this use case I totally understand and you may close the issue. I can just continue using patch-package.
Hi @700software thanks for explaining! I have to admit this is the first time that we're hearing about this import from webpack being a problem. We'd like to help you out as much as possible but I'm afraid adding a ts-ignore to this import might in turn have type checking implications on our end which I'd like to avoid.
But for sentry (and a few others) we saw no fix because your types.d.ts file imports a dependency we don't use: webpack.
This confuses me a bit: If you're using NextJS I'm fairly sure that you will have webpack as a dependency. It's probably not listed in your package.json but its a transitive dependency of NextJS since it relies on webpack. At least to my knowledge. I'm curious to learn more here :)
To answer your question, Next.js doesn't use webpack anymore as I understand.
C:\GitHub\tmp>mkdir tmp-does-next-have-webpack
C:\GitHub\tmp>cd tmp-does-next-have-webpack
C:\GitHub\tmp\tmp-does-next-have-webpack>npm install next
added 30 packages in 8s
5 packages are looking for funding
run `npm fund` for details
C:\GitHub\tmp\tmp-does-next-have-webpack>npm ls next
tmp-does-next-have-webpack@ C:\GitHub\tmp\tmp-does-next-have-webpack
`-- [email protected]
C:\GitHub\tmp\tmp-does-next-have-webpack>npm ls webpack
tmp-does-next-have-webpack@ C:\GitHub\tmp\tmp-does-next-have-webpack
`-- (empty)
C:\GitHub\tmp\tmp-does-next-have-webpack>
Regarding the proposed solution: Totally understand implications on your end and why having // @ts-ignore might not work for you without further pre- or post-processing or some other solution.
Regarding the problem statement: It is probably rare for people to disable skipLibCheck. Totally understand why you haven't heard about it before.
Regarding our personal needs: We've solved the issue on our end with patch-package for now.
The root need,
The reason we name our internal files .d.ts instead of .ts is not to export them, but just to provide clarity to the broader team that there is no runtime code in those files.
and the disabling of skipLibCheck was known to have such a tradeoff somewhere. :)
Thanks for the detailed explanation! i can't promise we'll change something but before we close this issue, I will tag @lforst: We could think about vendoring in the imported types to get rid of the webpack type imports. If webpack isn't always available in NextJS this might become problematic in more ways. Another option would be to add it as a dep to our package but this seems a bit over the top... wdyt?
Activity
s1gr1d commentedon Oct 24, 2024
Hello, thanks for raising this!
Can you elaborate the problem you had before adding
// @ts-ignore?700software commentedon Oct 24, 2024
In our project we changed our
tsconfig.jsonskipLibCheckfromtrue(default) tofalseThe reason we did this was to get red underlines and type check errors in typos in our
.d.tsfiles since we use those extensively for internal types, and especially complex type transformations. (The reason we name our internal files.d.tsinstead of.tsis not to export them, but just to provide clarity to the broader team that there is no runtime code in those files.)With
skipLibCheckwe couldn't get checks in those files.Now that
skipLibCheckis turned off, we have noticed a handful of libraries, including yours will block our app from type-checking/building.Some of these we fixed by bumping our React version or
@types/nodeversion.But for sentry (and a few others) we saw no fix because your

types.d.tsfile imports a dependency we don't use:webpack.So my proposal is to add
// @ts-ignoreto "optional dependency imports" if you want to supportskipLibCheck: falseconsumers.However if you don't want to support this use case I totally understand and you may close the issue. I can just continue using
patch-package.Lms24 commentedon Oct 28, 2024
Hi @700software thanks for explaining! I have to admit this is the first time that we're hearing about this import from
webpackbeing a problem. We'd like to help you out as much as possible but I'm afraid adding ats-ignoreto this import might in turn have type checking implications on our end which I'd like to avoid.This confuses me a bit: If you're using NextJS I'm fairly sure that you will have webpack as a dependency. It's probably not listed in your package.json but its a transitive dependency of NextJS since it relies on webpack. At least to my knowledge. I'm curious to learn more here :)
700software commentedon Oct 28, 2024
To answer your question, Next.js doesn't use webpack anymore as I understand.
Regarding the proposed solution: Totally understand implications on your end and why having
// @ts-ignoremight not work for you without further pre- or post-processing or some other solution.Regarding the problem statement: It is probably rare for people to disable
skipLibCheck. Totally understand why you haven't heard about it before.Regarding our personal needs: We've solved the issue on our end with
patch-packagefor now.The root need,
and the disabling of
skipLibCheckwas known to have such a tradeoff somewhere. :)Lms24 commentedon Oct 29, 2024
Thanks for the detailed explanation! i can't promise we'll change something but before we close this issue, I will tag @lforst: We could think about vendoring in the imported types to get rid of the webpack type imports. If
webpackisn't always available in NextJS this might become problematic in more ways. Another option would be to add it as a dep to our package but this seems a bit over the top... wdyt?lforst commentedon Oct 29, 2024
Oh yeah thanks for roping me in. Two things:
Opened a PR to fix #14116
fix(nextjs): Don't leak webpack types into exports (#14116)
github-actions commentedon Oct 31, 2024
A PR closing this issue has just been released 🚀
This issue was referenced by PR #14116, which was included in the 8.36.0 release.