Skip to content
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 should type old value as possibly undefined #253

Closed
zippaaa opened this issue Feb 15, 2020 · 6 comments
Closed

watch should type old value as possibly undefined #253

zippaaa opened this issue Feb 15, 2020 · 6 comments
Labels
bug Something isn't working good first issue Good for newcomers has PR

Comments

@zippaaa
Copy link

zippaaa commented Feb 15, 2020

Docs: https://vue-composition-api-rfc.netlify.com/api.html#watch (Watching Multiple Sources)
Test:

setup() {
    const test = ref({a: 0, b: 0}); //reactive({a: 0, b: 0});
    watch(
        () => [test.a, test.b],
        ([newA, newB], [oldA, oldB]) => console.log(newA, oldA, newB, oldB)
    );
}

Result
изображение

Test:

setup() {
    const test = reactive({a: 0, b: 0});
    watch(
        () => [test.a, test.b],
        (newValues, oldValues) => console.log(newValues, oldValues)
    );
}

Result:
Array[0, 0], undefined

@posva
Copy link
Member

posva commented Feb 15, 2020

On the first run, the old value is undefined, so the error makes sense.
However, the typings are not right (vuejs/core#719) and they should follow the same fix as vuejs/core@c6a9787

@posva posva added bug Something isn't working good first issue Good for newcomers labels Feb 15, 2020
@colinscz
Copy link

colinscz commented Mar 3, 2020

@posva do I get it right, that more or less the same fixes as you mentioned for vue-next have to be applied to the corresponding files here?

I would like to work on this. Let me know if this is still ready to take :)

@posva posva changed the title Error in "Watching Multiple Sources" watch should type old value as possibly undefined Mar 4, 2020
@posva
Copy link
Member

posva commented Mar 4, 2020

@cnschwarz This is still up! I believe the fix is indeed very similar to the fix on vue-next

@colinscz
Copy link

colinscz commented Mar 4, 2020

@posva awesome, that is what I thought. I started with some of the changes yesterday. I will reach out if I have specific questions :)

@pikax
Copy link
Member

pikax commented Jun 10, 2020

Can you check if this is still a problem on ^0.6.1?

@antfu
Copy link
Member

antfu commented Jun 21, 2020

Closing this for now. If you still facing the issue, feel free to reopen it.

@antfu antfu closed this as completed Jun 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers has PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants