vue-datepicker
vue-datepicker copied to clipboard
Typescript migration
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 - 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:
- What level of browser support are we developing to? I noticed your
tsconfig.json
file was aimed ates2018
- is that correct? - 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
Hey @mst101
- 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
- Thats because vue 2.x.x has a poor typescript support but with the class-based approach it supports everything
@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 :-)