airbnb / babel-plugin-inline-react-svg

A babel plugin that optimizes and inlines SVGs for your React Components.
MIT License
474 stars 92 forks source link

How do I add type declarations for the svg file imported? #104

Closed arantesxyz closed 3 years ago

arantesxyz commented 3 years ago

I'm having this error in vsc (no errors when executing):

Property 'className' does not exist on type 'IntrinsicAttributes'.ts(2322)

I tried: @types/index.d.ts

declare module '*.svg' {
  import React = require('react')
  export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>
  const src: string
  export default src
}

But i still receiving the error in vsc.

ljharb commented 3 years ago

I have no idea what @types/index.d.ts would be.

This package does not contain TS types. If there's a DefinitelyTyped package, I'd suggest using that; if not, I'd suggest creating one.

thadeucity commented 3 years ago

@arantesxyz

declare module '*.svg' {
  import React = require('react');

  const value: React.SFC<React.SVGProps<SVGSVGElement>>;

  export = value;
}

This onw worked for me