Closed juhamust closed 3 years ago
Great idea, I'll try to work on that today
Fixed via commits e18f381a43f6d06c7eb10a91871dd90095845299 and 0bb03a67f3b7bcc8e07ef91019039432774302f7. Thanks again for the idea! This is a great addition to the tool!
Thanks for the quick response and glad that you found the suggestion useful! However, now that I tested it, the implementation is not exactly what I was looking for 😊 My feature request was to be able to generate JSDoc compatible type definitions for JavaScript files - not just copying existing ones. As an example:
Input:
MyComponent.propTypes = {
bar: PropTypes.string.isRequired,
foo: PropTypes.number,
}
Output:
/**
* @typedef MyComponentProps
* @property {string} bar
* @property {number?} foo
*/
Do you think this could be in the scope of this project? If yes, should I re-open the ticket or create a new one?
What is the purpose of that? Are you converting your prop types to JSDoc to continue using JavaScript and not switching to TypeScript files? This project is focused on people converting their codebases from JavaScript to TypeScript and I don't really want to support JSDoc type checking like you described.
Yes, that is exactly the case: I'm working on a project that cannot be converted into TypeScript at this point (if ever 😬 ). However, by using JSDoc type hinting some editors (at least VS Code, IntelliJ IDEA, etc.) are able to guide and complete the code way better than just defining React.propTypes info. Therefore I suggested the feature to be added to this nifty tool.
Gotcha. Yeah, that's not the focus or purpose of this tool, but if you are interested in pursing it, feel free to fork this repo and make the necessary modifications as this code is ISC licensed and free to use as you wish.
It would be nice if the tool could optionally generate the JSDoc typedef comment blocks from the propTypes info - for the projects that aren't converted into TS yet.