Skip to content

regarding the icons type signature #981

Answered by thecrypticace
ceIia asked this question in Help
Discussion options

You must be logged in to vote

Yes, the signature is quite odd but it is correct now whereas it was not before. This is because this is the return type of React.forwardRef(…). Imo, the ref 2nd argument really should've been designed as a prop in React but it wasn't (probably due to a lot of historical decisions) and that leads to some of these weird type-level issues.

The problem with the original types is that:

  1. Icons were incorrectly marked as a general component — not an "Exotic" one. I'm honestly not 100% sure why the React types need this distinction but they do appear to make it very intentionally.
  2. The type of Icon['ref'] was incorrect — being inherited from SVGSVGElement (all HTML and SVG elements in react have …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@ceIia
Comment options

@simensen
Comment options

Answer selected by ceIia
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants