babel-plugin-flow-react-proptypes icon indicating copy to clipboard operation
babel-plugin-flow-react-proptypes copied to clipboard

opaque type is skipped

Open DimitryDushkin opened this issue 7 years ago • 2 comments

Hey! Thank you for great plugin!

We've started to use "opaque type" and I've noticed it's simply skipped by plugin. So all checks on this type fails, because it's degrades to shapeOf undefined.

Is this right, or am I doing something wrong?

Thank you.

DimitryDushkin avatar Feb 28 '18 08:02 DimitryDushkin

Thanks for bringing this up.

Could you give a code example that causes it to use shapeOf?

Also, what would you expect the behavior to be? We could treat them the same as normal types and actually do the checks, or they could be treated as any, which seems equally correct.

brigand avatar Feb 28 '18 09:02 brigand

Hi there, ran into similar problems with opaque type aliases and so I put together this PR to add support by using the opaque type alias's underlying type information to generate the propTypes (i.e. it behaves just like a regular type declaration).

I prefer that to treating them as any because in the project I'm working on we have a mixture of flow and non-flow-based source code so we use the generated prop types for validation of the source code which has not yet been migrated.

Hope this helps.

marcind avatar Apr 10 '18 05:04 marcind