-
Notifications
You must be signed in to change notification settings - Fork 11
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
watch scope #5
Comments
Thanks for filing this. This is limitation of TypeScript's inference schema. Watch's annotation cannot have the annotated class's information. Try this: @Watch<AddressComponent, string>(function(newVal, oldVal){
this.isNewAdress
}) |
I might change the Then the Watch decorator will be like vue-typescript. @Watch<MyComponent>('key')
myWatchMethod(newVal: string, oldVal: string) {
}
declare function Watch<V extends Vue>(key: keysof V): TypedProperty<(n: V[key], o: V[key]) => void> User still needs to annotate Component class and value type, but the watch scope is correctly set to the enclosing class. And watch property type is checked. |
New style watch in next branch |
Ok, next branch has it stringly typed like other libraries and vue, but I really like your strongly typed style, although it require additional annotation for "this" scope. |
Hi, it has a string API but everything is type checked! It's powered by typescript's new |
Really nice, when do you plan to merge? |
Probably after typescript officially released mapped types in stable. |
Watching on this issue... |
Shipped in 0.6.0! |
Probably not an issue but a caveat or I'm doing something wrong.
Inside watch function type of (this) is Vue so I have to do something like this or it won't compile:
also data and watched members must be initialized.
The text was updated successfully, but these errors were encountered: