JSDoc - documentation generator for JavaScript with type annotations. USE WHEN: user mentions "JSDoc", "JavaScript documentation", asks about "documenting JavaScript", "type hints", "jsdoc comments", "API documentation generation" DO NOT USE FOR: TypeScript - use `jsdoc-tsdoc` skill for TypeScript/TSDoc

GitHub
安装命令
npx skhub add claude-dev-suite/jsdoc
Markdown
SKILL.md

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

发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

Sep 24, 2026

分类

未分类

许可证

MIT

源路径

skills/documentation/jsdoc

默认分支

main

最新提交

9496306

Tree SHA

fe4e2f1