milesj / babel-plugin-typescript-to-proptypes

Generate React PropTypes from TypeScript interfaces or type aliases.
MIT License
367 stars 25 forks source link

PropTypes are omitted for component with many props #14

Closed yakirn closed 5 years ago

yakirn commented 5 years ago

When trying to convert a component with many props (over 25) the plugin only converts the first ~25 props and omits the rest. I created a demo repo.

Steps to reproduce:

npm i && npm test

Expected result

The result file (lib/ManyProps.js) should contain all 40 props that are in the source file (src/ManyProps.tsx)

Actual result

The result file contains only 25 props.

Environment:

Node: v8.16.0 "@babel/cli": "^7.4.4", "@babel/core": "^7.4.4", "@babel/preset-react": "^7.0.0", "@babel/preset-typescript": "^7.3.3", "@types/react": "^16.8.17", "babel-plugin-typescript-to-proptypes": "^0.17.1", "typescript": "^3.4.5"

I don't have experience with babel plugins but I'd be happy to help with a fix if you can give some directions to where the problem is. Thanks!

milesj commented 5 years ago

@yakirn This is by design. Increase the maxSize setting: https://github.com/milesj/babel-plugin-typescript-to-proptypes#maxsize-number

yakirn commented 5 years ago

Can’t believe I missed that 🤦🏻‍♂️ I think it is more intuitive if 0 will be the default, and I’m curious about why put a limit in the first place? Could save others who will make my mistake. Thanks for the quick response!

milesj commented 5 years ago

@yakirn Putting a limit reduces the file size of the transpiled output. I'd say 25 props is generous, and anything more than that should probably be refactored :P

yakirn commented 5 years ago

Got ya. Understanding what all of the props are is the first step I’m taking in refactoring a beast. This is where I needed this awesome plugin :) Cheers!

On Wed, 15 May 2019 at 22:00 Miles Johnson notifications@github.com wrote:

@yakirn https://github.com/yakirn Putting a limit reduces the file size of the transpiled output. I'd say 25 props is generous, and anything more than that should probably be refactored :P

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/milesj/babel-plugin-typescript-to-proptypes/issues/14?email_source=notifications&email_token=ABSZ4MEKNKBLNQO7OFPLKVTPVRMTRA5CNFSM4HNEEHFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVPUDLY#issuecomment-492781999, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSZ4MCEE7E4A3NWCVLEZ33PVRMTRANCNFSM4HNEEHFA .