Composable unwrapping with destructure+re-export doesn't work if imported from a library #13697
Replies: 1 comment
-
Okay I have updated Vue from 3.5.16 to 3.5.18, and things started to work! Sorry for the spam, I was kinda desperate. edit: Oh, .18 came out yesterday, thanks for the fix. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
consider this:
and
All of this works as expected, unwrapping works, and the compiler doesn't complain.
However, let's say I have a library installed via npm locally (I'm not sure if the local part matters), and its export typescript file includes the same thing as my foo.ts. Intuitively, everything should work the same way, but unfortunately, I get this error:
The best part is that this seems to be a false positivie - afaik the ref unwrapping still works when running a dev server through Vite, it's just that the typechecker complains.
The only difference I've found between my code, and for example
useMouse
from VueUse (which works fine for me) is that VueUse packages do not export Typescript code directly, they only export the types file, so Typescript only seesdeclare function...
, and everything works fine with destructuring.Sorry for the confusing explanation, but to be honest, I have no idea what I'm doing wrong. But essentially, I want to be able to do:
and then in a .vue file:
but with my composable. With useMouse, it works, so it must work with mine too, but I'm not sure why :/ like I said, the only difference is that my library (https://github.com/silicon-heaven/libshv-js) does not ship JS files, just TS files directly
edit: It seems like there is something wrong with my setup in the main project, because I'm not able to reproduce this if I create two new fresh projects :/
Beta Was this translation helpful? Give feedback.
All reactions