Skip to content

StyledComponent cannot be used as a JSX component - Typescript error #3377

Open

Description

@pciarach

Current behavior:

Every @emotion/styled component fails type-checking as a JSX element with TS2604/TS2786 ("does not have any construct or call signatures") when a project declares a global const React: typeof import('react').

To reproduce:

I'm not an expert when it comes to bundling and stuff but by using LLM I was able to come up with this repo: https://github.com/pciarach/react-import-repro. README contains a potential fix (which helped locally) but I have no idea whether it is the correct way to solve it.

Expected behavior:

These components are correct JSX elements so they should not be reported by Typescript as invalid.

Environment information:

  • @emotion/styled@11.14.1, @emotion/react@11.14.0
  • @types/react@18.3.28, react@18.3.1
  • typescript@6.0.2
  • tsconfig.compilerOptions: jsx: "react", strict: true, moduleResolution: "bundler", skipLibCheck: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions