jpkleemans / vite-svg-loader

Vite plugin to load SVG files as Vue components
MIT License
554 stars 58 forks source link

`?component` param needed to get correct in-editor typing #134

Open beefchimi opened 7 months ago

beefchimi commented 7 months ago

Without the ?component param at the end of the .svg import, VsCode reports the import as a string.

Only by appending the ?component will VsCode report it as a FunctionalComponent:

import

I tried adding defaultImport: 'component' to the svgLoader config and it made no difference.

microHoffman commented 7 months ago

Yeah I have similar issue, I've resolved that by manually putting this to my index.d.ts:

declare module '*.svg' {
    import type { FunctionalComponent, SVGAttributes } from 'vue'
    const src: FunctionalComponent<SVGAttributes>
    export default src
  }