Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17f5e83

Browse files
authored
refactor: extend Overrides for MuiSkeleton (#4818)
* refactor: extend Overrides for MuiSkeleton Looking at the types provided with `@material-ui/core`, it is indeed missing `MuiSkeleton`. I'm not sure why. I found this issues upstream: mui/material-ui#24959 I also tried upgrading the package to the latest - 4.12.4 I believe but that didn't fix it either. I resorted to extending the `Overrides` type based on what I saw in the most recent version of the declaration file. This is a temporary fix but opts back in to type safety instead of resorting to `@ts-ignore`. * formatting
1 parent 34268e6 commit 17f5e83

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

site/src/theme/overrides.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import { lighten, Theme } from "@material-ui/core/styles"
1+
import { lighten, Theme, StyleRules } from "@material-ui/core/styles"
22
import { Overrides } from "@material-ui/core/styles/overrides"
3+
import { SkeletonClassKey } from "@material-ui/lab"
34
import { colors } from "./colors"
45
import { borderRadius, borderRadiusSm } from "./constants"
56

6-
export const getOverrides = ({ palette, breakpoints }: Theme): Overrides => {
7+
type ExtendedOverrides = Overrides & {
8+
MuiSkeleton: Partial<StyleRules<SkeletonClassKey>>
9+
}
10+
11+
export const getOverrides = ({
12+
palette,
13+
breakpoints,
14+
}: Theme): ExtendedOverrides => {
715
return {
816
MuiCssBaseline: {
917
"@global": {
@@ -190,8 +198,6 @@ export const getOverrides = ({ palette, breakpoints }: Theme): Overrides => {
190198
marginTop: 8,
191199
},
192200
},
193-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- The Mui types don't accept the MuiSkeleton but it works. I tried to extends the Overrides interface with no success.
194-
// @ts-ignore
195201
MuiSkeleton: {
196202
root: {
197203
backgroundColor: palette.divider,

0 commit comments

Comments
 (0)