-
Notifications
You must be signed in to change notification settings - Fork 434
Why is 'vue-property-decorator' library not a part of vue-class-component? #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Because when we use |
Interesting- I am using babel/esnext so should i not use the library?
What issues are there?
Maybe there should be a warning on the readme of the project.
…On 24 December 2016 at 16:21, katashin ***@***.***> wrote:
Because when we use prop decorator with Babel, it causes some problems
while it really works well with TypeScript.
As vue-class-component also supports Babel users, unfortunately we cannot
include it in this library.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#50 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC8aNakN5d62PuxOQG3UU_FpZg32D4Ibks5rLKu9gaJpZM4LVKUd>
.
--
Tony Polinelli
|
The issue is caused by the difference of behavior between babel-transform-decorators-legacy and TypeScript's decorators. For example in the following case: @Component
class MyComp extends Vue {
foo = 'foo + ' + this.bar
@prop(String) bar
baz = 'baz + ' + this.bar
}
const c = new MyComp({
propsData: { bar: 'bar' }
}) In TypeScript, this works as expected This is because Babel decorators will initialize a decorated property as |
Any chance this scenario could change with improved decorators support in upcoming Babel 7? |
Just curious if this results in odd behaviour with Storybook? |
@davidm-public Are you even able to get storybook working with vue-class-component? I'm struggling with it. |
FYI: @JessicaSachs @davidm-public I just added the file, as in the documentation, and voila. import Vue from 'vue'
declare module 'vue/types/options' {
interface ComponentOptions<V extends Vue> {
__doc?: string
}
}
storiesOf('MyComponent', module)
.addDecorator(withDocs(MyComponent.options.__docs))
... |
To write vue components using classes, we need to be able to do things such as 'watch' values. It makes sense to me that this should be a part of the same repo?
Looking at vue-property-decorator, since it can export Componenti guess we have this functionality already, just under a different (less appropriate library name)
import { Component, prop, watch } from 'vue-property-decorator';
should be
import { Component, prop, watch } from 'vue-class-component';
or
import { prop, watch }, Component from 'vue-class-component';
The text was updated successfully, but these errors were encountered: