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

[material-ui] Use interface instead of type for props #41500

Merged
merged 3 commits into from Mar 18, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Mar 15, 2024

fixes #40427

Material UI Popper

build before: PopperProps usage is replaced by its value with React.ElementType<...>

export type PopperProps = Omit<BasePopperProps, 'direction'> & {
    /**
     * The component used for the root node.
     * Either a string to use a HTML element or a component.
     */
    component?: React.ElementType;
    /**
     * The components used for each slot inside the Popper.
     * Either a string to use a HTML element or a component.
     * @default {}
     */
    components?: {
        Root?: React.ElementType;
    };
    /**
     * The props used for each slot inside the Popper.
     * @default {}
     */
    componentsProps?: BasePopperProps['slotProps'];
    /**
     * The system prop that allows defining system overrides as well as additional CSS styles.
     */
    sx?: SxProps<Theme>;
};
declare const Popper: React.ForwardRefExoticComponent<Omit<BasePopperProps, "direction"> & {
    /**
     * The component used for the root node.
     * Either a string to use a HTML element or a component.
     */
    component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
    /**
     * The components used for each slot inside the Popper.
     * Either a string to use a HTML element or a component.
     * @default {}
     */
    components?: {
        Root?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
    } | undefined;
    /**
     * The props used for each slot inside the Popper.
     * @default {}
     */
    componentsProps?: BasePopperProps['slotProps'];
    /**
     * The system prop that allows defining system overrides as well as additional CSS styles.
     */
    sx?: SxProps<Theme> | undefined;
} & React.RefAttributes<HTMLDivElement>>;

build after: PopperProps is used, no usage of React.ElementType<...>.

export interface PopperProps extends Omit<BasePopperProps, 'direction'> {
    /**
     * The component used for the root node.
     * Either a string to use a HTML element or a component.
     */
    component?: React.ElementType;
    /**
     * The components used for each slot inside the Popper.
     * Either a string to use a HTML element or a component.
     * @default {}
     */
    components?: {
        Root?: React.ElementType;
    };
    /**
     * The props used for each slot inside the Popper.
     * @default {}
     */
    componentsProps?: BasePopperProps['slotProps'];
    /**
     * The system prop that allows defining system overrides as well as additional CSS styles.
     */
    sx?: SxProps<Theme>;
}
declare const Popper: React.ForwardRefExoticComponent<PopperProps & React.RefAttributes<HTMLDivElement>>;
export default Popper;

Base UI Popup

Before:

declare const Popup: React.ForwardRefExoticComponent<Omit<PopupProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<Element>>;

After:

declare const Popup: PolymorphicComponent<PopupTypeMap<{}, "div">>;

@siriwatknp siriwatknp added typescript package: material-ui Specific to @mui/material labels Mar 15, 2024
@mui-bot
Copy link

mui-bot commented Mar 15, 2024

Netlify deploy preview

https://deploy-preview-41500--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 06bd85e

Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into it. I suppose there is no straightforward way to add a test for this, right?

@siriwatknp
Copy link
Member Author

siriwatknp commented Mar 15, 2024

Thanks for looking into it. I suppose there is no straightforward way to add a test for this, right?

I guess there is but it would require some amount of effort. The idea is to use the build and run tsc against both React v17 and v18.

@Janpot
Copy link
Member

Janpot commented Mar 15, 2024

The idea is to use the build and run tsc against both React v17 and v18.

Yep, that doesn't fall under what I meant with "straightforward" 😄

@siriwatknp siriwatknp marked this pull request as ready for review March 18, 2024 02:35
@siriwatknp siriwatknp enabled auto-merge (squash) March 18, 2024 03:15
@siriwatknp siriwatknp added the package: base-ui Specific to @mui/base label Mar 18, 2024
@siriwatknp siriwatknp merged commit fb361fa into mui:master Mar 18, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: base-ui Specific to @mui/base package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript broken in latest release ElementType requires between 0-1 type arguments
3 participants