swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Typescript error with `SwiperSlideProps` interface and `@types/react@18`

Open francescocaveglia opened this issue 2 years ago • 2 comments

Check that this is really a bug

  • [X] I confirm

Reproduction link

https://github.com/francescocaveglia/swiper-test

Bug description

The SwiperSlideProps interface is not compatible with @types/react@18

(the error is solved with "skipLibCheck": true but I would prefer to avoid it)

Expected Behavior

no typescript error

Actual Behavior

tsc command returns this error:

error TS2430: Interface 'SwiperSlideProps' incorrectly extends interface 'HTMLAttributes<HTMLElement>'.
  Types of property 'children' are incompatible.
    Type 'ReactNode | ((slideData: SlideData) => ReactNode)' is not assignable to type 'ReactNode'.
      Type '(slideData: SlideData) => ReactNode' is not assignable to type 'ReactNode'.

427 interface SwiperSlideProps {

Swiper version

8.2.4

Platform/Target and Browser Versions

Node

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the docs.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • [X] Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • [ ] I'm willing to open a PR

francescocaveglia avatar Jun 14 '22 18:06 francescocaveglia

Seeing this as well.

  Type 'ComponentClass<any, any>' is not assignable to type 'ReactNode | ((slideData: SlideData) => ReactNode)'.

edkimmel avatar Jul 15 '22 17:07 edkimmel

Is it solved??

sangmin802 avatar Sep 16 '22 03:09 sangmin802

I ended up having to downgrade to React 17 to resolve this.

dschueller-cs avatar Oct 28 '22 22:10 dschueller-cs