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

types(ref): fix type error when ref parameter is of type any #9768

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

Alfred-Skyblue
Copy link
Member

@Alfred-Skyblue Alfred-Skyblue commented Dec 7, 2023

export function ref<T extends Ref>(value: T): T

This function overload matches the any type, and it returns any instead of Ref<any>.

const msg: any = 'hello'

const msgRef = ref(msg) // ===> any

// Expected `Ref<any>` for msgRef, but received type `any`.

In this PR, the function overload was removed because its outcome is identical to export function ref<T>(value: T): Ref<UnwrapRef<T>>.

image

Copy link

github-actions bot commented Dec 7, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 86.9 kB 33 kB 29.8 kB
vue.global.prod.js 133 kB 49.9 kB 44.7 kB

Usages

Name Size Gzip Brotli
createApp 48.3 kB 19 kB 17.3 kB
createSSRApp 51.5 kB 20.3 kB 18.5 kB
defineCustomElement 50.7 kB 19.7 kB 18 kB
overall 61.6 kB 23.8 kB 21.7 kB

@Alfred-Skyblue Alfred-Skyblue changed the title types(reactivity): fix type error when passing any through ref types(ref): fix type error when passing any through ref Dec 7, 2023
@Alfred-Skyblue Alfred-Skyblue changed the title types(ref): fix type error when passing any through ref types(ref): fix type error when ref parameter is of type any Dec 7, 2023
@yyx990803 yyx990803 merged commit cdac121 into vuejs:main Dec 7, 2023
11 checks passed
@Alfred-Skyblue
Copy link
Member Author

Thank you for your quick response and for adding test cases, that's awesome.

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.

2 participants