Skip to content

TypeDoc

Developer UtilitiesUtilityTypeScript

What it is

TypeDoc generates API documentation directly from TypeScript source and TSDoc comments, using the type information rather than parsing comments alone.

Point TypeDoc at an entry point. It resolves exported symbols, their real types, and any TSDoc comments, and emits HTML or JSON.

Installation

npm install --save-dev typedoc

Getting started

The smallest useful thing you can do with it, and what each part means.

Documented source
/**
 * Fetches a book by its identifier.
 *
 * @param id - The book's unique id.
 * @returns The book, or `null` when no such book exists.
 * @throws {NetworkError} If the request fails.
 *
 * @example
 * ```ts
 * const book = await getBook('42');
 * ```
 */
export async function getBook(id: string): Promise<Book | null> {
  // …
}
TypeDoc takes the signature from the compiler, so the parameter and return types in the output cannot disagree with the code. The comment supplies only the prose.

Advanced usage

Where the library earns its place over a simpler alternative.

Configuration and CI enforcement
{
  "entryPoints": ["src/index.ts"],
  "out": "docs",
  "excludePrivate": true,
  "excludeInternal": true,
  "validation": {
    "notExported": true,
    "invalidLink": true,
    "notDocumented": true
  },
  "treatWarningsAsErrors": true
}
The validation block is the useful part: it fails the build on broken @link references and on exported symbols with no documentation, so docs cannot quietly rot.

Errors and fixes

The failures you are most likely to hit, and what actually resolves them.

X is referenced but not exported
A public signature mentions a private type. Export it, or mark the member @internal.
Output is nearly empty
The entry point exports nothing TypeDoc can see. Confirm entryPoints matches your real index file.

Best practices

  • Document the public entry point thoroughly and mark internals with @internal.
  • Enable validation with treatWarningsAsErrors so broken links fail CI.
  • Include @example blocks — they are what readers look for first.
  • Generate on release rather than every commit; the output is large.

Background

Why it exists, and what it was reacting to.

TypeDoc reads the compiler's own view of your code, so signatures in the output are always accurate — unlike documentation tools that reconstruct types from annotations.