Skip to content

TypeScript theme type not recognized despite having it set in .d.ts fileΒ #3354

@amcsi

Description

@amcsi

Current behavior:

I believe I've followed the docs in how to get theming to work with TypeScript, but it doesn't seem to work.
I've added both @emotion/react and @emotion/styled, defined what Theme should be in a types.d.ts file, and VsCode/Webstorm still do not recognize the return value of useTheme() or the theme in styled('div') $(props => props.theme...).... ;` as the theme I provided.

Image Image

To reproduce:

  1. Clone this example project I've created just for this ticket: https://github.com/amcsi/emotion-typescript-reproduction
  2. Run npm install
  3. Check the useTheme() and styled('div') uses in App.tsx and see that the type of the theme is not recognized to be the same as what I defined in types.d.ts

Expected behavior:

Theme should be recognized as {hey: string}

Video demo:

2025-11-11.17-45-06.mp4

Environment information:

  • react version: 19.2.0 (but this happens in React 18 as well)
  • @emotion/react version: 11.14.0
  • @emotion/styled version: 11.14.1 (but this happens with version 11.14.0 too)

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