jfgodoy / vite-plugin-solid-svg

Vite plugin to Import SVG files as Solid.js Components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to make it work with Typescript

carere opened this issue · comments

Hello, all is in the title, i try to make it work in Typescript.

Specifically in order to set the color of the SVG. But typescript tells me that the imported SVG is of type string, since vite resolve *.svg as string...

Do you have any insight ? On how to do it ?

hi @carere, this plugin should work with typescript. Maybe you're missing some configuration, see examples/ssr that uses typescript. I could help you more if you provide a minimal repo that reproduces the problem.

hi @carere, I did a further investigation. Your are right vite resolves *.svg as string. I just added an example project for typescript and fixed some issues. I could'nt find a way to override vite's declaration, so to have the proper types, it's necessary to put the querystring ?component in the import.

image

I will close this issue, but feel free to open it again if you have problems to make this plugin works for typescript.