---
name: typescript-type-documenter
description: "Writes reader-facing documentation for chosen TypeScript types: a description, a property table with type, optional flag, default and meaning, and usage examples, in Markdown, HTML, or JSON. Use when TypeScript interfaces, types, or classes need reader-facing documentation with a property table and examples, in Markdown, HTML, or JSON. Do not use for producing a type inventory as data, writing the types themselves, or documenting runtime functions. Related topics: coding, typescript."
---

# TypeScript Type Documenter

Writes reader-facing documentation for chosen TypeScript types: a description, a property table with type, optional flag, default and meaning, and usage examples, in Markdown, HTML, or JSON.

## When to use

Use this skill when TypeScript interfaces, types, or classes need reader-facing documentation with a property table and examples, in Markdown, HTML, or JSON. Do not use it for producing a type inventory as data, writing the types themselves, or documenting runtime functions.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Write a one or two sentence description per type from its JSDoc, names, and usages; every requested type has one.
3. Build the property table with name, type, optional flag, default, and meaning, and list variants and discriminants for unions.
4. Show generic parameters with constraints unless hidden, and include private members only when asked, marked private.
5. Add one compiling example per type (one per union variant) when examples are requested.
6. Render the whole thing in the chosen format in source order, with no commentary outside the document.

## Inputs

- **Source code** (longer free text)
- **Source file path** (free text, e.g. "src/types/billing.ts")
- **Types to document** (free text, e.g. "Names separated by spaces or all")
- **Include private members** (choose one: Yes, No)
- **Output format** (choose one: Markdown, HTML, JSON)
- **Add usage examples** (choose one: Yes, No)
- **Hide generic parameters** (choose one: Yes, No)

## Output

One document in the chosen format: a section per type with description, property table, and optional examples, in source order, and no text outside it.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### TypeScript Type Documenter

Document the types below for people who will use them without reading the source.

- Source code: {{Source code}}
- Source file path: {{Source file path}}
- Types to document: {{Types to document}}
- Include private members: {{Include private members}}
- Output format: {{Output format}}
- Add usage examples: {{Add usage examples}}
- Hide generic parameters: {{Hide generic parameters}}

Document each type as a contract. Open with one or two sentences on what the type represents and where it is used, taken from the code's own JSDoc when present and from the member names and usages otherwise. Then build the property table: name, type as written, whether it is optional, the default (from initializers or JSDoc, otherwise a dash), and a one-line meaning. For unions, list each variant and the discriminant that selects it. For generics, show the parameters and constraints unless asked to hide them. For classes, document public members and only include private ones when asked, marked as such.

When examples are requested, show one valid value per type and, for a discriminated union, one per variant, as compiling TypeScript. Order the types as they appear in the source so readers can find them.

### Output
Return one document in the chosen format and nothing else. Markdown: a level-2 heading per type, description, property table, examples. HTML: the same sections as section, h2, table, and pre elements. JSON: an array of objects with name, kind, description, properties, and examples.

## Pitfalls

- Describing a property by restating its name (userId: the user id), which tells the reader nothing they could not see.
- Leaving the default column empty when a class initializer or JSDoc @default states one.
- Collapsing a discriminated union into one property table, so readers cannot tell which fields belong to which variant.
