Skip to content

Typescript support for theme when using css prop #1197

@mgrip

Description

@mgrip
  • emotion version: 10.0.6
  • react version: 16.8.0-alpha.1

Relevant code:

<span
  css={theme => ({
    fontWeight: theme.font.weight.light,
    position: "absolute",
    right: "8px",
    top: "52%"
  })}
>

What you did:
Created a theme using using the emotion-theming package

What happened:
No typescript support for the provided theme object.

Reproduction:

Problem description:

From the documentation, it appears the current typescript support allows you to define the theme object shape when using styled(), but not when using the css prop. Currently (and as confirmed by the documentation), the object is typed as any.

Suggested solution:

Not sure if possible, but hopefully provide some way of defining a theme type via typescript generics, even when using the css prop. It appears the type is hardcoded for the css prop to any here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions