Typescript: incorrect typings for unwrapped refs #3315
Closed
Description
Version
3.0.6
Reproduction link
https://github.com/shameleo/vue-ts-bug
Steps to reproduce
npm install
npm run dev
Open index.html
browser and look console output.
What is expected?
If typescript is correct, console.log
would print refs and their values.
What is actually happening?
I see values and undefined
Here essential code:
export default defineComponent({
data: () => ({
arr: [1, 2, 3].map((num) => ({ num: ref(num) })),
}),
mounted() {
this.arr.forEach((el) => {
console.log(el.num);
// Typescript shows it is Ref<number>, but actually it is number
console.log(el.num.value);
});
},
});