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

Fix #215

Open kevinbarabash opened this issue 6 years ago • 3 comments

In some situations where imported prop types were being used in multiple components, some of the AST nodes generated by the plugin were being used in multiple places which caused issues for downstream plugins in @babel/env. This PR fixes that by clone the prop types node before adding it to the AST.

Resolves #215

kevinbarabash avatar Apr 17 '19 16:04 kevinbarabash

Coverage Status

Coverage remained the same at 92.587% when pulling 89e1a6f3e11abc42fb968fa45d77c5beb8c7d94d on Khan:215_minimal_repro into d39eef29755af43e769ebf19dccbd13c6f316ffb on brigand:master.

coveralls avatar Apr 17 '19 16:04 coveralls

I ran into some issues when running this on my code so there's at least one edge case I haven't handle. For some of the code I get a parse error: SyntaxError: Unexpected token u in JSON at position 0. I'll investigate this to see what's up.

kevinbarabash avatar Apr 17 '19 17:04 kevinbarabash

It turns out I was clone too soon and sometimes props would be a function instead of an object. I've move the clone operation to be right before where the new chunk of AST is inserted into the output tree and that fixed the issue I was seeing.

kevinbarabash avatar Apr 17 '19 20:04 kevinbarabash