shrpne / vue-inline-svg

Dynamically loads an SVG source and inline <svg> element so you can manipulate the style of it
MIT License
175 stars 21 forks source link

TypeScript warning in v3 #56

Closed vincerubinetti closed 1 year ago

vincerubinetti commented 1 year ago

I have a component that contains this in the template:

  <InlineSvg
    v-if="custom"
    :src="custom"
    class="icon"
    aria-hidden="true"
    :data-icon="icon"
  />

with this package imported locally:

import InlineSvg from 'vue-inline-svg';

VSCode is giving me a strange error, as if I'm missing a required prop:

Type '{ src: string; class: string; 'aria-hidden': string; dataIcon: string | undefined; 'data-icon': string | undefined; }' is not assignable to type 'ComponentProps<InlineSvgConstructor>'.
  Property 'props' is missing in type '{ src: string; class: string; 'aria-hidden': string; dataIcon: string | undefined; 'data-icon': string | undefined; }' but required in type 'InlineSvgConstructor'.ts(2322)

I'm using version "vue-inline-svg": "^3.1.2".

The package itself seems to be working fine, I'm just wondering why I'm getting this warning. Any ideas?

shrpne commented 1 year ago

Hello! Looks like the types are from v2

You can check it v2 https://github.com/shrpne/vue-inline-svg/blob/master/types/index.d.ts v3 https://github.com/shrpne/vue-inline-svg/blob/v3/types/index.d.ts

vincerubinetti commented 1 year ago

Very strange...

In my node_modules/vue-inline-svg/types/index.d.ts, I see the correct version 3 types. In fact, searching my entire repo for InlineSvgConstructor shows no results... and the package is not installed globally either.

Okay, I just tried clearing my yarn cache, deleting node_modules and reinstalling, and restarting my editor. The warning seems to have gone away for now. It must've been some caching issue. Sorry for the trouble.