I put this in a global.d.ts file so I don't even have to import it.
Now I can use it like this:
interfacePropsextendsJSXProps.ButtonElement{}
Am I missing something? Is there a better solution to this? I think react should provide an easier type system for the end user in the first place tho... It was extremely frustrasting to find the right types when I started react.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey man, nice article!
I only see one problem. For me the " forward top-level props to an element" section doesn't work.
Because when I do:
I get this error:
However, there is an easy workaround to fix this problem:
But this seems really combersome and repetitive when you have to do this in every component.
I wrote a generator which basically generates me this:
I put this in a
global.d.ts
file so I don't even have to import it.Now I can use it like this:
Am I missing something? Is there a better solution to this? I think react should provide an easier type system for the end user in the first place tho... It was extremely frustrasting to find the right types when I started react.