Does not apply propTypes using `$Exact<>`
See original GitHub issueI am using $Exact<>
to ensure that only certain props are passed to a component (flow will fail if any others are passed). I understand that checking for extraneous props is not easily handled with propTypes
, but all type definitions wrapped in $Exact<>
are ignored.
This works:
type ComponentProps = {
someProp: string,
};
This does write any propType
checks:
type ComponentProps = $Exact<{
someProp: string,
}>;
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Difference between PropTypes.exact and PropTypes.shape
1 Answer 1 · What happens with missing properties? · Both will give you warning i.e if you do not pass color for...
Read more >Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property:
Read more >How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >prop-types-exact - npm
For use with React PropTypes. Will error on any prop not explicitly specified.. Latest version: 1.2.0, last published: 5 years ago.
Read more >How To Use PropTypes In React - Web Dev Simplified Blog
If you did want to throw a warning, though, when the object has properties not specified in the PropTypes you could use PropTypes.exact() ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/brigand/babel-plugin-flow-react-proptypes/pull/51
See also https://github.com/facebook/flow/pull/2525 for the WIP documentation 😉