-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add JSDoc support #137
base: main
Are you sure you want to change the base?
Add JSDoc support #137
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is a really nice, elegant and surprisingly compact implementation, nice work!
Co-authored-by: Volodymyr Agafonkin <[email protected]>
} | ||
|
||
const type = getTsType(field); | ||
const isRequired = field.required || field.repeated || field.map; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isRequired = field.required || field.repeated || field.map; | |
const isRequired = field.required; |
repeated
fields (and map
) are inheritely optional as they can be provided with zero values.
Should we not reflect that in the JSDoc and makes all repeated and map fields optional ?
I am currently using pbf with Typescript and the implementation of JSDoc is a nice and elegant feature to get type hints understandable by Typescript compilers. Is there any blockers to merge this and integrate it in the next release ? |
Hey, @aberrier, thanks for trying this implementation! It is working for me as well. I've planned to add more tests for this, like the ones in the Another approach for TypeScript support might also be considered in #138. I'm not sure what the best option here, but implementing JSDoc support is less intrusive and easier to review, in my opinion. |
Different approach to #107. Adds
--jsdoc
option to generate type annotations.