question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not find a declaration file for module '@mui/icons-material/Visibility'.

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I installed the latest version of material-ui and mui/icons-material v5.5.0. When I import an icon:

import Visibility from '@mui/icons-material/Visibility';

I got this error:

Could not find a declaration file for module '@mui/icons-material/Visibility'. 'C:/Users/User/project/app-react/frontend/node_modules/@mui/icons-material/Visibility.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/mui__icons-material` if it exists or add a new declaration (.d.ts) file containing `declare module '@mui/icons-material/Visibility';

Expected behavior 🤔

Should fix the eslint error while installing @mui/icons-material.

Steps to reproduce 🕹

Steps:

  1. Install the latest material-ui
  2. Install the latest mui/icons-material

Context 🔦

No response

Your environment 🌎

`npx @mui/envinfo`
 System:
    OS: Windows 10 10.0.19042
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD    
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.36)
  npmPackages:
    @mui/base:  5.0.0-alpha.71
    @mui/icons-material: ^5.5.0 => 5.5.0
    @mui/material: ^5.5.0 => 5.5.0
    @mui/private-theming:  5.4.4
    @mui/styled-engine:  5.4.4
    @mui/styled-engine-sc: ^5.4.2 => 5.4.2
    @mui/system:  5.5.0
    @mui/types:  7.1.2
    @mui/utils:  5.4.4
    @types/react: ^17.0.40 => 17.0.40
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    styled-components: ^5.3.3 => 5.3.3
    typescript: ^4.6.2 => 4.6.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Chukwu3mekacommented, Dec 14, 2022

What I did to fix this was to

//Option 1:

import AccessAlarmIcon from '@mui/icons-material/AccessAlarm';
import ThreeDRotation from '@mui/icons-material/ThreeDRotation';

//Option 2:

import { AccessAlarm, ThreeDRotation } from '@mui/icons-material';

Option 1, seeme to be the issue in TypeScript, import your desired icon using Option 2, this takes away the error.

Also, If need be, you can choose a diffr=erent name for your imports, such as

import { AccessAlarm as MUIAccessAlarmICON, ThreeDRotation } from '@mui/icons-material';

now you can use the AccessAlarm icon like so <MUIAccessAlarmICON/>

0reactions
Chukwu3mekacommented, Dec 14, 2022

Tags should include TypeScript

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find a declaration file for module 'material-ui/styles ...
Try npm install @types/material-ui/styles/MuiThemeProvider if it exists or add a new declaration (.d.ts) file containing declare module ...
Read more >
Could not find declaration file for module 'react' | bobbyhadz
The error "could not find declaration file for module 'react'" occurs when TypeScript cannot find the type declaration for a react-related module.
Read more >
@mui/icons-material - npm
This package provides the Google Material Icons converted to SvgIcon components. Installation. Install the package in your project directory ...
Read more >
Minimizing bundle size - Material UI - MUI
While importing directly in this manner doesn't use the exports in the main file of @mui/material , this file can serve as a...
Read more >
module not found: error: can't resolve '@mui/icons-material' in ...
Oct 25, 2021 ... FileDownload icon is added in v5, it does not exist in v4. You can search for v4 icons here....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found