About export-public-types
A TypeScript skill for library authors designing public APIs. It explains why every type used in public signatures and return values should be exported so library users can reference it.
Key features
- 01Public API type export guidance
- 02Types in function signatures
- 03Types in return values
- 04Library interface design
Use cases
- 01Publishing TypeScript libraries
- 02Exposing types used by public functions
- 03Designing reusable component interfaces
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ marius-townhouse/ effective-typescript-skills --skill export-public-typesAfter installing, type/export-public-typesin Claude Code to confirm it loaded.
Details
From the project READMEExport All Types That Appear in Public APIs
Overview
When you publish a library, users need access to all types that appear in your public API. If a function returns User but User isn't exported, users can't type their own variables to match. Export all types that appear in public function signatures, return types, or interfaces.
This is essential for good developer experience in libraries.
When to Use This Skill
- Publishing TypeScript libraries
- Types appear in public function signatures
- Users need to reference your types
- Building reusable components
- Designing library interfaces
The Iron Rule
Export every type that appears in your public API. Users need these types to work with your library effectively.
Example
// BAD: Internal type not exported
interface User {
id: string;
name: string;
}
export function getUser(id: string): User {
// ...
}
// User can't do:
// import { getUser, User } from 'library'; // Error: User not exported
// const user: User = getUser('123');
// GOOD: Export the type
export interface User {
id: string;
name: string;
}
export function getUser(id: string): User {
// ...
}
// User can now:
// import { getUser, User } from 'library';
// const user: User = getUser('123');
Reference
- Effective TypeScript, 2nd Edition by Dan Vanderkam
- Item 67: Export All Types That Appear in Public APIs