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

Union types are not unwrapped properly #9903

Closed
jods4 opened this issue Dec 22, 2023 · 3 comments · Fixed by #9909
Closed

Union types are not unwrapped properly #9903

jods4 opened this issue Dec 22, 2023 · 3 comments · Fixed by #9909

Comments

@jods4
Copy link
Contributor

jods4 commented Dec 22, 2023

Vue version

3.313

Link to minimal reproduction

https://play.vuejs.org/#eNp9UctOwzAQ/JWVL7RSSUEVl5CmgqoHkFpQgZsvUbp5FMe27E0fivLv2KkaioR6seyd2fHMbsOetA52NbKQRTY1pSawSLUGkch8yhlZzmIuy0orQ9DAl9ybRK8xG4Hxh7tBC5lRFdw4mRsuuUyVtASVzWEKy4SKwCRyo6rBEGK4u32AmW8dNCCTCkPg7Kg4g3YIIchaiEcvQUeNsOwU+h8jX1SZF44dKRqf/Dp37kFYaZEQuhdAVNzHTeOJs8B/EgiUORXQttHYQb73gs9GLqXznJV5sLVKulE0XoWzVFW6FGjeNJUuE2chdIjHEiHU/rWrkalxdK6nBabf/9S39uBrnL0btGh2yFmPUWJypBO8+Fjhwd17sFKbWjj2FXCNVonaezzRnmu5cbYveJ3bl26Jpcw/7eJAKO051B+jlkyZ0sptYu6j9ASPtx2LM7fp+ZXZ/OaZBJOuj8uWtT+kU81Z

Steps to reproduce

Create a type that is the union of a Ref of a non-primitive type and null, e.g. type X = Ref<{ name: string }> | null.

What is expected?

UnwrapRef<X> should be { name: string } | null.

What is actually happening?

Well... in TS script block it looks like UnwrapRef<X> is right, but when looked at inside the template block, it's still Ref<{ name: string }> | null. (see repro link)

As a consequence, using x in template (where refs are unwrapped automatically) fails type-checking as TS doesn't see the right type.
image

System Info

See repro in Vue SFC Playground.

Any additional comments?

This is the same issue as #3990 which was fixed. Maybe it regressed in a later release?

@LinusBorg
Copy link
Member

Since it works fine in the script block and only fails in the template, this doesn't seem to be a regression of #3990, I'd rather think this is a bug in vue-language-tools

@jods4
Copy link
Contributor Author

jods4 commented Dec 22, 2023

@johnsoncodehk do you think the bug is specifically in vue-language-tools?
I can re-create the issue there but there was a bit of back-and-forth at #3990 time so I'd like to be sure.

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.

3 participants