As I set up a new project with Vite, I encountered a perplexing issue when running tsc
that resulted in 784 errors related to MUI being unable to locate the csstype
module. Here is an example of the error:
node_modules/@mui/styled-engine/index.d.ts:1:22 - error TS2307: Cannot find module 'csstype' or its corresponding type declarations.
My MUI and TypeScript versions are as follows:
"@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.4.4",
"@mui/material": "^5.4.4",
"typescript": "^4.5.5",
Below is my tsconfig configuration:
{
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"types": ["vite/client"],
"baseUrl": "./src",
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"paths": {
"~/": ["*"]
},
"removeComments": true,
"noEmitOnError": true,
"noImplicitAny": false,
"strictNullChecks": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
/* Experimental Options */
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */
},
"include": ["./src"],
"exclude": ["node_modules"]
}
Although I have included "moduleResolution": "Node"
in my tsconfig, which resolves similar issues for others, I am still facing this problem.