Error using @ant-design/icons with TypeScript
See original GitHub issueLately I have problem using icons with @ant-design/icons. It seems like this issue has been there for a while, but only a few people have encountered it.
I tried the solution @lukasluecke suggested in #304, which is to install @types/react and @types/react-dom directly to the project. But it does work for my situation. Any other suggestion on solving
package.json
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.29",
"@fortawesome/free-solid-svg-icons": "^5.13.1",
"@fortawesome/react-fontawesome": "^0.1.11",
"@microsoft/sp-core-library": "1.10.0",
"@microsoft/sp-lodash-subset": "1.10.0",
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
"@microsoft/sp-property-pane": "1.10.0",
"@microsoft/sp-webpart-base": "1.10.0",
"@pnp/common": "^2.0.6",
"@pnp/graph": "^2.0.6",
"@pnp/logging": "^2.0.6",
"@pnp/odata": "^2.0.6",
"@pnp/sp": "^2.0.6",
"@pnp/telemetry-js": "^2.0.0",
"@reduxjs/toolkit": "^1.4.0",
"@types/es6-promise": "0.0.33",
"@types/react": "16.8.8",
"@types/react-dom": "16.8.3",
"@types/webpack-env": "1.13.1",
"antd": "^4.4.1",
"office-ui-fabric-react": "6.189.2",
"react": "16.8.5",
"react-dom": "16.8.5",
"react-highlight-words": "^0.16.0",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"
},
"resolutions": {
"@types/react": "16.8.8"
},
"devDependencies": {
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
"@microsoft/rush-stack-compiler-3.7": "^0.5.2",
"@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-tslint-rules": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.10.0",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
"ajv": "~5.2.2",
"gulp": "^3.9.1"
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11
Top Results From Across the Web
Typescript does not recognize ant design prop for rendering icon
I am new in typescript and Ant design. I have a password input and want to have an open/invisible Icon inside input element....
Read more >Icon - Ant Design
Import icons from @ant-design/icons , component name of icons with different theme is the icon name suffixed by the theme name. Specify the...
Read more >@ant-design/icons - npm
Start using @ant-design/icons in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
Read more >Import quickfix not given for Ant Design icons : WEB-44118
What steps will reproduce the problem? ... What is the expected result? Import should be shown. What happens instead? No import suggestion. The...
Read more >@ant-design/icons | Yarn - Package Manager
You can import it directly or destructure from @ant-design/icons when tree-shaking enabled.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lfpkkk it doesn’t work as followed your steps. I just use the icon with default props, but it warned.
is there any other ways to fix?
@linonetwo After weeks of research, I finally noticed that @types/react and @types/react-dom are listed under devDependencies in package.json by default, but in my project they were moved under dependencies somehow. So my final solution to this issue is to move them back to devDependencies, of course with the latest version number, and then reinstall the whole node modules by npm intall.
Hope this is helpful for solving your issue as well.