Open NathanAP opened 5 days ago
Someone told me the recommended way to make create a typed ref
is by doing const databaseList: Ref<VisualizationItem[]> = ref([])
and it fixes my problem. If this is the right behaviour, you guys can close this issue.
if (!selectedDatabase.value)
test(selectedDatabase.value.object) // this throws ts-plugin(2345)
In this case selectedDatabase.value
is null
- it must throw.
Ah yes. Sorry, it was my mistake when I was writing the issue. The if checks for null values. I edited it.
The error image is right, though. It says that object is not type "Database".
You can see the same effect in your example, but in mine is like this:
If you pass your mouse over databaseList
or selectedDatabase
, you see that it shows object
being an Object
and not a Database
.
Someone in Discord told me its because how ref
unwrap stuff and I should use Ref
to type it properly. If this is working as intended, thats fine.
Vue - Official extension or vue-tsc version
2.0.26
VSCode version
1.90.2
Vue version
3.4.31
TypeScript version
5.5.3
System Info
tbh not sure if this is relevant because I'm in Gitpod.
Steps to reproduce
Hey guys! Sorry if this is not the right place to post my situation.
I have the following code where it used to work some time ago (TS 5.3.3 for sure):
But when I do something like...
...
2345
error is being thrown, which doesn't make sense because myselectedDatabase
should be aVisualizationItem
. Looking forward in this, I discovered that when I hover over mycomputed
orref
variables, the following is being shown:It seems that vs code can no longer identify that my
object
part is aDatabase
and it shows me as a simple object, which throws the following:Edit: I tried
const databaseList: Ref<VisualizationItem[]> = ref([])
and this works fine.What is expected?
No errors should be thrown because everything is typed.
What is actually happening?
TS 2345 is thrown and it says that my variable has the wrong type.
Link to minimal reproduction
No response
Any additional comments?
No response