Skip to content

feat(compiler): Automatically add @default JSDoc to @Prop() declarations #6264

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

Conversation

yashwanth-yenugu
Copy link
Contributor

@yashwanth-yenugu yashwanth-yenugu commented May 27, 2025

What is the current behavior?

Currently, Stencil does not automatically add @default JSDoc to @Prop() declarations, even when a default value is present in the component's property definition. Developers have to manually add this JSDoc.

Closes: 6139

What is the new behavior?

Stencil will now automatically add @default 'value' to the JSDoc of a @Prop() when a default value is detected for that property and no @default JSDoc is already present. This improves developer quality of life by reducing redundancy and making component APIs clearer.

Documentation

No new documentation is required, as this is an automatic behavior change.

Does this introduce a breaking change?

[ ] Yes
[x] No

Testing

Unit tests have been added to src/compiler/types/tests/generate-prop-types.spec.ts to verify the new behavior, including cases where a default value is present and where @default JSDoc is already manually set. All tests are passing.

Other information

This feature is similar to how Stencil automatically adds @readonly when a @Prop() only has a getter method.

@yashwanth-yenugu yashwanth-yenugu requested a review from a team as a code owner May 27, 2025 12:26
@yashwanth-yenugu yashwanth-yenugu changed the title feat: Automatically add @default JSDoc to @Prop() declarations feat(Compiler): Automatically add @default JSDoc to @Prop() declarations May 27, 2025
@yashwanth-yenugu yashwanth-yenugu changed the title feat(Compiler): Automatically add @default JSDoc to @Prop() declarations feat(compiler): Automatically add @default JSDoc to @Prop() declarations May 27, 2025
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Awesome, thanks a lot!

@christian-bromann
Copy link
Member

@yashwanth-yenugu it seems like some of the CI tests are failing, mind taking a look? Let me know if I can help with them.

@yashwanth-yenugu
Copy link
Contributor Author

Hi @christian-bromann , I’ve pushed a fix for the CI issues — the tests are now passing ✅
could you please take another look and let me know if anything else is needed? Thanks.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Thank you 🙏

@christian-bromann christian-bromann merged commit 9657927 into stenciljs:main May 28, 2025
72 checks passed
@yashwanth-yenugu yashwanth-yenugu deleted the feature/add-prop-default-jsdoc branch May 28, 2025 18:16
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.

feat: automatically add @default ... to @Prop() jsdoc
2 participants