-
Notifications
You must be signed in to change notification settings - Fork 30.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/react] React.Children.only types seems to be broken #32832
Comments
Shrinkwrap to 16.7.20 where it still works well, 16.7.21 and 16.7.22 are broken |
This is a consequence of https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L471 In the definition of
So the upshot is that you can't just return a |
Actually, it's being tracked here - it's due to a compiler issue, and there's promise of a fix soon. In the meantime, this should work: export const Wrapper: React.FC = ({ children }) => (<React.Fragment>React.Children.only(children)</React.Fragment>); |
#32279 may also be relevant as it removed the constraint on the return type of React.Children.only which should always be ReactElement. |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
Hey everyone.
Updated to latest
@types/react
, started to get this error for this code:Can't figure out what this is wrong. What am I missing here?
Thanks!
The text was updated successfully, but these errors were encountered: