Type not preserved with array ref since 3.2.30
See original GitHub issueVersion
3.2.30
Reproduction link
Steps to reproduce
In the following block of Typescript code, look at the type of the list
variable.
import { ref } from "vue";
type DropdownOption = { value: string; name: string };
const list = ref<DropdownOption[]>([]);
What is expected?
The return type of ref<DropdownOption[]>([])
to be Ref<DropdownOption[]>
.
What is actually happening?
The return type of ref<DropdownOption[]>([])
is currently Ref<{value: string, name: string}[]>
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Reference to Array vs reference to array pointer - Stack Overflow
One problem is that your char array is NOT NECESSARILY going to be null-terminated. Since array is an automatic variable that is allocated ......
Read more >API Reference :: NVIDIA Deep Learning cuDNN Documentation
cudnnMathType_t is an enumerated type used to indicate if the use of Tensor Core operations is permitted in a given library routine. Values....
Read more >Chapter 10. Arrays
A variable of array type holds a reference to an object. Declaring a variable of array type does not create an array object...
Read more >node-oracledb 5.5.0 Documentation for the Oracle Database ...
Oracle Database driver for Node.js maintained by Oracle Corp. ... WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Read more >Why is an array a reference type? - Quora
An array is referred to as a reference data type since it specifies a reference to an ... the object is not explicitly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In a project I’m working on the same issue occurred during an upgrade of only the
yarn.lock
file. Did some research and apparently if the version of@vue/reactivity
mismatches with the pinned version ofvue
in thepackage.json
it will produce this issue.For the typescript type checking we’re using
vue-tsc
and it seems like they have an indirect dependency on@vue/reactivity@3.2.27
, thus making it possible for a mismatch upgrade in theyarn.lock
file.After bumping
vue
in thepackage.json
to the same version it resolves the issue. So it seems like typescript get confused somehow when@vue/reactivity
is not matching the version of other core vue packages.Don’t know if an investigation is really needed to know why a mismatch in versions result in this error, because it’s supposed the version of core vue packages must be the same. But it might worth looking into if it’s allowed that
vue-tsc
can result in such mismatch of core packages in theyarn.lock
. Especially whenvue-tsc
is named on the vue site.I could be off-base here, but I think the problem statement above is the issue related to this Typescript error.
That error does not appear in
vue<=3.2.29
. This is the code producing the error: