method-shorthand-jsdoc

Refactor factory functions to preserve JSDoc comments using method shorthand.

35|4|Updated Dec 18, 2024
One-click install
npx skills add https://github.com/wellcrafted-dev/wellcrafted --skill method-shorthand-jsdoc-wellcrafted-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: method-shorthand-jsdoc
Source: https://github.com/wellcrafted-dev/wellcrafted/tree/main/.claude/skills/method-shorthand-jsdoc
Command: npx skills add https://github.com/wellcrafted-dev/wellcrafted --skill method-shorthand-jsdoc-wellcrafted-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the issue where JSDoc comments on helper functions within factory functions are not visible to consumers when those helpers are referenced in the returned object, leading to poor developer experience and documentation gaps.

Core Features & Use Cases

  • JSDoc Preservation: Ensures documentation on internal methods is correctly exposed to consumers.
  • Improved IDE Tooling: Allows developers to hover over returned methods and see their documentation directly.
  • Use Case: When creating a complex object with a factory function, you want the methods exposed on that object to have clear, accessible documentation for anyone using the factory's output.

Quick Start

Use the method-shorthand-jsdoc skill to refactor the provided factory function to ensure JSDoc is visible on returned methods.

Frequently Asked Questions about method-shorthand-jsdoc

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does JSDoc disappear when I assign helper functions as properties in a returned object?

JSDoc visibility is lost because assigning internal functions as properties breaks the documentation linkage. Refactoring the factory function to use method shorthand preserves JSDoc comments and exposes them to consumers on hover.

How do I preserve JSDoc comments on methods exposed by a factory function?

To preserve JSDoc comments, refactor your factory function to define internal helper methods using method shorthand within the returned object. This ensures documentation is correctly exposed and `this` context is maintained for inter-method calls.

How do I keep the `this` context correct when refactoring a factory function for JSDoc visibility?

Using method shorthand within the returned object ensures the `this` context is correctly maintained for inter-method calls. This approach preserves JSDoc comments while keeping internal helper functions properly bound to the factory's returned instance.

Does using method shorthand in JavaScript expose JSDoc for internal helper methods in IDEs?

Yes, using method shorthand exposes JSDoc for internal helper methods in IDEs. It allows developers to hover over returned methods and see their documentation directly, improving developer experience and resolving documentation gaps.

Can I use method shorthand to fix JSDoc visibility in TypeScript factory patterns?

Yes, you can use method shorthand to fix JSDoc visibility in TypeScript factory patterns. It addresses the issue where documentation on internal methods is not visible to consumers when those helpers are referenced in the returned object.