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 typedocGetting started
The smallest useful thing you can do with it, and what each part means.
typescript
/**
* 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> {
// …
}Advanced usage
Where the library earns its place over a simpler alternative.
json
{
"entryPoints": ["src/index.ts"],
"out": "docs",
"excludePrivate": true,
"excludeInternal": true,
"validation": {
"notExported": true,
"invalidLink": true,
"notDocumented": true
},
"treatWarningsAsErrors": true
}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.
