fso/projects

← back to all projects

Inventory Management System (TypeScript)

Part 9 — TypeScript

Why This Project

An inventory system has the kind of data where TypeScript shines: products with different categories that have different attributes (a shirt has size and color, a laptop has RAM and storage), stock transactions (restock, sale, adjustment) with different required fields, and computed values (stock level, total value). You'll use discriminated unions, generics, and utility types in places where they naturally solve real problems.

What to Build

A system for a small store to manage their products. Add products with category-specific attributes, record stock changes (received shipment, sold, damaged/adjusted), view current inventory levels, and see a dashboard with low-stock alerts and total inventory value. Full stack: Express + MongoDB backend and React frontend, both in TypeScript. Shared type definitions between both.

Requirements

Skills Practiced

TypeScript discriminated unions type narrowing generics utility types shared types Mongoose + TypeScript typed Express handlers strict mode

Pain Point to Notice

The dynamic form that changes fields based on product category is where TypeScript earns its keep. Without types, you'd pass the wrong fields and only find out at runtime. With discriminated unions, the compiler tells you: "A ClothingProduct needs a size field, you're missing it." The form's onChange handler needs to narrow the category type before accessing category-specific fields. This is annoying at first but it prevents an entire class of bugs — sending malformed data to your API.

Resources