vue-shepherd
vue-shepherd copied to clipboard
Would be nice to add type declarations for typescript
I got it working by adding a .d.ts containing just declare module vue-shepherd but it would be good to include a more complete type declaration for typescript users.
Hi @garyo, I totally agree! We have the types in the main Shepherd repo here https://github.com/shipshapecode/shepherd/tree/master/src/types
Can those be imported and used?
I would think so, though you'll still need to add types for the things you add to the Vue prototype. I'm just getting started with vue-shepherd (migrating from vue-tour) and I'm typing my steps using the Shepherd types; that works fine.
@garyo I don't think we added anything to this Vue wrapper really. I had plans to add more features, but I've been busy with other things. If you'd like to add imports of the types here and/or other features, we would love the help!
I'm realizing the same thing -- I think it's trivial to just use shepherd.js in my Vue app, no real need for this wrapper. I just made a Tour.vue that imports shepherd.js directly.
You could also add this to your declaration file to make use of the injected function as intended, with types from shepherd.js
import Shepherd from 'shepherd.js'
declare module 'vue-shepherd'
declare module 'vue/types/vue' {
// this.$myInjectedFunction inside Vue components
interface Vue {
$shepherd: (...args: any[]) => Shepherd.Tour
}
}
@jim-toth perhaps we should use that as the types for this repo? I would definitely accept a PR adding a types file.
if i use declare module 'vue-shepherd'
i get error ts2665: invalid module name in augmentation. Module 'vue-shepherd' resolves to an untyped module at '...node_modules/vue-shepherd/dist/vue-shepherd.common.js', which cannot be augmented
@manuel-84 sorry to hear that. As mentioned above, I would accept a PR to fix TS. The types exist in Shepherd itself.
For the composition api the following declaration file works really well:
import Shepherd from 'shepherd.js'
declare module 'vue-shepherd' {
export function useShepherd(...args: Array<Shepherd.Tour.TourOptions>): Shepherd.Tour
}
If anyone would like to open a PR adding types, I would gladly accept it!