Subscribe on changes!

Composables with Typescript can't be used without destructuring

avatar
Apr 27th 2023

Vue version

3.2.47

Link to minimal reproduction

https://play.vuejs.org/#eNp9UsFuwjAM/RWrF0BCVFxZQYKdd9m5l1BcyJQ6UeKyTVX/fU47SltNO+Rg5/nl+b00ydG5zb3GZJdkofDaMQTk2oFRdN3nCYc8OeSkK2c9Q+NRFazv2ELpbQULmVw8b6EO+Pb9aqUM6mxwDeMKHkObtBiaGw5CkFOaAt8QCL8YjCYEHUABh4jUBj2g99ZD0FQgPFQsV1DTp1dOsMaA89ahZ40BNHV09vyBBedUWAoM1UjMbipt/+Sc7bBcrV5yytLeHLFCCsbKGcUoFUB22x6aZkK+iUqO0LZZKpf/gU5PUJYOtMk6mTgk4QwWeyzX8I7l4GYfQS7OdQhNjL5U4tJkwSaq6GTt4nR2ttagooPs1vdPfZ/q6ow+ttsRaVmTmGNpHvByNfOxe0ayjKHMM2EbxUtUAUJ9vWJgvDyCutiirpBYxVciR5/YH4K7qMplqUzAmMwYOt3hF7ntUfF4+dmexMSOd93PQBuXTdofWE8Vlw==

Steps to reproduce

With a Typescript compiler set up run the code snippet provided in SFC Playground.

What is expected?

Be able to follow conventions mentioned in the documentation here.

What is actually happening?

Cannot follow conventions since the code generates typing errors.

System Info

No response

Any additional comments?

No response

avatar
Apr 28th 2023

This is not a bug. When you wrap the return type with reactive, the properties are unwrapped and are no longer refs. The type error you are seeing is expected behavior.