-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
@types/[email protected] + jsxImportSource: @emotion/react = Its return type 'ReactNode' is not a valid JSX element.
#3049
Comments
Opened a PR with a potential fix here: cc @Andarist happy to do any further changes to this as well, let's discuss in the PR if necessary |
As a temporary workaround until #3048 is merged, I think adding this type definition will work fine. import { JSX } from '@emotion/react/jsx-runtime';
declare module '@emotion/react/jsx-runtime' {
namespace JSX {
type ElementType = React.JSX.ElementType;
}
} |
It took me some time to find this issue. I think this is what's causing TypeScript errors in Next.js + Emotion projects created with my tool at create-next-stack.com. When setting
in I get
import type { AppProps } from "next/app";
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
} Dependencies:
Thank you guys for looking into this! |
@naari3 I use this workaround, but I got another error
|
@rick-chou Normally if you have |
thanks! I updated all the dependencies and used this workaround, and solved the problem. |
Works like a charm! 🎉 |
yarn upgrade "@emotion/react" "@emotion/server" "@emotion/styled" --latest This is to pull in the bugfix for this issue: emotion-js/emotion#3049
Current behavior:
Over the last months, there have been significant changes to the TypeScript
@types/react
package by @eps1lon in order to accommodate the different return types of components (one of the reasons being to avoid the problems with async React components)Using
"jsxImportSource": "@emotion/react"
along with the new@types/[email protected]
package causes failures that look like this:CodeSandbox: https://codesandbox.io/p/sandbox/emotion-issue-template-forked-vsng2b?file=%2Fsrc%2FApp.tsx
To reproduce:
dependencies
anddevDependencies
Expected behavior:
"jsxImportSource": "@emotion/react"
and the@types/[email protected]
package are compatibleEnvironment information:
react
version: 18.2.0@emotion/react
version: 11.11.0The text was updated successfully, but these errors were encountered: