Closed ben4d85 closed 1 year ago
I've got the same issue. Did you manage to find a way to fix it?
I've got the same issue. Did you manage to find a way to fix it?
Please check this PR: https://github.com/nolimits4web/swiper/pull/6626 You need to change exports in swiperjs's package.json. I tried and it's working fine now.
Solution:
declare module 'swiper'
Thank you so much @salvadoregunacci for the solution. But how should I fix the bug when deploying a website ? I am getting a build error of the same on vercel.
@paras1729kori
You can try this solution:
in your tsconfig
file add the following code
"compilerOptions": {
"noImplicitAny": false
}
P.S it's not the best option, but it might come in handy
Thanks a bunch @salvadoregunacci. It worked.
It helps for me: "strict": true -> "strict": false
in your tsconfig.json
Got same error today while migrating nextjs project to esm. tsconfig moduleResolution = bundler
Im just copy-pasted declaraions from swiper.d.ts
into my project's global.d.ts
declare module 'swiper' {
import Swiper from './types/swiper-class'
import { SwiperOptions } from './types/swiper-options'
import { SwiperModule } from './types/shared'
declare const A11y: SwiperModule
declare const Autoplay: SwiperModule
declare const Controller: SwiperModule
declare const EffectCoverflow: SwiperModule
declare const EffectCube: SwiperModule
declare const EffectFade: SwiperModule
declare const EffectFlip: SwiperModule
declare const EffectCreative: SwiperModule
declare const EffectCards: SwiperModule
declare const HashNavigation: SwiperModule
declare const History: SwiperModule
declare const Keyboard: SwiperModule
declare const Lazy: SwiperModule
declare const Mousewheel: SwiperModule
declare const Navigation: SwiperModule
declare const Pagination: SwiperModule
declare const Parallax: SwiperModule
declare const Scrollbar: SwiperModule
declare const Thumbs: SwiperModule
declare const Virtual: SwiperModule
declare const Zoom: SwiperModule
declare const FreeMode: SwiperModule
declare const Grid: SwiperModule
declare const Manipulation: SwiperModule
export default Swiper
export {
Swiper,
SwiperOptions,
A11y,
Autoplay,
Controller,
EffectCoverflow,
EffectCube,
EffectFade,
EffectFlip,
EffectCreative,
EffectCards,
HashNavigation,
History,
Keyboard,
Lazy,
Mousewheel,
Navigation,
Pagination,
Parallax,
Scrollbar,
Thumbs,
Virtual,
Zoom,
FreeMode,
Grid,
Manipulation,
}
}
what worked for me in Next.js 13 was using swiper instead of swiper/module that was written in the documentation. import { Navigation, Pagination, Scrollbar, A11y } from "swiper";
if use next.js, you can use this:
import { Navigation, Pagination } from 'swiper';
Check that this is really a bug
Reproduction link
n/a
Bug description
Fresh installation of Vite with React and TypeScript using Swiper version 9.3.2. I am getting the following error:
Here's my code:
Expected Behavior
Types should just work without error.
Actual Behavior
Type error.
Swiper version
9.3.2
Platform/Target and Browser Versions
n/a
Validations
Would you like to open a PR for this bug?