Skip to content

Conversation

@Efklaz
Copy link

@Efklaz Efklaz commented Jan 26, 2025

The problem was that after the request (Replace deprecated global JSX namespace #4333), I couldn’t use styled-components in React 19. This happened because the .d.ts files were generated without using the React namespace in places where React.JSX was required. Instead, they were generated as plain JSX, which caused errors since, in React 19, this is no longer a global namespace but is scoped to React.

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2025

🦋 Changeset detected

Latest commit: 4921ae2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
styled-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@quantizor
Copy link
Contributor

Has anyone else tested this change and confirmed it is necessary?

Copy link

@gdbd gdbd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its ok

@binhpv
Copy link

binhpv commented Mar 3, 2025

I believe a simpler change is to upgrade the @types/react package to version 19. When doing this in some other projects, TypeScript infer the correct return type as React.JSX.Element.

@binhpv
Copy link

binhpv commented Mar 12, 2025

With this change I have another error:
../node_modules/.pnpm/styled-components@file+..+..+github+styled-components+packages+styled-components+package.tgz__loi6del3vqmxvl5u5pb7bprybe/node_modules/styled-components/dist/hoc/withTheme.d.ts:3:139 - error TS2694: Namespace 'globalThis' has no exported member 'JSX'.
The generated .d.ts file contains globalThis instead of React namespace and still causes error.

I tried to upgrade types/react to version 19 but then there are many issue with defaultProps that is also now removed from React 19, so I'm stuck at the moment :(

@fabb
Copy link
Contributor

fabb commented Apr 28, 2025

i have a alternative solution for react 19 compatibility: #5578

@quantizor
Copy link
Contributor

The alternate fix was merged, so I will close this one. Thank you.

@quantizor quantizor closed this Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants