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

swiper/vue missing type declarations #3916

Closed
1 of 3 tasks
honzabilek4 opened this issue Nov 3, 2020 · 11 comments · Fixed by #4707
Closed
1 of 3 tasks

swiper/vue missing type declarations #3916

honzabilek4 opened this issue Nov 3, 2020 · 11 comments · Fixed by #4707

Comments

@honzabilek4
Copy link

This is a (multiple allowed):

  • bug
  • enhancement
  • feature-discussion (RFC)

I see that Swiper has already types for swiper/react component included. I would be really cool to add type definitions for swiper/vue component as well. This would allow us to integrate swiper in vue.js projects with typescript easier.

Screenshot 2020-11-03 at 8 35 50

I'm willing to work on this feature with a little guidance from maintainers.

  • Swiper Version: v3.6.5
  • Platform/Target and Browser Versions: Typescript
@GerryWilko
Copy link

If this helps anyone I wrote a skeleton typings file to get it to atleast work with a typescript vue project:

swiper-t.d.ts

declare module 'swiper/vue' {
  import _Vue from 'vue';

  export class Swiper extends _Vue {}

  export class SwiperSlide extends _Vue {}
}

@vltansky vltansky added the Vue label Jan 21, 2021
@vltansky
Copy link
Collaborator

@GerryWilko you're welcome to contribute :)

@GerryWilko
Copy link

@vltansky Apologies I meant to come back to this and create a PR. I just dropped this in as a comment temporarily. I'll raise a PR tomorrow! 😀

@GerryWilko
Copy link

I've raised a PR for this file. I did a bit of testing and it didn't seem to affect the React typings.

@NabilFr
Copy link

NabilFr commented Apr 5, 2021

In the meantime, how we can use swiper in vue 3/typescript project?

@david50407
Copy link

@NabilFr use this shim:

declare module 'swiper/vue' {
  import { DefineComponent } from 'vue'

  export const Swiper: DefineComponent<any, any, any>
  export const SwiperSlide: DefineComponent<any, any, any>
}

@giuliano-macedo
Copy link

@david50407 I think you should make a PR with this shim 👀

@david50407
Copy link

@giuliano-oliveira this shim only provides simple definition of swiper/vue module without details (like props, slots, etc)
IMO, this shim is a workaround, this project still need full type definitions for Vue.

@nicojmb
Copy link

nicojmb commented May 20, 2021

Please, add full typscript support on vue in future releases.

@heyhippari
Copy link
Contributor

The proper (i.e. more maintainable) way to do this would probably be to convert the component to TypeScript.

Having separate, manually written typings is a recipe for disaster in the long run, imo.

I'd be willing to work on the conversion, if the maintainers are okay with it. I'll do some preliminary exploration on my end, based on how the Angular component builds itself, and report back once I have something.

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

Successfully merging a pull request may close this issue.

10 participants