Skip to content

Typescript error referencing another selector but it works #45

Open

Description

@dominictobias

Hi, when referencing another styled component like this:

const Parent = styled('div')``

const Child = styled('div')`
  ${Parent}.active & {
    background: blue;
  }
`

It works but generates the following TS error:

Screenshot 2023-02-13 at 19 22 47

Argument of type 'Component<HTMLAttributes<HTMLDivElement> & AsProps> & { class: (props: HTMLAttributes<HTMLDivElement> & AsProps) => string; }' is not assignable to parameter of type 'string | TagStyleGenerator<HTMLAttributes<HTMLDivElement> & AsProps & ThemeProp>'.
  Type 'Component<HTMLAttributes<HTMLDivElement> & AsProps> & { class: (props: HTMLAttributes<HTMLDivElement> & AsProps) => string; }' is not assignable to type 'TagStyleGenerator<HTMLAttributes<HTMLDivElement> & AsProps & ThemeProp>'.
    Type 'Element' is not assignable to type 'string | number | undefined'.
      Type 'null' is not assignable to type 'string | number | undefined'.ts(2345)

Is this not the correct way, or can this TS error be ignored? Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions