euvl / v-clipboard

Simple and powerful clipboard plugin for Vue.js 2 and 3
MIT License
522 stars 39 forks source link

No type definition for TypeScript users #5

Closed francoismassart closed 5 years ago

francoismassart commented 5 years ago

Working on a vue.js project made with TypeScript, I was not able to compile because of the lack of a definition file.

Here is how I worked round this but I'd appreciate a real definition file with all its benefits 👍

In my shims-vue.d.ts file I added:

declare module 'v-clipboard' {
  import { PluginObject } from 'vue';
  const vClipboard: PluginObject;
  export default vClipboard;
}
euvl commented 5 years ago

Can you create a PR with it?

mika76 commented 5 years ago

This didn't work for me - says that PluginObject needs a type - if I use PluginObject<{}> it compiles but it still does not compile with this.$clipboard...

francoismassart commented 5 years ago

Thanks it works on my project.

@mika76 did you try it ? It should work

mika76 commented 5 years ago

Hey @francoismassart sorry I didn't see the update - I will give it a go and let you know...

Tsessebe commented 5 years ago

in main.ts

import Clipboard from 'v-clipboard';
Vue.use(Clipboard);

When trying to use -> this.$clipboard(value);

Property '$clipboard' does not exist on type 'myComponent'.

dependency in package.json -> "v-clipboard": "^2.2.2",