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

[DataGrid] Fix ElementType usage #12479

Merged
merged 4 commits into from
Mar 19, 2024
Merged

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Mar 18, 2024

Fixes mui/material-ui#40427 for the data grid

Before After

In GridPanel, you can still see generics being passed to React.ElementType, but this was solved on the Core side in mui/material-ui#41500

Testing

It's hard to test because it requires a different version of @types/react than we use in our monorepo.
I've created a branch in https://github.com/cherniavskii/cra-data-grid-test/tree/react17

Before:

npx tsc --skipLibCheck false
node_modules/@mui/base/Unstable_Popup/Popup.d.ts:13:70 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

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

node_modules/@mui/x-data-grid/components/cell/GridActionsCellItem.d.ts:25:17 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

25     component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@mui/x-data-grid/components/cell/GridActionsCellItem.d.ts:32:17 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

32     component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@mui/x-data-grid/components/cell/GridActionsCellItem.d.ts:37:17 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

37     component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@mui/x-data-grid/components/cell/GridActionsCellItem.d.ts:49:17 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

49     component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@mui/x-data-grid/components/GridPagination.d.ts:3:17 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

3     component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@mui/x-data-grid/components/GridPagination.d.ts:5:17 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

5     component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/react/global.d.ts:157:11 - error TS2451: Cannot redeclare block-scoped variable 'TrustedHTML'.

157 interface TrustedHTML {}
              ~~~~~~~~~~~

  node_modules/@types/trusted-types/index.d.ts:14:11
    14     const TrustedHTML: typeof lib.TrustedHTML;
                 ~~~~~~~~~~~
    'TrustedHTML' was also declared here.
  node_modules/@types/trusted-types/index.d.ts:15:10
    15     type TrustedHTML = lib.TrustedHTML;
                ~~~~~~~~~~~
    and here.

node_modules/@types/trusted-types/index.d.ts:14:11 - error TS2451: Cannot redeclare block-scoped variable 'TrustedHTML'.

14     const TrustedHTML: typeof lib.TrustedHTML;
             ~~~~~~~~~~~

  node_modules/@types/react/global.d.ts:157:11
    157 interface TrustedHTML {}
                  ~~~~~~~~~~~
    'TrustedHTML' was also declared here.

node_modules/@types/trusted-types/index.d.ts:15:10 - error TS2451: Cannot redeclare block-scoped variable 'TrustedHTML'.

15     type TrustedHTML = lib.TrustedHTML;
            ~~~~~~~~~~~

  node_modules/@types/react/global.d.ts:157:11
    157 interface TrustedHTML {}
                  ~~~~~~~~~~~
    'TrustedHTML' was also declared here.


Found 10 errors in 5 files.

Errors  Files
     1  node_modules/@mui/base/Unstable_Popup/Popup.d.ts:13
     4  node_modules/@mui/x-data-grid/components/cell/GridActionsCellItem.d.ts:25
     2  node_modules/@mui/x-data-grid/components/GridPagination.d.ts:3
     1  node_modules/@types/react/global.d.ts:157
     2  node_modules/@types/trusted-types/index.d.ts:14

After:

npx tsc --skipLibCheck false         
node_modules/@mui/base/Unstable_Popup/Popup.d.ts:13:70 - error TS2707: Generic type 'ElementType' requires between 0 and 1 type arguments.

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

node_modules/@types/react/global.d.ts:157:11 - error TS2451: Cannot redeclare block-scoped variable 'TrustedHTML'.

157 interface TrustedHTML {}
              ~~~~~~~~~~~

  node_modules/@types/trusted-types/index.d.ts:14:11
    14     const TrustedHTML: typeof lib.TrustedHTML;
                 ~~~~~~~~~~~
    'TrustedHTML' was also declared here.
  node_modules/@types/trusted-types/index.d.ts:15:10
    15     type TrustedHTML = lib.TrustedHTML;
                ~~~~~~~~~~~
    and here.

node_modules/@types/trusted-types/index.d.ts:14:11 - error TS2451: Cannot redeclare block-scoped variable 'TrustedHTML'.

14     const TrustedHTML: typeof lib.TrustedHTML;
             ~~~~~~~~~~~

  node_modules/@types/react/global.d.ts:157:11
    157 interface TrustedHTML {}
                  ~~~~~~~~~~~
    'TrustedHTML' was also declared here.

node_modules/@types/trusted-types/index.d.ts:15:10 - error TS2451: Cannot redeclare block-scoped variable 'TrustedHTML'.

15     type TrustedHTML = lib.TrustedHTML;
            ~~~~~~~~~~~

  node_modules/@types/react/global.d.ts:157:11
    157 interface TrustedHTML {}
                  ~~~~~~~~~~~
    'TrustedHTML' was also declared here.


Found 4 errors in 3 files.

Errors  Files
     1  node_modules/@mui/base/Unstable_Popup/Popup.d.ts:13
     1  node_modules/@types/react/global.d.ts:157
     2  node_modules/@types/trusted-types/index.d.ts:14

@cherniavskii cherniavskii added component: data grid This is the name of the generic UI component, not the React module! typescript labels Mar 18, 2024
@mui-bot
Copy link

mui-bot commented Mar 18, 2024

Deploy preview: https://deploy-preview-12479--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 3b4ed65

@cherniavskii cherniavskii marked this pull request as ready for review March 18, 2024 17:22
@cherniavskii
Copy link
Member Author

@siriwatknp Can you take a look if this makes sense to you? Thanks!

@cherniavskii cherniavskii added the needs cherry-pick The PR should be cherry-picked to master after merge label Mar 19, 2024
@cherniavskii cherniavskii merged commit 6fc1da5 into mui:next Mar 19, 2024
18 checks passed
@cherniavskii cherniavskii deleted the fix-react-types branch March 19, 2024 16:25
github-actions bot pushed a commit that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! needs cherry-pick The PR should be cherry-picked to master after merge 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