reactjstypescriptmaterial-ui

How to resolve the error Property 'vars' does not exist on type 'Theme' in Material UI


I am trying to clone this project locally

https://github.com/mui/material-ui/tree/v6.1.9/docs/data/material/getting-started/templates/marketing-page

I git cloned the project and moved shared-theme and marketing-page into my project as mentioned in README but I keep getting this error that

borderRadius: (theme.vars || theme).shape.borderRadius,

Property 'vars' does not exist on type 'Theme'.ts(2339)

I also installed all the npm libraries mentioned in the README.

What am I doing wrong here?


Solution

  • To fix this typescript error, add the following line:

    import type {} from '@mui/material/themeCssVarsAugmentation';
    

    see https://mui.com/material-ui/customization/css-theme-variables/usage/#typescript