From bc61bce297bce8c38299671e9fe18f6a5b0fd77e Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Mon, 13 May 2024 15:55:29 +0800 Subject: [PATCH] fix(types): fixed SwiperModule, slideTo, effectInit types (#7428) * fix(types): fixed SwiperModule, slideTo, effectInit types * fix(types): Update shared.d.ts --- src/swiper-effect-utils.d.ts | 10 +++++----- src/types/shared.d.ts | 14 +++++++++++--- src/types/swiper-class.d.ts | 12 ++++++------ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/swiper-effect-utils.d.ts b/src/swiper-effect-utils.d.ts index 97f31c2ed..aaee39d97 100644 --- a/src/swiper-effect-utils.d.ts +++ b/src/swiper-effect-utils.d.ts @@ -5,13 +5,13 @@ declare const createShadow: (suffix?: string, slideEl: HTMLElement, side?: strin declare const effectInit: (params: { effect: string; swiper: Swiper; - on?: () => void; - setTranslate?: () => void; - setTransition?: () => void; + on: () => void; + setTranslate: () => void; + setTransition: (duration: number) => void; overwriteParams?: () => SwiperOptions; - perspective?: boolean; + perspective?: () => boolean; recreateShadows?: () => void; - getEffectParams?: () => any; + getEffectParams?: () => { slideShadows?: boolean }; }) => void; declare const effectTarget: (effectParams: any, slideEl: HTMLElement) => void; diff --git a/src/types/shared.d.ts b/src/types/shared.d.ts index 4c28f9654..821f71349 100644 --- a/src/types/shared.d.ts +++ b/src/types/shared.d.ts @@ -1,5 +1,13 @@ +import { Swiper } from './index.d.ts'; + export interface CSSSelector extends String {} -export interface SwiperModule { - name: string; -} +export type SwiperModule = (options: { + params: Swiper['params']; + swiper: Swiper; + extendParams: (obj: { [name: string]: any }) => void; + on: Swiper['on']; + once: Swiper['once']; + off: Swiper['off']; + emit: Swiper['emit']; +}) => void; diff --git a/src/types/swiper-class.d.ts b/src/types/swiper-class.d.ts index 11e521834..213916dc6 100644 --- a/src/types/swiper-class.d.ts +++ b/src/types/swiper-class.d.ts @@ -215,7 +215,7 @@ interface Swiper extends SwiperClass { * @param runCallbacks Set it to false (by default it is true) and transition will * not produce transition events. */ - slideNext(speed?: number, runCallbacks?: boolean): void; + slideNext(speed?: number, runCallbacks?: boolean): boolean; /** * Run transition to previous slide. @@ -224,7 +224,7 @@ interface Swiper extends SwiperClass { * @param runCallbacks Set it to false (by default it is true) and transition will * not produce transition events. */ - slidePrev(speed?: number, runCallbacks?: boolean): void; + slidePrev(speed?: number, runCallbacks?: boolean): boolean; /** * Run transition to the slide with index number equal to 'index' parameter for the @@ -235,7 +235,7 @@ interface Swiper extends SwiperClass { * @param runCallbacks Set it to false (by default it is true) and transition will * not produce transition events. */ - slideTo(index: number, speed?: number, runCallbacks?: boolean): void; + slideTo(index: number, speed?: number, runCallbacks?: boolean): boolean; /** * Does the same as .slideTo but for the case when used with enabled loop. So this @@ -246,7 +246,7 @@ interface Swiper extends SwiperClass { * @param runCallbacks Set it to false (by default it is true) and transition will * not produce transition events. */ - slideToLoop(index: number, speed?: number, runCallbacks?: boolean): void; + slideToLoop(index: number, speed?: number, runCallbacks?: boolean): Swiper; /** * Reset swiper position to currently active slide for the duration equal to 'speed' @@ -256,7 +256,7 @@ interface Swiper extends SwiperClass { * @param runCallbacks Set it to false (by default it is true) and transition will * not produce transition events. */ - slideReset(speed?: number, runCallbacks?: boolean): void; + slideReset(speed?: number, runCallbacks?: boolean): boolean; /** * Reset swiper position to closest slide/snap point for the duration equal to 'speed' parameter. @@ -265,7 +265,7 @@ interface Swiper extends SwiperClass { * @param runCallbacks Set it to false (by default it is true) and transition will * not produce transition events. */ - slideToClosest(speed?: number, runCallbacks?: boolean): void; + slideToClosest(speed?: number, runCallbacks?: boolean): boolean; /** * Get dynamically calculated amount of slides per view, useful only when slidesPerView set to `auto`