export-public-types

Use when publishing libraries. Use when types appear in public APIs. Use when users need to reference types. Use when building reusable components. Use when designing library interfaces.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "export-public-types" with this command: npx skills add marius-townhouse/effective-typescript-skills/marius-townhouse-effective-typescript-skills-export-public-types

Export 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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

tsdoc-comments

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

code-gen-independent

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

module-by-module-migration

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tsconfig-options

No summary provided by upstream source.

Repository SourceNeeds Review