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

return type of unref includes ShallowRef if the passed type is ShallowRef | ComputedRef | MaybeRef #11356

Closed
NicolaiHorlacher opened this issue Jul 14, 2024 · 0 comments · Fixed by #11360

Comments

@NicolaiHorlacher
Copy link

Vue version

3.4.31

Link to minimal reproduction

https://play.vuejs.org/#eNqtU9tq4zAQ/ZVBL91CcMlmn7LewO7Sh13ohTb0SVBcZ+K4lSUhjdKU1P/ekVynpjdaKMZCmhnpnDOXrfhtbbYOKKYi96WrLYFHChZUoatfUpCXYiZ13VjjCOjOImzhfFUoZW7PcDmCv6axgXCRDkfF3RWmHS/QwtKZBvb4+b2fuze2ELR75pU6fsugS6qN7gLm6Gn8jXBD0wFg7snVuprB/RB5YO0p9Kb9KXQ72EoN4Fice0RIj+8zs/Z19O/voX8hzuSTKj8IlR90BeXy8YGwsaog5BNAvhrPuioQ4/v8gM/xwiBIjLj2pdHLusquvdHcIAlNipIZ1QrdiY0yuD+mHY/oSwL+Jxu5gKPeXq6wvHnFfu030SbFqUOPbo1S7HxUuAqpcx+eH7OwgbMxi6A4+h3nGXqjQuTYhf0JesG0B3GJ7b/UlpzNuT/cEGrfi4pEY2Sb4qXgRo3FeEv6E91J9iPd4ypwFpWpMvKcvk/O0LPxcYMBInNRqIAvI+K/6y8GnnNevnaEGGDXcY80+p5jVxsX1ny5RhfzyKo5GdlkLNoHV8KK9A==

Steps to reproduce

unref and toValue resolve the type incorrectly if the passed type is ShallowRef | ComputedRef | MaybeRef.

What is expected?

The return type of the text function should be string.

function test(text: ShallowRef<string> | ComputedRef<string> | MaybeRef<string>) {
  return unref(text);
}

What is actually happening?

But it is string | ShallowRef<string> instead.

System Info

Typescript 5.5.3

Any additional comments?

function test(text: ShallowRef<string> | MaybeRef<string>) {
  return unref(text);
}

and

function test(text: ShallowRef<string> | ComputedRef<string>) {
  return unref(text);
}

have the only string as return type as expected.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant