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): readonly-array as an argument to ref/reactive, inconsistency between type and behaviour #6319

Closed
wants to merge 2 commits into from

Conversation

hubvue
Copy link

@hubvue hubvue commented Jul 20, 2022

When readonly-array is used as a ref/reactive parameter, the result type is inconsistent with the behaviour.

example:

export declare function expectType<T>(value: T): void

const refV = ref([ref(1), 2, ref(3), reactive({a: ref(1)})] as const)  // The same goes for reactive


const first = refV.value[0]

console.log((first as any).value) // 1

expectType<number>(refV.value[0])        // it should be error
expectType<Ref<number>>(refV.value[0])   // it should be right

playground

@hubvue hubvue changed the title types(reactivity): readonly-array as an argument to ref/reactive, inconsistency between type and behaviour fix(types): readonly-array as an argument to ref/reactive, inconsistency between type and behaviour Jul 21, 2022
@skirtles-code
Copy link
Contributor

I was wondering whether this change is still required? It seems quite similar to #3820, which was released in 3.2.42.

@hubvue
Copy link
Author

hubvue commented Apr 12, 2024

@skirtles-code The version of vue that submitted the PR didn't yet support support for readonly arrays, I tested that the current version does, and there's not much use for this PR, so it looks like it's possible to turn this PR off.

@yyx990803 yyx990803 closed this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

None yet

3 participants