vue-cookie-accept-decline icon indicating copy to clipboard operation
vue-cookie-accept-decline copied to clipboard

TypeScript Support

Open bradyemerson opened this issue 2 years ago • 2 comments

Following the example usage gives the following error: Could not find a declaration file for module 'vue-cookie-accept-decline'. './node_modules/vue-cookie-accept-decline/dist/vue-cookie-accept-decline.umd.js' implicitly has an 'any' type.

bradyemerson avatar May 22 '22 21:05 bradyemerson

Hey there - sorry this component does not support TypeScript out of the box.

What you could do is add a declaration file for it to get rid of the error. When you use it, it won't be type-safe, but at lease it won't error. Link on how to do that here. (It also mentions how to add some typing's for yourself.)

If I get some time, I may add TypeScript support to this project - but it's just tougher with the options API that this component was built with. I'm just super booked now, sorry.

johndatserakis avatar May 22 '22 22:05 johndatserakis

I'm using it in a VITE project having TS with no problem.

ascweb avatar May 26 '22 09:05 ascweb

any updates on this?

shidcordero avatar Sep 03 '23 11:09 shidcordero

@shidcordero Sorry, there are currently no plans to upgrade this component to use TypeScript directly.

I think the best way to use this component in a TypeScript project is to add a simple declarations file as mentioned above. You can then additionally add typing for the methods and variables you intend to use.

At that point, I could place that directly in this project for others to use. It wouldn't be a "real" TypeScript project, but it would be something.

Anyways, sorry for the trouble. I'm a huge TypeScript fan, it's just these older "options" API Vue libraries are tough to use with TypeScript, I've experienced.

johndatserakis avatar Sep 04 '23 15:09 johndatserakis