Trying to migrate to latest version of material-ui, but I'm getting following compilation error.
.../@material-ui/core/Badge/Badge.d.ts
Type error: Namespace 'React' has no exported member 'ElementType'. TS2694
if I look into react/index.d.ts there's indeed no ElementType type defined.
| Tech | Version |
|--------------|---------|
| Material-UI | ^4.0.2 |
| React | ^16.8.6 |
| TypeScript | 3.3.3 |
tsconfig>
{
"compilerOptions": {
"target": "es6",
"allowJs": true,
"skipLibCheck": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"experimentalDecorators": true
},
"include": [
"src"
]
}
This is likely due to an outdated version of @types/react
. Try upgrading that version to at least ^16.8.6
My Bad! I was on @types/react
version 16.8.3.
Moving to version 16.8.19 fixes the issue!
already on version "@types/react": "^16.9.32", still gettins same issue
@anuja8275 I solved my issue that could be your issue by changing my filename from .ts to .tsx and by importing React.
If anyone is converting their App from JS to TS then they have to rename the filename to ts and tsx respectively, wherever jsx is written those files should be converted to tsx.
Most helpful comment
This is likely due to an outdated version of
@types/react
. Try upgrading that version to at least^16.8.6