Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Type of ref for Map with generic in values is abnormal. #9771

@sinkersan

Description

@sinkersan

Vue version

3.3.10

Link to minimal reproduction

https://play.vuejs.org/#eNp9U8lu2zAQ/ZUBL5EBV0aSmyob6OJDA6QtGvdk+aBKY5uJRBJcFAeG/r1DUrYVJIgNSZztzZuFR/ZFqbRzyDKWm0pzZcGgdQqaUuzmBbOmYItC8FZJbeEIGrfTSrbKWayhh62WLVxR/NXnQhTCviiEvwY1zOFYCABeZyBc+w/11IuibDEDYzUXu0L0PmTrRGW5FOAMPtjSYr5aJJMYXUlhLKUsyaPD+1IRLBFIBD4DSfmADD5iQgROEQ2n15yEyDNfrTeLhEDnizFuqXUGZCLP9SZEA6zTNB3lS7uycZg+4YtJJpt0K/WyrPYJyWcs/yOkVDmzT96G7tB698kk+vbDV1OPtfCBIXFU+2cwDNAjvNA/CKWFiNC+WIifysUvVt9TVeeO+olQi8KI3lKkeSfX08u8rkejKtjdXgqE7xILRik9xvsINyOEm1cIv/e84Qrupea0TANI/OezuHO0YSRYbFVDfEkCyGvehQP4OrTJ4tmroftEk6Dl9AbgIjaFQUaNHrQpr8PexvkcjwEj9Yygp74FpNklQ0g4yPnszINNaf+px1u+Sx+NFHRJQo0F86vFG9S/lN9dKis7jaxgZdPI57ugs9rhMDiK2WP19I7+0Ry8jhqlkVh21OmzzZaaNiialw8/8UDns7GVtWvI+wPjHzSycZ5jdPvqRE20R36B7Y9wvelSrszyYFGYU1GeaFi34F8wuunfPij9Qvc2vT2tKev/Ay/CctU=

Steps to reproduce

  1. Create ref with Map that use generic
const reactiveMap = ref(new Map<number, T>());
  1. Try to assign value from crated map in other place that expect this generic:
const test: T = reactiveMap.value.get(1)

You can check typescript error on line 14 in App.vue file in reproduction link.

What is expected?

Code works without any typescript errors.

What is actually happening?

Got error:

 Argument of type 'UnwrapRefSimple<T>[]' is not assignable to parameter of type 'T[]'.
  Type 'UnwrapRefSimple<T>' is not assignable to type 'T'.
    'T' could be instantiated with an arbitrary type which could be unrelated to 'UnwrapRefSimple<T>'

System Info

No response

Any additional comments?

This issue happens on 3.3.10 versions and works well on 3.3.9
I may assume that issue related to this changes: https://github.com/vuejs/core/pull/8960/files#diff-81475b10580b705fb8421b8c430ac63220938646c0e09141be79c85b0ea392ffR499
that was included in lates release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions