Encountering this issue with both arrays and objects has been a challenge. While using shallowRef
instead of ref
might provide a temporary solution, the need for deep reactivity persists. I have resorted to casting as a workaround, but it is not ideal. What would be the most effective way to tackle this dilemma?
class Bar {
private val = 1;
}
class Foo {
private bar = new Bar();
}
const fooRef = ref(new Foo());
const foo: Foo = fooRef.value; // Property bar is missing in type {} but required in type Foo
const bar = fooRef.value.bar; // Property bar does not exist on type {}
const baz = ref([new Foo()]);
const z = baz.value[0].bar.val; // Property bar does not exist on type {}
Key packages being used:
"typescript": "^5.6.3",
"vue": "^3.5.12",