Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v6 TS Missing static properties when component is wrapped by styled-component #4104

Closed
oskarwrobel opened this issue Jul 26, 2023 · 1 comment

Comments

@oskarwrobel
Copy link

oskarwrobel commented Jul 26, 2023

TS does not see static properties when component is wrapped by styled-component.

Reproduction

function MyComponent({ className }: { className?: string }) {
  return <div>My component</div>
}
MyComponent.SomeStaticData = "Foo bar";

const StyledMyComponent = styled(MyComponent)`
  color: blue;
`;

return (
  <>{StyledMyComponent.SomeStaticData}</>
);

Property 'SomeStaticData' does not exist on type 'IStyledComponent<"web", typeof MyComponent, { className?: string | undefined; } & object> & object'.ts(2339)

Example: https://codesandbox.io/s/keen-euler-gxn4zj?file=/src/App.tsx
(CodeSandbox supports styled-components 6.0.0-beta.14 however it works exactly the same for 6.0.5)

Steps to reproduce

Wrap a component that contains static properties.

Expected Behavior

Static properties should remain accessible.

Actual Behavior

TS does not see static properties.

@oskarwrobel oskarwrobel changed the title v6 TS does not see static properties when component is wrapped by styled-component v6 TS Missing static properties when component is wrapped by styled-component Aug 1, 2023
@oskarwrobel
Copy link
Author

Fixed by @MartinPELCAT in #4141.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant