; const Ap" /> ; const Ap" /> ; const Ap"/>

ComponentProps in xstyled components

69 Views Asked by At
import { x } from "@xstyled/styled-components";
import React, { ComponentProps } from "react"

type WrongProps = ComponentProps<typeof x.div>;

const App = () => {
  return (
    <x.div
      wrongProp="wrong"
    />
  );
}

I'm using components from https://xstyled.dev/. When trying to get the type of all possible props from <x.div {...props} />, I get an object that can be anything, but clearly, it doesn't accept any props. Because when trying to pass "wrongProp", it yells at me that it doesn't exist. Type WrongProps gets inferred as follows:

type WrongProps = {
    [x: string]: any;
    [x: number]: any;
    [x: symbol]: any;
} & {
    theme?: DefaultTheme | undefined;

Do you know the problem and how to get around it?

0

There are 0 best solutions below