🎯

export-public-types

🎯Skill

from marius-townhouse/effective-typescript-skills

VibeIndex|
What it does

Exports all types used in public function signatures, return types, and interfaces to enable type referencing and improve library usability.

πŸ“¦

Part of

marius-townhouse/effective-typescript-skills(83 items)

export-public-types

Installation

Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills --all
Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills -s prefer-unknown-over-any exhaustiveness-checking
Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills -a opencode claude-code
Quick InstallInstall with npx
npx skills add marius-townhouse/effective-typescript-skills -l
git cloneClone repository
git clone https://github.com/marius-townhouse/effective-typescript-skills.git
πŸ“– Extracted from docs: marius-townhouse/effective-typescript-skills
1Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

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.

Overview

# 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

```typescript

// 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

More from this repository10

🎯
tsdoc-comments🎯Skill

Generates TypeScript documentation comments (TSDoc) to explain public APIs, complex types, and provide comprehensive code documentation with IDE tooltips.

🎯
async-over-callbacks🎯Skill

Transforms callback-based asynchronous code into clean, readable async/await patterns for better type flow and error handling.

🎯
type-safe-monkey-patching🎯Skill

Enables type-safe runtime extension of global objects and DOM elements in TypeScript without sacrificing type checking or using `as any`.

🎯
create-objects-all-at-once🎯Skill

Efficiently initializes multiple TypeScript objects simultaneously using concise object literal syntax and spread operators.

🎯
module-by-module-migration🎯Skill

Guides developers through systematic TypeScript module migration, breaking down complex refactoring into manageable, incremental steps.

🎯
ts-js-relationship🎯Skill

Explains TypeScript's relationship to JavaScript, highlighting how it adds static typing and catches errors before runtime while remaining fully compatible with JavaScript code.

🎯
code-gen-independent🎯Skill

Generates JavaScript code despite TypeScript type errors and demonstrates that TypeScript types are erased at runtime, requiring alternative type checking strategies.

🎯
context-type-inference🎯Skill

Helps restore precise type context when extracting values, preventing type inference errors through annotations, const assertions, and type preservation techniques.

🎯
precise-string-types🎯Skill

Enforces strict string type constraints and prevents unintended string type conversions in TypeScript projects.

🎯
type-display-attention🎯Skill

Displays and simplifies complex TypeScript types to improve IDE readability and developer experience.