gregnb / gregnb/mui-datatables

Custom styling does not work with TypeScript

Open
#1,810 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

With
```
"react": "^17.0.2",
"@mui/material": "^5.0.6",
"mui-datatables": "^4.0.0",
```

const getMuiTheme = () =>
createTheme({
overrides: {
MUIDataTable: {
root: {
backgroundColor: '#AAF',
},
paper: {
boxShadow: 'none',
},
},
},
});

Gives an error with TypeScript
```
Argument of type '{ overrides: { MUIDataTable: { root: { backgroundColor: string; }; paper: { boxShadow: string; }; }; }; }' is not assignable to parameter of type 'ThemeOptions'.
Object literal may only specify known properties, and 'overrides' do not exist in type 'ThemeOptions'.
```

the following code

const tableTheme = () =>
createTheme(
adaptV4Theme({
overrides: {
MUIDataTable: {
root: {
backgroundColor: '#AAF',
},
paper: {
boxShadow: 'none',
},
},
},
}),
);

gives me the following message

```
Type '{ MUIDataTable: { root: { backgroundColor: string; }; paper: { boxShadow: string; }; }; }' is not assignable to type 'ComponentsOverrides'.
Object literal may only specify known properties, and 'MUIDataTable' does not exist in type 'ComponentsOverrides'.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the TypeScript errors in the createTheme and adaptV4Theme examples using the listed React, @mui/material, and mui-datatables versions. Trace the typing for MUIDataTable styling and determine what change is needed so the custom styling configuration type-checks; done means both examples no longer produce the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.