buhrmi / vue-pouch

Live and reactive PouchDB bindings for Vuejs
164 stars 20 forks source link

Add TypeScript support and examples #21

Open rominf opened 5 years ago

rominf commented 5 years ago

I couldn't get it to work in Vue.js TypeScript project.

assemblethis commented 5 years ago

Nor could I. I'm digging into this issue now. I'm trying to use pouch in a Vue.js PWA/TypeScript project using the new Vue CLI 3.

I'll come back with some more details.

assemblethis commented 5 years ago

I've added a TypeScript example that's working for me. It's probably not great, but it's a start:

https://github.com/assemblethis/pouch-vue/blob/master/README.md

rominf commented 5 years ago

Nice, thank you! But ignoring tslint errors is not very good...

assemblethis commented 5 years ago

Are you referring to the @ts-ignore syntax:? I read the following article "Don’t let TypeScript slow you down" (https://medium.com/@vitalyb/dont-let-typescript-slow-you-down-92d394ec8c9f) and it suggested using the @ts-ignore syntax with third party libraries that don't natively support typescript since add-on packages can get out of date and cause further problems. It made an argument that: "If you’re using a library that natively supports TypeScript this shouldn’t concern you. If the library doesn’t, then just use it without types."

rominf commented 5 years ago

Yes, I'm referring to the @ts-ignore. I think I will use it as you wrote, but I'm waiting for TypeScript support :)

assemblethis commented 5 years ago

If you improve upon the example, please share. I'm new to TypeScript.

rominf commented 5 years ago

I'm new to TypeScript too :)

assemblethis commented 5 years ago

I switched over to the recommended fork of this project at https://github.com/MDSLKTR/pouch-vue

My TypeScript example still works with the fork. Some reason called pouch-vue now instead of vue-pouch.

I'm going to test out authentication this week. I'll let you know how it goes.

assemblethis commented 5 years ago

Two auth issues uncovered with the fork at https://github.com/MDSLKTR/pouch-vue

1) Closed: https://github.com/MDSLKTR/pouch-vue/issues/3 2) Open: https://github.com/MDSLKTR/pouch-vue/issues/4

So far so good, outlook is hopeful that auth will work as needed for my PWA project.

assemblethis commented 5 years ago

I'm contemplating creating an ES6 module for the fork and including typings for TS.

assemblethis commented 5 years ago

I've got a pull request to include typescript support for the pouch-vue project which is the successor to this project: https://github.com/MDSLKTR/pouch-vue/pull/9

It might have what you need.