79126816

Date: 2024-10-25 17:56:02
Score: 0.5
Natty:
Report link

Found a solution.

interface SVGAttributes<T> doesn't need to have title prop, becuase when title prop is passed, @svgr/webpack creates a tag <title> inside <svg> tag, not put title as an attribute.

So all we need is to make proper declaration through intersection to avoid mistake which says that title prop doesn't exist:

declare module '*.svg' {
    import { type FC, type SVGProps } from 'react'
    const SVG: FC<SVGProps<SVGElement> & { title?: string }>
    export default SVG
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: rgdzv