Emotion: Typings are missing SerializedStyles

Created on 7 Dec 2018  路  4Comments  路  Source: emotion-js/emotion

  • emotion version: 10.0.4
  • react version: 16.6.3

Relevant code.

/** @jsx jsx */
import { css, jsx } from "@emotion/core";

const base = css`
background-color: hotpink;
`;

export default () => (
  <div
    css={base}
  >
    This has a hotpink background.
  </div>
);

What you did:
Wrote a small react component using emotion 10, using the example in the docs

What happened:
Typescript complained about wrong typing
image

Reproduction
https://github.com/hiiyar/vgprime-web/tree/emotion-10
yarn install && yarn dev

TypeScript question

Most helpful comment

Thank you for posting an issue.
This is because one of your dependencies, namely, react-spinners, depends on old emotion(@9) typing.
With version number, exact error message would be

Type 'SerializedStyles'(@10) is not assignable to type 'Interpolation'(@9).

(other two lines are meaningless, since it just explain the way that TS tried to assign version 10 type to version 9 type.

All 4 comments

Thank you for posting an issue.
This is because one of your dependencies, namely, react-spinners, depends on old emotion(@9) typing.
With version number, exact error message would be

Type 'SerializedStyles'(@10) is not assignable to type 'Interpolation'(@9).

(other two lines are meaningless, since it just explain the way that TS tried to assign version 10 type to version 9 type.

@Ailrun thank you, makes sense.

So when we run into this would the correct course of action be to raise an issue on the library causing the error?

In cases like this, you should raise an issue in the dependant project and ideally help them migrate to a new version of emotion. Closing this as the problem has been investigated and the advice has been given.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnbrett picture johnbrett  路  3Comments

mattfysh picture mattfysh  路  3Comments

Aaron-Pool picture Aaron-Pool  路  3Comments

smlmrkhlms picture smlmrkhlms  路  3Comments

mitchellhamilton picture mitchellhamilton  路  3Comments