-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Comments
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 |
@johnsoncodehk do you think the bug is specifically in |
The problem seems to be the inconsistency between the unref behavior of defineComponent setup return and UnwrapRef. |
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 stillRef<{ 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.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?
The text was updated successfully, but these errors were encountered: