Material-ui: Type error: Namespace 'React' has no exported member 'ElementType'.

Created on 4 Jun 2019  路  5Comments  路  Source: mui-org/material-ui


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.

  • [ X ] This is not a v0.x issue.
  • [ X ] I have searched the issues of this repository and believe that this is not a duplicate.

Your Environment 馃寧

| 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" ] }

typescript

Most helpful comment

This is likely due to an outdated version of @types/react. Try upgrading that version to at least ^16.8.6

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zabojad picture zabojad  路  3Comments

finaiized picture finaiized  路  3Comments

revskill10 picture revskill10  路  3Comments

FranBran picture FranBran  路  3Comments

rbozan picture rbozan  路  3Comments