You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
styled(MantineButton) rejects all props in 6.4.2 (regression from 6.1.x) #5756
In 6.1.x, wrapping a component whose React.ComponentPropsWithRef<typeof T> resolves to {} produced a styled component that was permissive enough to accept arbitrary props at JSX call sites. In 6.4.2 the same code rejects every prop, including children.
This breaks every styled(X) where X is a Mantine v7 polymorphic-factory component (Button, Card, Menu.Item, Badge, SegmentedControl, …). TypeScript can't introspect Mantine's callable-generic intersection, so React.ComponentPropsWithRef<typeof X> resolves to {} in any sc version. 6.1.x stayed permissive on that empty BaseProps; 6.4.2 does not.
Simple Example
import*asReactfrom'react';importstyledfrom'styled-components';import{ButtonasMantineButton}from'@mantine/core';constStyled=styled(MantineButton)`color: red;`;// 6.1.x: OK// 6.4.2: TS2769 — `variant` and `children` do not exist on// `FastOmit<FastOmit<{}, never> & Partial<Pick<{}, never>>, "as" | "forwardedAs">// & { as?: WebTarget; forwardedAs?: WebTarget }`constusage=<Styledvariant="filled">hi</Styled>;
Thanks for the quick response/fix to this. Using 6.x-test fixes the minimal example that I provided, but unfortunately we still see issues when an additional/transient prop is added to the styled Mantine component like this:
import{Button}from'@mantine/core';importstyledfrom'styled-components';constStyledWithExtras=styled(Button)<{$variant: 'a'|'b'}>`color: red;`;constx=<StyledWithExtras$variant="a"variant="filled">hi</StyledWithExtras>;// TS2769 — Property 'children' does not exist on type// IntrinsicAttributes & FastOmit<FastOmit<FastOmit<{}, '$variant'> & { $variant: 'a' | 'b' }, never> & Partial<...>, ...>
In this case, it is revealed that the internal type is still resolved as FastOmit. A fix for this would be great!
We're running into a similar problem with styled() wrapping a polymorphic/generic component.
The wrapped component silently accepts props that the component itself would reject.
Repro
import*asReactfrom"react";importstyledfrom"styled-components";typeAsProp<CextendsReact.ElementType>={as?: C};typePolymorphicComponentProps<CextendsReact.ElementType,P=object>=React.PropsWithChildren<P&AsProp<C>>&Omit<React.ComponentPropsWithoutRef<C>,keyof(AsProp<C>&P)>;typeButtonVariant="primary"|"secondary";interfaceButtonBasePropsextendsReact.ButtonHTMLAttributes<HTMLButtonElement>{variant?: ButtonVariant;}typeButtonProps<CextendsReact.ElementType="button">=PolymorphicComponentProps<C,ButtonBaseProps>;constButton=<CextendsReact.ElementType="button">(props: ButtonProps<C>)=>null;constStyledButton=styled(Button)``;// Direct component correctly rejects the bad variant:constok=<Buttonvariant="totally-fake">x</Button>;// errors (correct)// Wrapped component silently accepts it:constbad=<StyledButtonvariant="totally-fake">x</StyledButton>;// no error — expected an error
On 6.4.x the StyledButton line produces no error, even though the direct Button usage does.
Any help will be much appreciated!
Reacted by Sebastian Janik, Oskar Wróbel, Gabriel Daniluk, Paweł Gutowski and Dennis Oelkers
The problem I mentioned in my earlier comment still seems unresolved on 6.5.1 — using that repro, <StyledButton variant="totally-fake"> is still accepted silently, while the unwrapped <Button variant="totally-fake"> correctly errors.
Could you take a look, or shall I report a separate issue?
The problem I mentioned in my earlier comment still seems unresolved on 6.5.1 — using that repro, <StyledButton variant="totally-fake"> is still accepted silently, while the unwrapped <Button variant="totally-fake"> correctly errors.
Could you take a look, or shall I report a separate issue?
Activity
refactor(types): confine untyped-target widening to the JSX call surface
fix(types): distribute the empty-props check over unions
test(types): guard the empty-props predicate across its full input space
fix(types): make .attrs() permissive for un-introspectable targets
fix(types): keep styled() and .attrs() permissive for un-introspectab…
fix(types): permissive props for un-introspectable targets, plus as-t…
quantizor commentedon Jun 2, 2026
Sorry for the trouble, could you try out #5759 in the form of
[email protected]please?dennisoelkers commentedon Jun 2, 2026
Hey @quantizor!
Thanks for the quick response/fix to this. Using
6.x-testfixes the minimal example that I provided, but unfortunately we still see issues when an additional/transient prop is added to the styled Mantine component like this:In this case, it is revealed that the internal type is still resolved as
FastOmit. A fix for this would be great!kkwasny-rtbh commentedon Jun 11, 2026
We're running into a similar problem with styled() wrapping a polymorphic/generic component.
The wrapped component silently accepts props that the component itself would reject.
Repro
On 6.4.x the StyledButton line produces no error, even though the direct Button usage does.
Any help will be much appreciated!
fix(types): derive target props once per target, not per call site
fix(types): decide target permissiveness from the target, not the pro…
fix(types): decide permissiveness from the target, and hold style con…
feat(types): derive target props once per target, and merge a declare…
quantizor commentedon Aug 4, 2026
This should be fixed in 6.5 https://github.com/styled-components/styled-components/releases/tag/styled-components%406.5.0
quantizor commentedon Aug 6, 2026
There's a patch prerelease (
[email protected]) that fixes a few other issues if you could test it and let me know if it fixes your issue?quantizor commentedon Aug 6, 2026
Didn't mean to auto-close, waiting for your yay/nay.
quantizor commentedon Aug 7, 2026
Now formally released https://github.com/styled-components/styled-components/releases/tag/styled-components%406.5.1
Please go ahead and close the issue if it's fixed for you or post some more info.
kkwasny-rtbh commentedon Aug 10, 2026
Hey @quantizor, thanks for your response!
The problem I mentioned in my earlier comment still seems unresolved on 6.5.1 — using that repro,
<StyledButton variant="totally-fake">is still accepted silently, while the unwrapped<Button variant="totally-fake">correctly errors.Could you take a look, or shall I report a separate issue?
quantizor commentedon Aug 10, 2026
Yes a new focused ticket would be helpful
perf(types): `.attrs` target-unchanged fast path, and broaden the typ…
fix(types): cheaper annotated declaration sites, and sound generic po…
quantizor commentedon Aug 10, 2026
@kkwasny-rtbh give this a go https://github.com/styled-components/styled-components/releases/tag/styled-components%406.5.2-prerelease-20260810214005
[email protected]
kkwasny-rtbh commentedon Aug 11, 2026
@quantizor, thanks a lot for the quick response!
The fix in
6.5.2-prerelease-20260810214005seems to work fine so I'm looking forward to the release. 👍quantizor commentedon Sep 25, 2026
Closing as fixed: the original case shipped in 6.5.1 and the follow-up case in 6.5.2. Please open a new issue if anything still looks off.