-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type error: Could not find a declaration file for module 'next/dist/compiled/webpack/webpack' #21390
Comments
I'm seeing this too |
Same |
This should resolve the typing issues described in #21390 from the webpack inlining, by declaring `next/dist/compiled/webpack` in the main typing file as a source.
@guybedford, still doesn't work for me with or without webpack as (dev-)dep. $ yarn why next
=> Found "next@10.0.7-canary.0"
$ yarn why webpack
=> Found "webpack@4.46.0"
$ next build
../../node_modules/next/dist/build/webpack/plugins/build-manifest-plugin.d.ts:1:25
Type error: Could not find a declaration file for module 'next/dist/compiled/webpack/webpack'. '[...]/node_modules/next/dist/compiled/webpack/webpack.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/next` if it exists or add a new declaration (.d.ts) file containing `declare module 'next/dist/compiled/webpack/webpack';`
> 1 | import { webpack } from 'next/dist/compiled/webpack/webpack';
| ^
2 | import { Rewrite } from '../../../lib/load-custom-routes';
3 | export declare type ClientBuildManifest = Record<string, string[]>;
4 | export default class BuildManifestPlugin {
info - Creating an optimized production build .child_process.js:655
throw err;
^ |
Workaround, add this in your code somewhere: declare namespace webpack {
export type Compiler = any
export type Plugin = any
}
declare module "next/dist/compiled/webpack/webpack" {
export const webpack: any
} |
When I set Should I always set |
If the previous PR didn't capture the issue, perhaps someone here can share a full end to end replication for me as I wasn't able to replicate the issue with a basic app with a tsconfig.json as described. @elliottsj I also tried cloning your repo but wasn't able to see the issue there either. Alternatively, could someone here verify if the approach in guybedford@39e7ffd seems like it might work, in which case we could go ahead and merge that. |
git clone https://github.com/elliottsj/elliott.dev.git
cd elliott.dev/
git checkout next-10.0.7
# npm i -g pnpm
pnpm i
pnpm build Tried the approach in guybedford@39e7ffd, but the error persists. This is also raised: |
Thanks @elliottsj that was exactly the replication I needed, I've verified the fix in #21785 works against that case. |
This adds a simple typing definition to the Webpack ncc output. Fixes #21390.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
This adds a simple typing definition to the Webpack ncc output. Fixes vercel/next.js#21390.
What version of Next.js are you using?
10.0.6-canary.6
What version of Node.js are you using?
14.15.4
What browser are you using?
N/A
What operating system are you using?
Linux
How are you deploying your application?
Vercel
Describe the Bug
When upgrading from v10.0.6-canary.0 to v10.0.6-canary.6, this error is raised:
See https://github.com/elliottsj/elliott.dev/pull/442/checks?check_run_id=1733030038
I am using pnpm, as well as tsconfig options
"strict": true
and"skipLibCheck": false
.Expected Behavior
No error should occur.
To Reproduce
See:
The text was updated successfully, but these errors were encountered: