# 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:

- Type safety
- Error handling
- Code organization
- Reusability
- Maintainability

## Running Examples

These examples are TypeScript files that can be:
- Copied into your project
- Used as reference for patterns
- Modified for your specific needs
- Run with `ts-node` for testing

```bash
# 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.

