babel-plugin-typescript-to-proptypes
babel-plugin-typescript-to-proptypes copied to clipboard
Add typeCheck support with typescript-to-proptypes
Problem
#8 outlines various different issues that are unsupported by the plugin because the typeCheck support doesn't yet exist.
Solution
Use the typescript-to-proptypes package to add support for type checking
TODO
- [ ] Make it actually work
- [ ] Add tests for various code that requires type checking (references, importing types,
Pick<>, etc)
FYI - This doesn't actually work yet. 😄 What it does at the moment is add a helper that will return an object representation of the evaluated prop definitions for each component in a file. What's left is to take that data and merge in obj.propTypes = React.PropTypes(...). I'm pretty sure that code already exists, but I'm not quite sure where it is and how to integrate it. I wanted to use this to start the conversation
Also, the new helper takes care of parsing the component prop types whether or not type checking is actually needed, so depending on how fast/slow it is, we could refactor the code to always use it.