next.js: Type '{}' is not assignable to type 'ReactNode'.
Verify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
“next”: “12.1.4”,
“react”: “^17.0.2”,
“react-dom”: “^17.0.2”,
file tsconfig.json
{
"compilerOptions": {
"target": "es6",
"esModuleInterop": true,
"importHelpers": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"lib": [
"dom",
"dom.iterable",
"esnext",
"es5",
"es6"
],
"baseUrl": ".", // setting a value for baseUrl is required
"paths": {
"@/*": [
"*"
],
"~/*": [
"*"
]
},
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"declaration": true,
"downlevelIteration": true,
"noUnusedParameters": false,
"noUnusedLocals": false,
"incremental": true
},
"exclude": [
"node_modules",
".next",
".vscode",
"out"
],
"include": [
"**/styles/**/*",
"**/*.ts",
"**/*.tsx",
"**/*.yml",
"**/*.yaml",
"**/*.css",
"**/*.scss",
"**/*",
".d.ts",
"next-env.d.ts",
]
}
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
The issue is that after upgrading to the last nextjs version, I am getting the error Type 'Component<{}, any, any>' is not assignable to type 'Element | ElementClass | null' for all components that are imported dynamically.
Workaround: Change dynamic import to normal import solves the issue
Expected Behavior
it should work.
To Reproduce
create a component and import it dynamically
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 19
- Comments: 29 (2 by maintainers)
I´m having the same issue. the app build doesn´t run correctly. Yesterday was running correctly. Today is broken
I have the same problem 😦 ecosystem project: react-ts All dependencies in the project aren’t auto-updating and are hardcoded (without ^) yesterday it works correctly too, today it is broken.
I’m having the same issue here. Our Next.js app is hosted on Vercel and no deploys are working anymore since 20h ago. No major changes made or anything like that, just a few cosmetic stuffs. I’m using NextJS v11.1.4, though. Looking forward to some news.
I also have a similar problem.
this is compile-error message.
I’m having the same issue here. =/ What is reason of this? Yesterday it works correctly too. Today it is broken. =/
We have same issue there on more our products running in nextjs … what is reason of this? We didnt do any updates in code, yesterday it works correctly, today it is broken.
Having the same issue here.
Error :
People, the same error occurs with my apps. I solve this by adding in next.config.js:
Almost similar but this also happens to me only in Vercel deployment - in my local it builds as expected.
By almost similar, I mean I am not even using dynamic import, and it worked fine just before this thread was opened.
My code
Hi guys. I found a temporary fixed for me that let me ship the build. All I had to do was upgrade @types/react to version 18.0.1 along with react and react-dom. Then I created a file at the root of the project named react-temporary.d.ts and pasted this inside:
Hope this temporary fix helps someone
This is getting bad, please please if anyone has suggestion on how to even bypass, would love to hear!
Worked perfect yesterday, but today recent redeploy was broken without any changes. Local builds are broken too, huge amount of weird TS errors
ref https://github.com/react-native-svg/react-native-svg/issues/1741#issuecomment-1093812197
I fixed it by updating
@types/react.package.jsonwith
yarn install.But it will cause other component type errors… You can put
// @ts-nocheckto file top or@ts-ignoreto error component above.I am still not sure how is this possible. I checkout the previous working branch - I ran
yarn run buildlocally works, but when I re-run the CI jobs which previously was succeeding now is failing. the only thing I can see as the difference is the docker file, I thought because I am not using a versionFROM node:lts-alpine, then I took the previous image hash (CI successful)FROM node:16.14.2-alpine@sha256:28bed508446db2ee028d08e76fb47b935defa26a84986ca050d2596ea67fd506 as build-stagebut it still gives the same error.Yeah if this is a breaking change (which it was), shouldn’t next have been bumped to 13.0.0?
thanks, this works for me in vercel deploying nextjs
What i did was getting back a old version of my
.lockfile and re-run all over again. Worked for me