Skip to content

[styled-component] Support css prop #31245

@sarod

Description

@sarod

I tried using the new css prop (https://medium.com/styled-components/announcing-native-support-for-the-css-prop-in-styled-components-245ca5252feb) with the babel typescript presets and the styled-component babel-plugin.

This runs fine but type-checking fails because type definition does not extend builtin components (div, button...) with the 'css' prop.

Note that a similar prop seems to be supported in emotionjs type definitions by globally extending the react module:

declare module 'react' {
  interface DOMAttributes<T> {
    css?: InterpolationWithTheme<any>
  }
}

See
https://github.com/emotion-js/emotion/blob/1b7333a837813949fa4fe301bb0d53887e784b8b/packages/core/types/index.d.ts#L83

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions