prop-types: PropTypes.node forbids true but flow typing accepts it, causing runtime warning
PropTypes.node does not accept true according to #109.
But flow typing in React declares export type ReactEmpty = null | void | boolean;
https://github.com/facebook/react/blob/b6173e643a4311b9b1cf039824b2f3d7b974b8cf/packages/shared/ReactTypes.js#L18 so it accepts true without error for type checking, but prop-types shows warning for it.
(Actually I’m using equivalent TypeScript type definition along with material-ui library which uses prop-types.)
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 18
AFAIK current state is:
@types/react: accepts truePropTypes.node: rejects trueSo React and its flow type are already in sync for
true. My guess is that React acceptstruefrom the beginning. But I’m in doubt, so filled https://github.com/facebook/react/issues/17871 .Ah, I misunderstood. You’re saying that react itself changed to allow
trueat some point, andPropTypes.nodedoes not properly allow it?It’d be great if we could figure out in which version that changed.