vue-datepicker icon indicating copy to clipboard operation
vue-datepicker copied to clipboard

Typescript migration

Open MrWook opened this issue 3 years ago • 3 comments

Let's migrate to typescript

  • [x] add typescript setup

  • [ ] move all components to typescript

  • [ ] move all js files to typescript

  • [ ] resolve build and serve script for typescript

MrWook avatar Aug 16 '21 13:08 MrWook

@MrWook - thanks for starting this off. I'm pretty buy this week and next, but I've had a quick glance at it and have a couple of initial questions:

  1. What level of browser support are we developing to? I noticed your tsconfig.json file was aimed at es2018 - is that correct?
  2. Is there a particular reason why you've switched to class-based components? It's just that I read that Evan You had abandoned the proposal to use these in Vue 3.

Thanks

mst101 avatar Aug 25 '21 12:08 mst101

Hey @mst101

  1. Yes that is correct typescript just compiles the typescript into js in the vue/ts files after that the vue compiler parses the vue files into js and at last babel compile everything into legacy browser formats
  2. Thats because vue 2.x.x has a poor typescript support but with the class-based approach it supports everything

MrWook avatar Aug 26 '21 09:08 MrWook

@MrWook - I've just revisited the Typescript course I took last year and now my head is full, once again, with generics and decorator functions!

I can see where you're going with the above code, but when I run npm run build, in its current form the build.js file is failing on the babel plugin:

[!] (plugin babel) SyntaxError: /home/mark/repos/vue-datepicker/src/components/PickerCells.vue?rollup-plugin-vue=script.ts: Unexpected token, expected "," (18:37)

  16 | import { Component, Prop } from 'vue-property-decorator'
  17 |
> 18 | const showEdgeDatesValidator = (value: any): boolean => {
     |                                      ^
  19 |   return ['day', 'month', 'year'].includes(value)
  20 | }
  21 |
src/components/PickerCells.vue?rollup-plugin-vue=script.ts (18:37)

It seems like the typescript is not being converted to javascript by the time it reaches the babel transpiler...

Any chance you can help me get over this little hump?

Thanks :-)

mst101 avatar May 06 '22 09:05 mst101