-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Types: Unable to return ComponentChild
from component
#4113
Comments
@rschristian The change you proposed of updating return type of What's considered a valid JSX is now based on the tag specifier satisfying
|
Interesting, thank you! I had no clue what was going so wrong there. If that's the approach that's needed for now, I wonder if it's better to wait... that's rather, rough, and I doubt our tooling here is going to support that nicely. I think forking the types for different TS versions is a non-starter. |
Ah this appears to have been visited before: #3611 It was just ahead of its time. Is forking the type so bad? It's unfortunate that TS only recently made it possible for function components to return a broader type like this, but as it is, the typing is incorrect. Without forking, I suppose you'd need to decide when to update the version of typescript for this repo and make the change to the |
It creates quite the mess and looks exceptionally fragile/easy for things to be out of sync, so I'd be against it. I think we should just stick with the types as-is for the time being, we definitely don't want to bump TS versions (recently that caused quite a bit of problems for people using Preact component libraries in older Angular projects, where I guess TS version is locked in?). This seems like a pretty uncommon issue to run across and can always be solved with a wrapping |
Describe the bug
From Slack
To Reproduce
TS Playground Link
The React equivalent, using
ReactNode
, works just fine. TS Playground LinkI believe we need to change this line to return a
ComponentChild
as React does but this seems to break a whole bunch of our types.The text was updated successfully, but these errors were encountered: