README.md raw

TypeScript Examples

This directory contains practical TypeScript examples demonstrating various patterns and features.

Examples

  1. type-system-basics.ts - Fundamental TypeScript types and features
  2. advanced-types.ts - Generics, conditional types, and mapped types
  3. react-patterns.ts - Type-safe React components and hooks
  4. api-patterns.ts - API response handling with type safety
  5. validation.ts - Runtime validation with Zod and TypeScript

How to Use

Each example file is self-contained and demonstrates specific TypeScript concepts. They're based on real-world patterns used in the Plebeian Market application and follow best practices for:

Running Examples

These examples are TypeScript files that can be:

# Run an example
npx ts-node examples/type-system-basics.ts

Learning Path

  1. Start with type-system-basics.ts to understand fundamentals
  2. Move to advanced-types.ts for complex type patterns
  3. Explore react-patterns.ts for component typing
  4. Study api-patterns.ts for type-safe API handling
  5. Review validation.ts for runtime safety

Each example builds on previous concepts, so following this order is recommended for learners.