Open leifmarcus opened 1 year ago
The ecosystem is kinda not well setup for this... The types it generates are all super Vue and Vue tooling specific. The same issue happens with Svelte. I'm not sure what's the best way to approach this at the moment.
Hello @Princesseuh, the vue typings are really hard to reason about, you are right. Thank you for looking into this issue.
I believe I was having issues with this too recently where my TypeScript checks were failing on a Tag
component. It was complaining that I was passing a string into the size
property, yet that's was expected behavior. The code roughly looked like this:
<Tag size="24">{ label }</Tag>
As a workaround, I just removed the component and used static HTML since it was a rather simple component, but it would be nice to have this fixed as I felt like I had to introduce some tech debt in order to get around this issue.
Having the same problem
@Princesseuh, I was thinking, the type problems might be because of a wrong typescript setup somehow? I think it would be great to have an example setup for typescript that works in the documentation. I remember, that in lower versions of Astro we needed to setup some typescript to make it work. I could imagine, that this setup might be the problem. But I also couldn’t find how typescript needs to be set up when using Astro with vue so that it can work with Vue and Astro files. Maybe someone has some insights about the ideal Typescript setup?
@Princesseuh, I was thinking, the type problems might be because of a wrong typescript setup somehow? I think it would be great to have an example setup for typescript that works in the documentation. I remember, that in lower versions of Astro we needed to setup some typescript to make it work. I could imagine, that this setup might be the problem. But I also couldn’t find how typescript needs to be set up when using Astro with vue so that it can work with Vue and Astro files. Maybe someone has some insights about the ideal Typescript setup?
The problem in the OP is just that we don't (and honestly kinda cannot) really use the .d.ts generated by Vue, as the code they generate is specific to their tooling.
No config changes can fix this, and there're no config changes required to use Astro and Vue together, as far as I'm aware
Thanks @Princesseuh. I agree. I think with the latest versions of all extensions and packages it works as expected.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When importing a Vue component from a package/library, that is build width the vite library mode and has types declared with the
vite-plugin-dts
, then astro files cannot resolve the types for the props of the Vue component.Instead, a type error is shown:
The type declaration for this file looks like this (automatically generated during lib build):
A temporary fix for this is to whitelist all
IntrinsicAttributes
inastroHTML.JSX
, which will not break the typescript check, but is not really type safe.What's the expected result?
Astro files should be able to correctly interpret the typescript typings for imported Vue files with correct types for the Vue component properties.
This should also work for Vue Components, that are not imported from Vue SFC Files, but also when imported from build javascript files.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-dggmu9
Participation