-
-
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
[base] Override the types of slotProps
per slot
#35964
Conversation
Netlify deploy previewNo updates. Bundle size report |
slotProps
per slot
slotProps
per slotslotProps
per slot
Looks good! As this is a breaking change, could you please add a short description of changes that need to be done by developers after updating to this version? |
Sure, I will try writing a Codemod script as well for this breaking change. |
fbbbd18
to
0a56020
Compare
The codemod could be tricky (if not impossible) to get right. It's hard to know which slots a developer wants to override (unless you create overrides for all of them, for example copying the shape of |
Yes, this was my idea. So developers can clean it up afterwards. I thought it's still useful as it reduces lots of manual work for those who have many of these type declarations. Let me know if you think it's not worth the effort. e.g., actual.ts:
declare module '@mui/base/SwitchUnstyled' {
interface SwitchUnstyledComponentsPropsOverrides {
'data-a'?: string;
'data-b'?: string;
'data-c'?: string;
'data-d'?: string;
}
} to expected.ts:
declare module '@mui/base/SwitchUnstyled' {
interface SwitchUnstyledRootSlotOverrides {
'data-a'?: string;
'data-b'?: string;
'data-c'?: string;
'data-d'?: string;
}
interface SwitchUnstyledInputSlotOverrides {
'data-a'?: string;
'data-b'?: string;
'data-c'?: string;
'data-d'?: string;
}
interface SwitchUnstyledThumbSlotOverrides {
'data-a'?: string;
'data-b'?: string;
'data-c'?: string;
'data-d'?: string;
}
interface SwitchUnstyledTrackSlotOverrides {
'data-a'?: string;
'data-b'?: string;
'data-c'?: string;
'data-d'?: string;
}
} Jscodeshift supports something like |
OK, it makes sense as it'll make the code run at least. |
413b6e3
to
c47a855
Compare
The codemod's taking way longer than I expected. I will drop it. I reverted codemod-related changes and added a note to the description of the PR, which should be added to the CHANGELOG of the upcoming release. |
c47a855
to
d0ca459
Compare
In SelectUnstyled.spec.tsx and MultiSelectUnstyled.spec.tsx there are tests with names containing |
Thanks. Done in this commit: Rename some functions in type tests. |
@@ -6,7 +6,7 @@ import { SlotComponentProps } from '../utils'; | |||
|
|||
export type PopperPlacementType = Options['placement']; | |||
|
|||
interface PopperUnstyledComponentsPropsOverrides {} | |||
interface PopperUnstyledRootSlotPropsOverrides {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's related to this PR, but shouldn't this interface be exported?
We've encountered an issue when upgrading MUI Core packages in mui/mui-x#7905:
https://ci.codesandbox.io/status/mui/mui-x/pr/7905/builds/349844
cmd: 'yarn tsc -b /tmp/fad0ee40/packages/grid/x-data-grid-generator/tsconfig.build.json',
stdout: '$ /tmp/fad0ee40/node_modules/.bin/tsc -b /tmp/fad0ee40/packages/grid/x-data-grid-generator/tsconfig.build.json\n' +
`../x-data-grid/src/components/panel/GridPanel.tsx(38,7): error TS4023: Exported variable 'GridPanelRoot' has or is using name 'PopperUnstyledRootSlotPropsOverrides' from external module "/tmp/fad0ee40/node_modules/@mui/base/PopperUnstyled/PopperUnstyled.types" but cannot be named.\n` +
cc @michaldudak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely. Thanks for letting me know. I'll review other cases and fix it right away.
Closes #34906
This PR goes with option 1 described in the issue above
Note to be added to CHANGELOG in the upcoming release
Breaking Changes for MUI Base:
slotProps
prop has changed. Developers can now override them per slot.${ComponentName}ComponentsPropsOverrides
is replaced with${ComponentName}${SlotName}SlotPropsOverrides
.