You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Angular templates are not type-safe in codesandbox)
Bug description
The core package has a SwiperEvents interface that defines callback functions for all possible events. The callback functions receive the Swiper reference as argument (and additional arguments in some cases).
The event emitter type is wrong. The event emitter replaces the callback function.
The current type results in an event emitter that emits a callback function instead of emitting the swiper reference directly.
The expected behavior works when running in the browser - we receive the swiper reference - but there is a TypeScript error because the type of the event emitter is wrong. With the current type our event handler method would receive a callback function that expects the swiper ref instead.
// ./demo.component.tsexportclassDemoComponent{demo(callback: (swiper: Swiper)=>void){// No TS error anymore// But a callback function would not make sense// and we actually receive the swiper reference directly and not a callback function}}
Current workaround is to use $any in the template:
Check that this is really a bug
Reproduction link
(Angular templates are not type-safe in codesandbox)
Bug description
The core package has a SwiperEvents interface that defines callback functions for all possible events. The callback functions receive the Swiper reference as argument (and additional arguments in some cases).
The Angular Swiper Component events are event emitters that use the SwiperEvents interface for the generic type.
The event emitter type is wrong. The event emitter replaces the callback function.
The current type results in an event emitter that emits a callback function instead of emitting the swiper reference directly.
Expected Behavior
The events should receive the swiper reference:
Actual Behavior
The expected behavior works when running in the browser - we receive the swiper reference - but there is a TypeScript error because the type of the event emitter is wrong. With the current type our event handler method would receive a callback function that expects the swiper ref instead.
Current workaround is to use
$any
in the template:Swiper version
7.0.5
Platform/Target and Browser Versions
macOS 11.5.2 / Brave 1.30.86 / TypeScript 4.3.5 / Angular 12.1.5
Validations
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: