| name | expo-api-docs |
| description | Write TSDoc comments for Expo SDK APIs following official conventions. MUST USE when introducing new user-facing TypeScript APIs in expo-* packages - document APIs correctly from the start, not as an afterthought. Also use when improving existing documentation. Covers @platform, @example, @deprecated, @default annotations, third-person declarative style, blockquote notes, and type export patterns for docs generation. |
| version | 1.0.0 |
| license | MIT |
Documenting Expo APIs
Guidelines for writing TSDoc comments in Expo SDK packages. The docs generation system (GenerateDocsAPIData.ts + TypeDoc) extracts these comments to produce API reference documentation.
Document APIs as you write them, not as an afterthought. When implementing new features, write TSDoc comments alongside the code.
When to Use
- Implementing new features that expose public TypeScript APIs
- Adding or modifying public APIs in
packages/expo-*
- Documenting functions, types, interfaces, constants, or enums
- Adding platform-specific annotations
- Writing code examples in docblocks
Core Principles
- Third-person declarative — describe what the function does, not what to do
- Explain the iceberg — document failure modes, side effects, concurrency behavior, not just params/returns
- Quality over quantity — no docs is better than useless docs like "The width" for a
width property
Function Documentation
Use third-person declarative ("Gets...", "Returns...", "Checks..."), not imperative ("Get...", "Return...").
export async function getUptimeAsync(): Promise<number> {
Key points:
- First sentence: what the function does
- Additional sentences: important behavior, edge cases, platform differences
- Leave off trailing period for single-phrase descriptions
- Use periods when writing multiple sentences
Parameter Documentation
setUpdateInterval(intervalMs: number): void {
Format: @param paramName Description starting with capital letter
Parameters can include:
- Markdown formatting (links, emphasis, lists)
- Blockquotes for important notes
- Links to documentation pages
Type and Interface Documentation
Document each property individually:
export type GetImageOptions = {
format: 'png' | 'jpeg';
jpegQuality?: number;
};
Teach something useful. Bad: "The width". Good: "The width of the captured photo, measured in pixels".
Supported TSDoc Tags
| Tag | Purpose | Example |
|---|
@param | Parameter description | @param options Configuration for the request |
@return / @returns | Return value description | @return A promise fulfilled with the result |
@default | Default value (no markdown, rendered as inline code) | @default 1 |
@platform | Platform availability (android, ios, web, expo) | @platform ios 11+ |
@example | Code example (placed at bottom of description) | See examples below |
@deprecated | Deprecation notice (auto-formatted as warning) | @deprecated Use newMethod() instead |
@experimental | Experimental API label | @experimental |
@hidden / @internal / @private | Hide from generated docs | @hidden |
@header | Group methods under custom headers | @header Scheduling |
@needsAudit | Mark for security/API audit (comment, not tag) | // @needsAudit |
@hideType | Hide generated Type callout for constants | @hideType |
Platform tag notes:
- Do NOT use
@platform when all platforms are supported — only add when limiting availability
- Use multiple
@platform tags for multiple platforms (one per line)
- Can specify minimum version:
@platform ios 11+
- Available platforms:
android, ios, web, expo (Expo Go)
Code Examples in Docblocks
Always wrap in triple backticks with language tag:
Blockquote Notes and Warnings
Use > blockquotes for important callouts:
Formats:
> **Note:** — informational
> **warning** — caution (lowercase "warning")
- Multi-line notes use
> on each line with blank > between paragraphs
Constant Documentation
export const isDevice: boolean = ExpoDevice.isDevice;
Enum Documentation
Document the enum and individual values:
export enum ContentType {
PLAIN_TEXT = 'plain-text',
HTML = 'html',
IMAGE = 'image',
URL = 'url',
}
Return Value Language
Use "resolves to" in @returns tags, following MDN's convention:
- Preferred:
@returns A promise that resolves to a CameraPhoto object.
- Also acceptable:
@returns A promise fulfilled with a CameraPhoto object.
In inline prose, "resolves with" is acceptable (e.g. "The promise resolves with the parsed result").
Type Export Patterns
Critical: Types must be exported from the entry point file for docs generation to pick them up.
Direct re-export from types file:
export {
type FileCreateOptions,
type DirectoryCreateOptions,
type FileHandle,
} from './Module.types';
Re-export after import:
import { NotificationFeedbackType, ImpactFeedbackStyle } from './Haptics.types';
export { NotificationFeedbackType, ImpactFeedbackStyle };
The GenerateDocsAPIData script processes the entry point specified in its package mapping and extracts all publicly exported symbols.
Writing Usage Examples (for .mdx docs)
When writing examples in documentation pages:
Code Block Format
```ts app/(tabs)/index.tsx
import * as FileSystem from 'expo-file-system';
const content = await FileSystem.readAsStringAsync(uri);
Always include:
- Language tag (`ts`, `tsx`, `js`, `json`, `swift`, `kotlin`)
- File path label when showing where code goes
### Interactive Snack Examples
```jsx
<SnackInline label="Basic file read" dependencies={['expo-file-system']}>
```tsx
import * as FileSystem from 'expo-file-system';
export default function App() {
// ...
}
```
Collapsible Examples
<Collapsible summary="Advanced usage with error handling">
```ts
try {
const result = await someAsyncOperation();
} catch (error) {
console.error('Operation failed:', error);
}
```
API Reference Section
End documentation pages with:
<APISection packageName="expo-file-system" apiName="FileSystem" />
This auto-generates the API reference from TSDoc comments.
Quick Reference
Do:
- Use third-person declarative ("Gets", "Returns", "Checks")
- Document behavior beyond params/returns (failures, side effects, concurrency)
- Use
@platform tags for platform-specific APIs
- Include practical
@example blocks
- Export types from entry points
Don't:
- Write useless descriptions ("The width" for a width property)
- Use imperative mood ("Get the value")
- Skip documentation for complex behavior
- Forget to re-export types for docs generation
- Use
@link tag (not supported — use standard markdown links)
- Add
@platform tags when all platforms are supported