mcpField
J
jsdoc

jsdoc

github.com/claude-dev-suiteDevelopment4652 installsUpdated 2d ago
Repository

About jsdoc

jsdoc is a quick-reference skill for JavaScript developers writing JSDoc comments. It explains documentation patterns for functions, types, classes, callbacks, generics, and modules, along with common pitfalls and fixes.

Key features

  1. 01函数与参数文档模式
  2. 02对象类型和回调定义
  3. 03类、泛型与模块注释
  4. 04常见注释错误及修正
  5. 05IDE 类型提示故障排查

Use cases

  1. 01为 JavaScript 函数补充参数和返回值说明
  2. 02记录对象类型与回调签名
  3. 03为类和模块编写文档注释
  4. 04排查 IDE 未显示类型提示的问题

MCP support

README 提到可通过 mcp__documentation__fetch_docs 获取 JSDoc 参考资料;未说明该技能提供 MCP 服务或客户端功能。

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill jsdoc

After installing, type/jsdocin Claude Code to confirm it loaded.

Details

From the project README

JSDoc - Quick Reference

When NOT to Use This Skill

  • TypeScript projects - Use the jsdoc-tsdoc skill for TSDoc and TypeScript-specific patterns
  • JSDoc generation config - This is for writing JSDoc comments, not configuring the tool
  • Complex type systems - TypeScript provides better type checking than JSDoc annotations
  • API documentation hosting - Use documentation platforms (TypeDoc, Docusaurus, etc.)

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: jsdoc for comprehensive tag reference, type expressions, and generation options.

Pattern Essenziali

Function Documentation
/**
 * Calculates the sum of two numbers.
 * @param {number} a - The first number
 * @param {number} b - The second number
 * @returns {number} The sum of a and b
 * @example
 * const result = add(2, 3); // 5
 */
function add(a, b) {
  return a + b;
}
Object Types
/**
 * @typedef {Object} User
 * @property {string} id - Unique identifier
 * @property {string} name - Full name
 * @property {string} email - Email address
 * @property {boolean} [active=true] - Optional, defaults to true
 */

/**
 * Creates a new user.
 * @param {User} userData - The user data
 * @returns {Promise<User>} The created user
 */
async function createUser(userData) {
  // ...
}
Class Documentation
/**
 * Represents a user in the system.
 * @class
 */
class User {
  /**
   * Creates a User instance.
   * @param {string} name - User's name
   * @param {string} email - User's email
   */
  constructor(name, email) {
    /** @type {string} */
    this.name = name;
    /** @type {string} */
    this.email = email;
  }

  /**
   * Gets the user's display name.
   * @returns {string} Display name
   */
  getDisplayName() {
    return this.name;
  }
}
Callback Types
/**
 * @callback FetchCallback
 * @param {Error|null} error - Error if failed
 * @param {Object} data - Response data
 */

/**
 * Fetches data from the API.
 * @param {string} url - The URL to fetch
 * @param {FetchCallback} callback - Called with the result
 */
function fetchData(url, callback) {
  // ...
}
Generic Types
/**
 * @template T
 * @param {T[]} array - Array of items
 * @returns {T|undefined} First item or undefined
 */
function first(array) {
  return array[0];
}
Module Documentation
/**
 * @module utils/string
 * @description String utility functions
 */

/**
 * Capitalizes the first letter.
 * @param {string} str - Input string
 * @returns {string} Capitalized string
 */
export function capitalize(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
}

Anti-Patterns

Anti-PatternWhy It's WrongCorrect Approach
No documentation at allNo IDE hints, hard to use APIDocument at least public functions and complex logic
Copying implementation as commentAdds no value, becomes outdatedDescribe behavior, not implementation
Missing @param typesNo type checking or autocompleteAlways specify parameter types
Outdated documentationMisleading, worse than noneUpdate docs when changing code
Over-documenting obvious codeClutters code, maintenance burdenDocument complex logic, skip trivial getters/setters
Using wrong tag for purposeConfuses tools, incorrect typesUse @typedef for types, @callback for functions
Not importing typesBroken type referencesUse @typedef {import('./types').Type}
Duplicate type info in TypeScriptRedundant, desynchronizesLet TypeScript types speak for themselves

Quick Troubleshooting

IssueDiagnosisSolution
IDE not showing type hintsJSDoc comments malformed or incompleteEnsure @param {Type} and @returns {Type} are present
Type errors in VS CodeIncorrect JSDoc type syntaxUse TypeScript-style types: {string|null} not {?string}
Broken type importsWrong import path in @typedefUse @typedef {import('./file').TypeName} with correct path
Generic types not workingImproper @template usageDeclare @template T before using it in params
Documentation not generatedJSDoc tool not configuredRun jsdoc -c jsdoc.json with proper config
Optional params showing as requiredMissing [] in param nameUse @param {string} [optional] or {string=}
Types not recognizedTypo or undeclared typedefDefine types with @typedef before use
Return type ignoredMissing @returns tagAlways document return value with @returns {Type}

Related Skills

Comments

Markdown supported