-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[DataGrid] Add slot typings #11795
[DataGrid] Add slot typings #11795
Conversation
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -49,44 +56,52 @@ export interface LoadingOverlayPropsOverrides {} | |||
export interface NoResultsOverlayPropsOverrides {} | |||
export interface NoRowsOverlayPropsOverrides {} | |||
export interface PanelPropsOverrides {} | |||
export interface PinnedRowsPropsOverrides {} | |||
export interface SkeletonCellPropsOverrides {} | |||
export interface RowPropsOverrides {} |
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.
I don't love these but I've added the missing ones for consistency.
ref={handleRef} | ||
ref={handleRef as any /* FIXME: typing error */} |
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.
I fixed the straightfoward typing errors, but left FIXME
comments for the ones that I couldn't find an easy answer to (mainly because the typings are in MUI core's codebase, so they're harder to fix). For the baseCheckbox
refs, the error is often a type mismatch between HTMLInputElement
vs HTMLButtonElement
which seemed harmless.
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.
Sidenote but while working on this I realized that making the datagrid work without MUI is going to be painful. Most of our base slot typings come directly from MUI, so we might have to duplicate typings. Or make users install MUI locally even when it's not bundled.
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.
Tough one indeed, I've added this problem to https://www.notion.so/mui-org/Using-Data-Grid-with-non-Material-slots-1f2978030a354ae388499be03ff5d549
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -8,5 +8,7 @@ export function GridFooterPlaceholder() { | |||
return null; | |||
} | |||
|
|||
return <rootProps.slots.footer {...rootProps.slotProps?.footer} />; | |||
return ( | |||
<rootProps.slots.footer {...(rootProps.slotProps?.footer as any) /* FIXME: typing error */} /> |
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.
This one is interesting.
The reason it's failing without as any
is this override in the docs examples:
mui-x/docs/data/data-grid/components/CustomFooter.tsx
Lines 10 to 14 in 58c5fe8
declare module '@mui/x-data-grid' { | |
interface FooterPropsOverrides { | |
status: FooterStatus; | |
} | |
} |
I there something we can do to isolate overrides in docs
from the packages?
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.
The way it's setup, the docs is importing the grid through relative imports (behind aliased paths). If the docs were importing code as regular packages, then the skipLibCheck
flag would do that iiuc, but it doesn't apply here since it's just regular files. I think it could probably be done, but I'm not sure how long it will take to setup, so I'd skip it for this PR.
Do we want to take the time to fix the remaining typing errors or are we ok with this change as it is? |
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.
Could you add a guide for typing a custom slot and mention the change in the migration guide?
…nto refactor-typed-grid-slots
Co-authored-by: Andrew Cherniavskyi <[email protected]> Co-authored-by: Bilal Shafi <[email protected]>
Closes #11687