vue-property-decorator
vue-property-decorator copied to clipboard
feat: Added @Setup() decorator for usage with the composition API.
feat: Added @Setup() decorator for usage with the composition API.
Includes associated test suite for expected output.
Includes upgrades to the underlying "vue" and "vue-template-compiler" package versions => 2.7.5.
What is the use of this particular decorator?
Although this decorator mixes two paradigms, e.g., class-based-components and the composition API, this may help teams to migrate from class-based-components by allowing usage of the composition API within class based components. I think there could be a strong need for this as teams migrate legacy Vue 2 typescript stacks to Vue 3.
👍
@kaorun343 Any thoughts on this PR?
I think writing setup function in Component decorator is enough and the new decorator is not needed.
I think writing the setup function in the Component decorator is enough and the new decorator is not needed.
Don't you think having the setup in components declaration in the class leaves unnecessary entropy (especially for huge projects who have to migrate to composition gradually) between code inside/outside setup:

I dunno, but I feel the proposed idea is better. also, it's very unusual at least for me to have the setup inside the Component decorator, then the class declaration followed by the class code.
You can use registerHooks instead of this @Setup decorator.
https://class-component.vuejs.org/guide/additional-hooks.html
Also, allowing setup function as a n instance method may causes invalid this access. This is why @Filter decorator is not included to this library.