tailwindlabs / heroicons

A set of free MIT-licensed high-quality SVG icons for UI development.
https://heroicons.com
MIT License
21.04k stars 1.26k forks source link

React type export doesn't include `title` #810

Closed jharwig closed 1 year ago

jharwig commented 1 year ago

Since https://github.com/tailwindlabs/heroicons/pull/779, the title prop can be set to create an svg title element, but the react typings do not include that prop: since the the definition in the Icon.d.ts file doesn't include it:

declare function StarIcon(props: React.ComponentProps<'svg'>): JSX.Element;

The error message is Property 'title' does not exist on type 'IntrinsicAttributes & SVGProps<SVGSVGElement>'.

I think the vue types are working because it allows any HTMLAttributes through, so it's probably just a matter of adding a & {title?: string } to the react props...

-? `import * as React from 'react';\ndeclare function ${componentName}(props: React.ComponentProps<'svg'>): JSX.Element;\nexport default ${componentName};\n`
+? `import * as React from 'react';\ndeclare function ${componentName}(props: React.ComponentProps<'svg'> & {title?: string}): JSX.Element;\nexport default ${componentName};\n`
RobinMalfait commented 1 year ago

Hey! Thank you for your PR! Much appreciated! 🙏

This should be fixed by #814, and will be available in the next release.

You can already try it using: