milesj / babel-plugin-typescript-to-proptypes

Generate React PropTypes from TypeScript interfaces or type aliases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PropTypes are omitted for component with many props

yakirn opened this issue · comments

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!

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!

@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