typescript-jsdoc
БесплатноБез исполняемых скриптовНе проверенWrite effective JSDoc comments for TypeScript code. Provides guidance on documentation format, strategic placement, best practices, and when to document…
от aiskillstore★ 509 звёзд на GitHubОб этом скилле
TypeScript JSDoc Documentation
Write effective JSDoc comments that enhance code maintainability and provide valuable context to developers and IDEs.
Core Format
JSDoc comments begin with /** and end with */, with lines inside typically starting with an asterisk. Tags start with @ followed by a keyword. Essential tags include @param, @returns, @throws, @example, and @deprecated.
Since TypeScript code already contains type information, JSDoc should focus on the "why" and "how" rather than repeating types:
/**
* Calculates the total price including tax
* @param basePrice - The price before tax
* @param taxRate - The tax rate as a decimal (0.08 for 8%)
* @returns The total price after applying tax
*/
function calculateTotal(basePrice: number, taxRate: number): number {
return basePrice * (1 + taxRate);
}
Strategic Documentation Levels
Treat JSDoc usage as having three distinct levels, each serving different purposes:
Essential Documentation appears on all public APIs, exported functions, classes, and interfaces. This is non-negotiable for library code or shared modules. Document what the entity does, important behaviors, potential errors, and provide a usage example when the interface isn't immediately obvious.
Clarifying Documentation becomes valuable when code has non-obvious behavior, implements complex algorithms, or has important side effects. Explain critical behaviors that aren't apparent from the signature, warn about unusual performance characteristics, or document retry logic, caching behavior, or state management. This documentation adds genuine value beyond the type system.
Minimal Documentation applies to internal helper functions, private methods, and straightforward utility functions where the code is genuinely self-documenting. Even here, a brief one-liner explaining intent helps future developers quickly understand purpose. Skip documentation only when the function name and implementation are immediately transparent.
Documentation Structure for Complex APIs
For classes and services, document the class at a high level, then provide detailed documentation on public methods:
/**
* Manages user authentication and session handling.
*
* This service maintains a singleton instance that handles all
* authentication flows including login, logout, and token refresh.
* It automatically manages token expiration and renewal.
*/
export class AuthenticationService {
/**
* Attempts to authenticate a user with provided credentials
* @param credentials - User login information
* @throws {AuthenticationError} When credentials are invalid
* @throws {NetworkError} When the authentication server is unreachable
* @example
* ```typescript
* const auth = new AuthenticationService();
* try {
* const session = await auth.login({
* username: '[email protected]',
* password: 'securepass'
* });
* } catch (error) {
* console.error('Login failed:', error.message);
* }
* ```
*/
async login(credentials: LoginCredentials): Promise<Session> {
// Implementation details
}
}
Advanced Patterns
For generic functions, JSDoc shines in providing context that type signatures alone cannot convey. Use @template tags to explain type parameters and document how they interact:
/**
* Transforms an array of items using a mapping function with memoization.
*
* This function caches results based on item identity, making it efficient
* for repeated transformations of the same data. The cache is cleared
* when the array reference changes.
*
* @template T - The type of items in the input array
* @template R - The type of items in the output array
* @param items - Source array to transform
* @param mapper - Function to transform each item
* @param keyExtractor - Optional function to generate cache keys
* @returns Transformed array with results potentially served from cache
*/
function memoizedMap<T, R>(
items: T[],
mapper: (item: T) => R,
keyExtractor?: (item: T) => string
): R[] {
// Implementation with caching logic
}
For complex object parameters, use nested parameter documentation to keep organization clear:
/**
* Configures the application database connection
* @param config - Database configuration options
* @param config.host - Database server hostname
* @param config.port - Port number (defaults to 5432)
* @param config.ssl - SSL connection settings
* @param config.ssl.required - Whether SSL is mandatory
* @param config.ssl.certificatePath - Path to SSL certificate file
* @param config.poolSize - Maximum connection pool size (1-100)
*/
function configureDatabase(config: DatabaseConfig): void {
// Configuration logic
}
When Documentation Becomes Redundant
Understanding when JSDoc becomes redundant is equally important. Avoi
Установить typescript-jsdoc в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл typescript-jsdoc?
Write effective JSDoc comments for TypeScript code. Provides guidance on documentation format, strategic placement, best practices, and when to document versus when to keep code self-documenting. Helps maintain code clarity and IDE support.
Как установить скилл typescript-jsdoc?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл typescript-jsdoc запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic