-
Notifications
You must be signed in to change notification settings - Fork 432
Generate Typescript and Flow type definitions from existing prop-types. #1346
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
Comments
There is nothing on the roadmap for |
How can we do this based on propTypes in an automated way? Also provide Flow typed definitions. |
I tried using dts-gen from Microsoft last week to create Typescript definitions but couldn't get it working using their basic CLI usage on our npm library. However I'm sure it'll be straightforward to write up a script that uses the source files to generate type definition files from the PropTypes we've already written. |
There is this codemod available to generate flow types from prop-types : https://medium.com/netscape/react-proptypes-to-flow-codemod-9757f5ec5381 . Only caveat is it seems to also removes prop-types... Never used it before but maybe there's a flag that can be passed to leave prop-types as is when converting. I know I've used this: https://github.com/joarwilk/flowgen before to convert TypeScript defs to flow types, (but that's assuming we have TypeScript defs). |
We might be able to use something from react-docgen AST parser if we need to do something custom. |
I'm going to work on adding a typedef file in October. I will also look into generating a library definition for flow as well. |
instead of trying to keep typedefs in sync, a better solution would just be to convert this to a typescript project 😉. |
I don't disagree... but providing a typedef file is a bit orthogonal to this project being typescript or not. Being typescript would certainly help this cause... but it doesn't prevent it either. We have other typescript projects around Salesforce, the heavy lifting here would be around integrating All that said... it is open source and we welcome contributions! I'd be happy to review a PR if you wanted to work on converting to typescript. We'd need to talk about it internally to see if the main contributors were comfortable with typescript though... we have some contributors who also use flow. |
@futuremint I think the biggest benefit would be replacing the clunky In my dreamworld ESNextNext just adopts the typescript specification, so you might as well get on board now 😈 |
Here is a library I found... https://github.com/KnisterPeter/react-to-typescript-definitions |
Hello, has there been any progress on types? |
@dehru I think @futuremint has been pulled into other organizational priorities. I'm un-assigning the issue from you @futuremint until you are able to take this up. |
Thats fine to un-assign it. @dehru we're an open sourced project and would welcome a contribution for this if you're inclined to take it on yourself. |
Hey everyone, we are currently working on adding TypeScript compatibility for |
Curious if you are rewriting in ts or just adding type defs? |
We are adding |
Extremely excited about this @xoob and I would love to help if I can in any way. |
I'm currently waiting for a number of pull requests to land before we continue on this. |
@xoob Is that pull requests on our side or something internal to you? @Ewilliams90 Welcome to Salesforce! |
I think one of the PRs is on our side (#2514). I took a look at that one and it generally looks good. |
I just can't wait those types definitions. It will be really nice feature and finally I will avoid multiple import issues in my project. |
@xoob, I would be really interested in your workflow for this, currently looking into doing something similar. Made a SO q to collate my search. |
Are there any plans on providing Typescript type definitions ?
The text was updated successfully, but these errors were encountered: