-
Notifications
You must be signed in to change notification settings - Fork 509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for generating prop types? #418
Comments
@selbekk you have such option: https://github.com/jaredpalmer/tsdx#babel |
🤔 I tried to generate a repro:
{
"plugins": ["babel-plugin-typescript-to-proptypes"]
} And it didn't make a difference to the output at all. Am I missing an important step? Here's a repro: https://github.com/selbekk/repro-tsdx-418 |
@selbekk thinking guess this plugin is not applicable with tsdx cause babel get already compiled sources after rollup (not original typescrpt) https://github.com/rollup/rollup-plugin-babel#why I'll check it more deeply soon... |
@selbekk maybe you don't need tsdx for building react components library |
TSDX is a great way to create packages, and my component library is just a bunch of packages, really. :) I don't see why I couldn't use TSDX for this. |
yep, tsdx is great! :) but not a silver bullet.. but this is interesting challenge so I'll try to solve it :) |
@selbekk I have solution, but it's not so simple)) |
btw, I also prefer to use typescript only as type checker and type defs generator - not as transpiler and compiler - this is for babel which is first class transpiler :) |
I'm happy that works, and thanks for the incredible effort solving that (!), but switching out the entire compiler is a bit convoluted. Is there no way this could be built in to tsdx itself? as a rollup plugin or whatever? |
milesj/babel-plugin-typescript-to-proptypes#9 as I see the only way is to extend rollup-plugin-typescript2 with custom typescript transformer but as @jaredpalmer says this is not |
@selbekk found another solution: https://github.com/gcanti/prop-types-ts
|
...to many |
|
There is also |
This comment has been minimized.
This comment has been minimized.
@acasazza please read the comments. |
@agilgur5, I tried babel-plugin-typescript-to-proptypes, and it seems the better solution. Can I make a tsdx template? What do you think? |
@acasazza again, please read the comments before notifying everyone...
That was stated already in above comments and why I said it's not viable. |
I think this comment can help you milesj/babel-plugin-typescript-to-proptypes#8 (comment) |
@andriyor thanks) |
Thought I'd mention this here for any readers, but I wrote upstream in rpt2 (where I now help out as a maintainer) in ezolenko/rollup-plugin-typescript2#268 (comment) that using Babel plugins on top of TS code may be possible with a two-pass system. It's very inefficient and hacky, but could be doable if someone wants to do so. Also code returned by Babel plugins is likely pure JS so it may complicate type-checking. Experimentation definitely required, but thought I might as well mention it. |
Current Behavior
Right now, projects made with TSDX doesn't generate prop types automatically.
Desired Behavior
I'd like to have an option (or a way to extend the config) so that I can generate prop types in the development version of the package I create.
Suggested Solution
We could add a config option to add this babel plugin:
https://www.npmjs.com/package/babel-plugin-typescript-to-proptypes
Or write something similar, idk 🤷♂️
Who does this impact? Who is this for?
We're creating a component library in TypeScript, but many of our consumers don't use TypeScript. It would be great to add prop types as a fallback runtime verification for those that aren't using types.
This translates well to many packages created with TSDX, I would assume.
The text was updated successfully, but these errors were encountered: