-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
TS2589 Error throws in TS3.6 if SVGIcon component being wrapped with styled-components #17275
Comments
Thank you for opening this issue and trying out the new typescript release. As far as I can tell this is an issue with TypeScript. Since microsoft/TypeScript#33132 is labelled as a bug I'd like to see if a workaround is found. If anybody has a solution I'm happy to review it but I'm not actively looking for a solution that is caused by two external dependencies just yet. |
Thank you very much. Yes, this is introduced by the latest TypeScript and looks like there are other typing regression bugs (e.g. one in RxJS). So far it’s unclear if TS would really fixes this since the core team member there also said it is likely to be by design. If that is the case, I do think MUI should simply the typing so it became extendable to the user, or documented as caveats. That’s why I open an issue here. Edited by @eps1lon: Restored actual comment. I actually overwrote the post I wanted to respond to instead of replying. 🤦♂️ |
That is always a goal (not just for the user but maintainer). We have to figure out how this might be possible first though. Currently it doesn't "look" very complicated it's just a It might not be a bad idea in the first place to get rid of Did you check if you encounter this issue with other components decorated with |
Nope, I'm actually using styled-components heavily, and none of one I wrapped with MUI-core gives error but the one from MUI-icon. And the interface of export interface SvgIconProps
extends StandardProps<React.SVGProps<SVGSVGElement>, SvgIconClassKey> {
color?: PropTypes.Color | 'action' | 'disabled' | 'error';
component?: React.ElementType<React.SVGProps<SVGSVGElement>>;
fontSize?: 'inherit' | 'default' | 'small' | 'large';
htmlColor?: string;
shapeRendering?: string;
titleAccess?: string;
viewBox?: string;
}
export type StandardProps<
C,
ClassKey extends string,
Removals extends keyof C = never,
AcceptsRef = true
> = Omit<C, 'classes' | Removals> &
StyledComponentProps<ClassKey> & {
className?: string;
style?: React.CSSProperties;
} & {
ref?: AcceptsRef extends true
? C extends { ref?: infer RefType }
? RefType
: React.Ref<unknown>
: never;
}; I guess there are some overheads for typescript language services. If keep tracking down, we do see some conditional types for But I don't think it is hitting the language parsing limits, or it could really a regression from TS?! |
Oh, well, it is compared to most of our types. What I'm getting at is that |
@eps1lon This actually solves the issue |
Great. This should also improve type perf for every component that isn't polymorphic and we can get rid of implicit children. |
So it looks like |
So what fixed this now specifically? |
It works when leaving |
This seems to affect |
Yes Textfield is also affected |
Dialog is also affected |
Current Behavior 😯
Expected Behavior 🤔
TS3.5 gives no errors, probably is due to this (comments).
Steps to Reproduce 🕹
Steps:
The code is straightforward, just copy paste and use in any component to see this TS error.
Context 🔦
Other components seems okay but SVG components are doomed. Perhaps we can simplify a bit the type declaration so it is less deep.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: