-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Typescript issues in 10.19.4+ with @mui/material #4293
Comments
it is related to #4271, specifically only this one: Lines 175 to 179 in c3160cc
|
Thanks for finding that! Will need to figure out an altered implementation I guess. |
Issue 1 resolved for me by modifying ComponentPropsWithRef as follows (from ryanlchan/preact@8a6b642): export type ComponentPropsWithRef<
C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
> = C extends new (props: infer P) => Component<any, any>
? PropsWithoutRef<P> & RefAttributes<InstanceType<C>>
: PropsWithRef<ComponentProps<C>>; This matches the implementation in types/react: type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
: PropsWithRef<ComponentProps<T>>; I could not get issues 2 and 3 to repro - @akornatskyy could you check if this helps you? |
@ryanlchan : thanks. I rolled your change on top of version |
@ryanlchan : any update? it is still reproducable with |
I could make it work by providing the type parameter: |
Going to close this out as I can no longer reproduce in latest Preact, seems to have been fixed? import { Card, Button, Icon } from '@mui/material';
export function Tmp() {
return <Card component="form" />;
}
export function Tmp2() {
return <Button>test <Icon /></Button>;
}
export function Tmp3() {
const disabled = true;
return <Button>test {disabled && <Icon />}</Button>;
} None of the original 3 cases seem to cause type errors anymore. If anyone can reproduce them, let me know. |
import Fade from '@mui/material/Fade';
import {styled} from '@mui/material/styles';
const Styled = styled(Fade)({});
export function T() {
const disabled = true;
return <p>test {disabled && <Styled />}</p>;
}
|
@akornatskyy I cannot reproduce any type errors with that snippet. Please double check the versions you're using. @mui/material: 6.1.7 |
The type error there is entirely correct; a button does not trigger a Generally I'd suggest letting TS infer the type (write an inline function first if you have to) as guessing the parameter type can cause difficult type errors if you're not familiar. |
@rschristian: my confusion was that error points to line 14 instead of 12. |
Ah, well, not something on our end. Maybe the library tries to derive different children types depending on event props? Not sure. |
It works as expected with
preact
version10.19.3
. The issues are reproducable with10.19.4
-10.19.6
.Issue 1
cause:
Issue 2
another issue is related to
Button
:cause:
Issue 3
and another one:
cause:
The text was updated successfully, but these errors were encountered: