johndatserakis / vue-cookie-accept-decline

👋 Show a banner with text, a decline button, and an accept button on your page. Remembers selection using cookies. Emits an event with current selection and on creation. Good for GDPR requirements.
https://johndatserakis.github.io/vue-cookie-accept-decline/
MIT License
147 stars 19 forks source link

TypeScript Support #19

Closed bradyemerson closed 1 year ago

bradyemerson commented 2 years ago

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.

johndatserakis commented 2 years ago

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.

ascweb commented 2 years ago

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

shidcordero commented 1 year ago

any updates on this?

johndatserakis commented 1 year ago

@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.