Closed nasheomirro closed 1 year ago
Looks like this issue is related to how typescript does inference, see accepted answer. I am not sure if there is a solution at the moment.
After some time the trick with commit 03bf3db is now un-needed, I don't know what changed but it has to be some update to typescript or maybe ts-server (idk).
Components have the correct types but are inferring incorrectly:
Note that
onClick
still has the correct type, it's just that typescript isn't inferring our function. What's weirder is that if you provide anas
prop, or explicitly provide a value for the component type, then it will infer correctly.Helpful links: https://github.com/kripod/react-polymorphic-types/issues/5 https://github.com/microsoft/TypeScript/issues/44596