Compiled

Known issues with Emotion

While Compiled has a very similar API to Emotion, there are some known issues specific to Emotion that you may need to address.

For Compiled limitations not specific to migrating from Emotion, see our limitations page.

@emotion/core types are not compatible with Compiled

Emotion v10 (@emotion/core) extends the global interfaces for the css prop, causing the css prop to only work with Emotion, and not styled-components or Compiled. As a result, you may run into Type 'CSSProps<unknown>' is not assignable to type 'InterpolationWithTheme<any>'. errors.

To fix this, we recommend:

diff --git a/node_modules/@emotion/core/types/index.d.ts b/node_modules/@emotion/core/types/index.d.ts
index 123456..abcdef 100644
--- a/node_modules/@emotion/core/types/index.d.ts
+++ b/node_modules/@emotion/core/types/index.d.ts
@@ -78,22 +78,3 @@ export interface ClassNamesProps<Theme> {
 export function ClassNames<Theme = any>(
   props: ClassNamesProps<Theme>
 ): ReactElement
-
-declare module 'react' {
-  interface DOMAttributes<T> {
-    css?: InterpolationWithTheme<any>
-  }
-}
-
-declare global {
-  namespace JSX {
-    /**
-     * Do we need to modify `LibraryManagedAttributes` too,
-     * to make `className` props optional when `css` props is specified?
-     */
-
-    interface IntrinsicAttributes {
-      css?: InterpolationWithTheme<any>
-    }
-  }
-}

Suggest changes to this page ➚