Skip to content
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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Add JSDoc support #137

wants to merge 4 commits into from

Conversation

stepankuzmin
Copy link

Different approach to #107. Adds --jsdoc option to generate type annotations.

Copy link
Member

@mourner mourner left a 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!

compile.js Outdated Show resolved Hide resolved
compile.js Outdated Show resolved Hide resolved
compile.js Outdated Show resolved Hide resolved
compile.js Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
stepankuzmin and others added 2 commits August 21, 2024 17:08
Co-authored-by: Volodymyr Agafonkin <[email protected]>
}

const type = getTsType(field);
const isRequired = field.required || field.repeated || field.map;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ?

@aberrier
Copy link

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.
Big plus for the compact and minimal implementation ! 👏

Is there any blockers to merge this and integrate it in the next release ?

@stepankuzmin
Copy link
Author

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 types/ folder, before marking this as ready for review.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants