sumcumo / vue-datepicker

A datepicker Vue component. Compatible with Vue 2.x.
https://sumcumo.github.io/vue-datepicker/
Apache License 2.0
75 stars 22 forks source link

Typescript migration #146

Closed mst101 closed 2 years ago

mst101 commented 2 years ago

@MrWook - I've rebased this branch off the latest master branch into which I also merged in my latest PR #145 (although I look forward to your review of that...) and have set about converting everything to TypeScript.

It's been a good exercise in applying my nascent TypeScript skills, although I have resorted to adding // @ts-ignore in a few places where I didn't know what to do.

Now, when I run npm run build, I am no longer getting the above error, but this instead:

[!] (plugin babel) SyntaxError: /home/mark/repos/vue-datepicker/src/components/Datepicker.vue?rollup-plugin-vue=script.ts: Support for the experimental syntax 'decorators-legacy' isn't currently enabled (157:1):

  155 | import Popup from './Popup.vue'
  156 |
> 157 | @Component({
      | ^
  158 |   components: {
  159 |     DateInput,
  160 |     PickerDay,
src/components/Datepicker.vue?rollup-plugin-vue=script.ts (157:0)
SyntaxError: /home/mark/repos/vue-datepicker/src/components/Datepicker.vue?rollup-plugin-vue=script.ts: Support for the experimental syntax 'decorators-legacy' isn't currently enabled (157:1):

One stackoverflow post suggested I should install the @babel/plugin-proposal-decorators package and add ["@babel/plugin-proposal-decorators", { "legacy": true }] to the plugins section of the .babelrc file.

I have tried this, however, the error persists. So basically, I'm stuck - and would appreciate some help! :-)

mst101 commented 2 years ago

Sorry, I was expecting this to follow on from #127... but I must have done something wrong :-|

Anyway, hopefully you (or someone else?) can see the code and help me understand why I'm getting those errors?

MrWook commented 2 years ago

Hey i will check it out 👍

Edit: This is a real pain in the ass 🤔 I got somewhere with changing to another rollup plugin and pushed it into my branch. I'm not so sure about the class based components anymore :( I really love it but it will increase the bundle size for some personal flavor 🤔 Maybe we should directly move to vue3

mst101 commented 2 years ago

Thanks for having checked this out. Glad it wasn't only me banging my head against the wall!

I'll close this and do what you suggest... but can we please move to Vite first ;-). I see what you've started for the build in vue3-support and have managed to get a dev environment set up in vite. Still need to have a look at vitetest as a replacement for jest...