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

fix(types): toRefs should not do any ref unwrapping #4966

Merged

Conversation

JensDll
Copy link
Contributor

@JensDll JensDll commented Nov 18, 2021

The ToRefs type should not do any ref unwrapping. In #4734 this was also changed for ToRef but was forgotten in ToRefs.

Sandbox link to reproduction

I also grouped together some of the tests for toRef and toRefs in ref.test-d.ts.

// #2687: somehow using ToRef<T[K]> here turns the resulting type into
// a union of multiple Ref<*> types instead of a single Ref<* | *> type.
[K in keyof T]: T[K] extends Ref ? T[K] : Ref<UnwrapRef<T[K]>>
[K in keyof T]: ToRef<T[K]>
}
Copy link
Contributor Author

@JensDll JensDll Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this was added in e315d84 the type for ToRef looked different, which is why doing ToRef only is fine again.

Related: Distributive Conditional Types

@JensDll JensDll changed the title fix (types): toRefs should not do any ref unwrapping fix(types): toRefs should not do any ref unwrapping Nov 18, 2021
@yyx990803 yyx990803 merged commit c6cd6a7 into vuejs:master Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants