-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Type of watch() doesn't take first run into account #719
Comments
jacekkarczmarczyk
changed the title
Typing of watch() doesn't not take first run into account
Type of watch() doesn't take first run into account
Feb 13, 2020
Do you mean that this is supposed to be like this ? export type WatchCallback<T = any> = (
value: T,
oldValue: T | undefined,
onCleanup: CleanupRegistrator
) => any |
The problem with this solution is that |
Presumably you'd be checking that anyway with a type guard so Also if |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
3.0.0-alpha.4
Reproduction link
https://codepen.io/jkarczm/pen/ZEYgEXd?editors=0011
Steps to reproduce
watch
callback is defined ashttps://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/apiWatch.ts#L40-L44
It means that in this case it will be
However on the first run
oldVal
isundefined
.What is expected?
When I want to use
oldVal
, for exampleconsole.log(oldVal.length)
I should be warned by TS that the value can be undefinedWhat is actually happening?
No warning
The text was updated successfully, but these errors were encountered: