emotion icon indicating copy to clipboard operation
emotion copied to clipboard

Type '{ children: string; css: SerializedStyles; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.

Open A91y opened this issue 1 year ago • 2 comments

Code Used

import React from "react";
import { css } from "@emotion/react";

const color = "white";

const App = () => {
  return (
    <>
      <div
        css={css`
          padding: 32px;
          background-color: hotpink;
          font-size: 24px;
          border-radius: 4px;
          text-align: center;
          cursor: pointer;
          &:hover {
            color: ${color};
          }
        `}
      >
        Hover to change color.
      </div>
    </>
  );
};

export default App;

Message in Problem Tab (VSCODE)

Type '{ children: string; css: SerializedStyles; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
  Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.

Additional Note

With the message popping in the problem tab. The css properties too were not applied on the page.

Environment information:

  • react version: 18.2.0
  • @emotion/react version: 11.11.1

A91y avatar Jul 20 '23 15:07 A91y

same problem

hyorimcho avatar Jan 30 '24 00:01 hyorimcho

import { type SerializedStyles } from '@emotion/react'
declare module 'react' {
  interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
    flex?: boolean
    relative?: boolean
    text?: string
    grid?: boolean
    before?: string
    after?: string
    shadow?: boolean
    w?: string
    h?: string
    bg?: string
    rounded?: string
    fixed?: boolean
    b?: string
    z?: string
    block?: boolean
    'focus:shadow'?: boolean
    css?: SerializedStyles
  }
  interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
    w?: string
    h?: string
  }
}

Rascal-Coder avatar Apr 10 '24 14:04 Rascal-Coder