Skip to content

[@vue/compiler-sfc] "xxx" is a destructured prop and should not be passed directly to watch() #8017

@sqal

Description

@sqal

Vue version

3.3.0-alpha.6
3.3.0-alpha.7

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9kEtPwzAQhP/KyhdaKQ+kShxCW5UjF4R69sVNNiQQP1jb7aHKf8d2GxSVikMem/mcmZ0zezGmOHpkFVvbmnrjwKLzZssVQC+NJgdnsJ0YBn3aY5vBSbi6gxFa0hIewtEHriJca2Uj6y3SaxOADTTY9grfSRu7mIQK3rw8IMG4jKfCxV3rVe16rSKyx2+P1i2WcI46AIU4pKYJoBFOVLNEi2U2SUik6a42xke6zaMmPiWdGz9f9kl7LhKSQYiz2cYM6T8RWZeXukJRYXAozSAcbtfl7ytXLGOXCnMpTPFptQo1p0X4VbCcVdNqnIUy48xZ55yxVVl6Zb4+ilrLche0krxyvcS80XK3KlbFYy4G04niqWx66+ZygVbmB9Kn0Hkw5uzaQ/Iow8cjUk6oGiSkfz1v2Hu+N8gf72v3Ixt/AMad00k=

Steps to reproduce

Open reproduction url and select vue version 3.3.0-alpha.6 or alpha.7 (for some reason SFC Playground doesn't remember the selected version)

What is expected?

Should compile vue component without error since all code is valid.

What is actually happening?

Compiler throws an error:

Error: [@vue/compiler-sfc] "error" is a destructured prop and cannot be directly watched. Use a getter () => error instead.

App.vue
13 |    const { error } = useRequest();
14 |  
15 |    watch(error, () => {
   |          ^^^^^
16 |  
17 |    });

But if you remove const { userId } = defineProps({ userId: Number }) then the error is gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions