| name | jsdoc |
| description | Full JSDoc format guide for TypeScript, covering @example formats (short, multi-line, multi-variant), tag usage (@default, @deprecated, what to avoid), documentation patterns for properties/enums/functions, and tag order. |
JSDoc
The detailed JSDoc format guide with examples for every case. The always-on essentials live in
the jsdoc rule. Reach here when you need the full reference.
@example format
Short one-liner: label on the @example line, code as inline backtick on the next line
Multi-line: fenced code block immediately after @example
Multiple variants: use multiple @example blocks
Rules
| Rule | Correct | Incorrect |
|---|
| Label + inline code | @example Required\n\name: Type`` | @example \name: Type`` (code on tag line) |
| Multi-line code | Fenced ```ts ``` block | Bare code lines without a fence |
| Short examples | Inline backtick | Triple-backtick fence (too heavy) |
| One concern per example | Separate @example blocks | One example covering all cases |
Tags
Use frequently
| Tag | Purpose | Notes |
|---|
@default | Default value | Only when the default is non-obvious (omit for undefined) |
@example | Usage example | Prefer for complex or multi-variant APIs |
@note | Important caveat | Version info, breaking changes |
@deprecated | Mark as deprecated | Include a migration path |
Use sparingly
| Tag | Purpose |
|---|
@see | Reference external docs |
@internal | Internal API |
@beta | Experimental |
Avoid (TypeScript already provides these)
@param: use TypeScript parameter types
@returns: use the TypeScript return type
@type: use a TypeScript type annotation
@typedef: use type or interface
@default undefined: optional (?) already implies this
Documentation patterns
Simple property: always multi-line
outDir?: string
Never use single-line /** description */. Always expand to multi-line.
Property with a non-obvious default
concurrency?: number
Do not add @default false or @default undefined when the TypeScript type already makes the
default obvious.
Enum or union with options
pathParamsType: 'object' | 'inline' | 'inlineSpread'
Nested properties: every field gets its own multi-line JSDoc
names?: {
data?: string
params?: string
}
Function documentation
Only add JSDoc when it adds value beyond the signature:
function camelCase(str: string): string { ... }
function isStringType(node: SchemaNode): boolean { ... }
Guidelines
Do:
- Document what the property does, not its TypeScript type
- Give every exported type, property, and function a JSDoc comment
- Always use multi-line JSDoc blocks
- Use concrete, full-sentence descriptions
- Include
@default only when the default is non-obvious
- Use multiple
@example blocks for different variants
- Keep
@example labels short and descriptive
Do not:
- Write single-line
/** description */
- Write
@default undefined
- Put code directly on the
@example line
- Use
@param or @returns tags
- Over-document trivial, self-explanatory properties
Tag order
- Description (required)
- Bullet list of variants or behaviors (if applicable)
@default (if non-obvious)
@example (one or more)
@note (if needed)
@deprecated (if applicable)
@see (if providing references)