Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using @ant-design/icons with TypeScript #354

Closed
lfpkkk opened this issue Aug 19, 2020 · 17 comments
Closed

Error using @ant-design/icons with TypeScript #354

lfpkkk opened this issue Aug 19, 2020 · 17 comments

Comments

@lfpkkk
Copy link

lfpkkk commented Aug 19, 2020

image

Lately 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"
  }
@linonetwo
Copy link

Same on me

Type '{ className: string; }' is missing the following properties from type 'Pick<AntdIconProps

@lfpkkk
Copy link
Author

lfpkkk commented Sep 2, 2020

@chenshuai2144 @afc163 could you guys help me on this issue? have been struggling for weeks. I installed @types/[email protected] and @types/[email protected] but doesn't work.

@lfpkkk
Copy link
Author

lfpkkk commented Sep 2, 2020

@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.
image

Hope this is helpful for solving your issue as well.

@antstudio-git
Copy link

@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?

image
image

@dexter0201
Copy link

Same issue. Any update on this?

@jiyarong
Copy link

jiyarong commented Jun 2, 2021

same here

@Clarkkkk
Copy link

Clarkkkk commented Jun 9, 2021

It may have something to do with the versions of @types/react and @types/react-dom. It works for me with @types/[email protected] and @types/[email protected]

@neonick
Copy link

neonick commented Jul 28, 2021

Doesn't work with

"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",

@sudarshan070
Copy link

Same issue with
"@types/react": "^16.9.53", "@types/react-dom": "^16.9.8",

@demigodliu
Copy link

Same Problem:
"react": "^18.1.0"
"react-dom": "^18.1.0"

@eminoda
Copy link

eminoda commented Dec 5, 2022

#483 (comment)

@Pankajsyal1
Copy link

<CaretRightOutlined rev={""} rotate={isActive ? 90 : 0} />}> add rev property it will fix

@PWbio
Copy link

PWbio commented Sep 13, 2023

"react": "17.0.2",
"react-dom": "17.0.2",
"@types/react": "17.0.65", // upgrade
"@types/react-dom": "17.0.20", // upgrade
"antd": "^5.9.0",

Upgrade types version works for me

@afc163 afc163 closed this as completed Sep 13, 2023
@dizefurkan
Copy link

I have already upgrade versions but still get error

Check out my comment for details; screenshots
#483 (comment)

@sohail-amini
Copy link

Add these two:
onPointerEnterCapture={undefined} onPointerLeaveCapture={undefined}
image

@datawookie
Copy link

datawookie commented Apr 20, 2024

I was getting same error:

src/components/sidebar/sidebar.tsx:342:24 - error TS2739: Type '{}' is missing the following properties from
type 'Pick<AntdIconProps, "type" | "children" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style"
| "summary" | "title" | "pattern" | "value" | "id" | "src" | ... 348 more ... | "twoToneColor">':
onPointerEnterCapture, onPointerLeaveCapture

342           expandIcon={<RightOutlined />}

and the solution from @sohail-amini worked for me!

@wctiger
Copy link

wctiger commented Jul 18, 2024

See ant-design/ant-design#47886 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests