A structured hands-on journey through TypeScript fundamentals, type systems, modern patterns, and React + TypeScript development.
| ๐ Learning Folders | ๐ Source Files | โ๏ธ React/TSX Components | ๐ช Custom Hooks |
|---|---|---|---|
16 |
28 |
5 |
1 |
- ๐ About This Repository
- ๐บ๏ธ Learning Roadmap
- ๐ Learning Journey (Folder Breakdown)
- ๐ง TypeScript Concepts Covered
- โ๏ธ React + TypeScript Integration
- ๐งฉ Component Architecture
- ๐ช Custom Hooks
- ๐งพ Shared Types Architecture
- ๐ฌ TypeScript โ React Connection
- ๐ Repository Structure
โถ๏ธ Getting Started- ๐ง Learning Philosophy
- ๐ฏ Skills Covered
- ๐ Learning Progression
- ๐ What This Repository Demonstrates
- ๐ฎ Future Roadmap
- ๐งโ๐ป Author
This repository documents a practical, step-by-step learning path for TypeScript โ progressing systematically from core syntax annotations to advanced type constructs, asynchronous data fetching, and real-world React + TypeScript web application development.
Learn
โ
Understand
โ
Write TypeScript
โ
Practice
โ
Build with React
โ
Apply Type Safety
๐ข STAGE 1 โ FOUNDATION
โโโ Type Annotations โข Basic Types โข Type Inference โข Compile-Time Checking
โ
๐ก STAGE 2 โ CORE TYPE SYSTEM
โโโ Union & Literal Types โข Type Narrowing โข Type Assertions โข Type Aliases
โ
๐ต STAGE 3 โ OBJECTS & FUNCTIONS
โโโ Object Shapes โข Optional/Default Params โข Utility Types (Partial, Required, Readonly)
โ
๐ฃ STAGE 4 โ DATA STRUCTURES & OOP
โโโ Typed Arrays โข Tuples โข Enums (Numeric, String, Const) โข Classes & OOP
โ
๐ STAGE 5 โ INTERFACES & GENERICS
โโโ Interfaces & Merging โข Generic Functions & Constraints โข Type Reusability
โ
โก STAGE 6 โ ASYNCHRONOUS TYPESCRIPT
โโโ Typed API Integration (Axios & Native Fetch) โข Promises โข Error Handling
โ
โ๏ธ STAGE 7 โ REACT + TYPESCRIPT APPLICATION
โโโ Typed Components โข PropsWithChildren โข Custom Hooks (useFetch<T>) โข Form Events
Every directory isolates a specific stage of the TypeScript learning path with practical code examples:
| ๐ Stage | ๐ Topic | ๐ Location | ๐ฏ Learning Objective |
|---|---|---|---|
| 00 | Compiler & Type Safety | 00 Ts Folder/ |
Setting up TypeScript, compile-time error detection, primitive string/number checks |
| 01 | Type Annotations | 1st Ts Folder/ |
Explicit type signatures for function parameters and return types |
| 02 | Type Inference | 2nd Ts Folder/ |
Understanding TypeScript's automatic type inference mechanism |
| 03 | Unions & Literals | 3rd Ts Folder/ |
Union types (string | number) and strict string literal unions |
| 04 | Type Narrowing | 4th Ts Folder/ |
Control-flow type narrowing using typeof guards & optional parameters |
| 05 | Assertions & unknown |
5th Ts Folder/ |
Safe type narrowing with unknown vs unsafe any and type casting |
| 06 | Type Aliases | 6th Ts Folder/ |
Creating reusable custom object type contracts using type |
| 07 | Object Types & Shapes | 7th Ts Folder/ |
Object literals, property type inference, and nested structure constraints |
| 08 | Functions & Utilities | 8th Ts Folder/ |
Function return signatures (void, null), default/optional params, Partial<T>, Required<T>, Readonly<T> |
| 09 | Arrays, Tuples & Enums | 9th Ts Folder/ |
Typed arrays (T[]), tuples ([string, number]), numeric & string enum, const enum |
| 10 | Classes & OOP | 10th Ts Folder/ |
Class constructors, access modifiers (public, private, protected), methods & instantiation |
| 11 | Interfaces | 11th Ts Folder/ |
Defining object contracts with interface, optional properties (?), inheritance (extends) |
| 12 | Generics | 12th Ts Folder/ |
Reusable type-safe code using generic parameters (<T>) and constraints |
| 13 | Axios API Integration | 13th Ts Folder/ |
Type-safe HTTP requests using Axios (axios.get<T>), async/await, error handling |
| 14 | Native Fetch API | 14th Ts Folder/ |
Typed asynchronous API calls using native fetch(), response.ok checks, JSON parsing |
| 15 | React + TypeScript App | 15th Ts Folder/ |
Full-fledged React + Vite SPA with typed components, props, hooks, forms, and custom state |
| ๐ง Concept | ๐ Primary Location | ๐ก Practical Application |
|---|---|---|
| Type Annotations | 1st Ts Folder/ |
Explicitly declaring variable and parameter types |
| Type Inference | 2nd Ts Folder/ |
Letting TypeScript infer variable types automatically |
| Union & Literal Types | 3rd Ts Folder/ |
Restricting variables to finite sets of scalar/string literal values |
| Type Guards & Narrowing | 4th Ts Folder/ |
Safely checking types at runtime using typeof conditions |
unknown Top Type |
5th Ts Folder/ |
Forcing explicit type narrowing before property access over any |
| Type Aliases | 6th Ts Folder/ |
Modeling reusable domain objects (type ChaiOrder = { ... }) |
| Function Signatures | 8th Ts Folder/ |
Return types, optional (?) & default parameters, void logging |
| Utility Types | 8th Ts Folder/ |
Standard library utilities: Partial<T>, Required<T>, Readonly<T> |
| Arrays & Tuples | 9th Ts Folder/ |
Homogeneous lists (string[]), fixed-length positional tuples ([string, number]) |
| Enums & Const Enums | 9th Ts Folder/ |
Strongly-typed constant collections (ChaiType, const enum SugarLevel) |
| Classes & Access Controls | 10th Ts Folder/ |
Object-oriented state encapsulation with public/private attributes |
| Interfaces | 11th Ts Folder/ |
API contracts, optional fields, declaration merging, class implementation |
| Generics | 12th Ts Folder/ |
Parameterized functions (wrapInArrays<T>(item: T): T[]) for maximum reusability |
| Typed Asynchronous HTTP | 13th Ts Folder/ & 14th Ts Folder/ |
Strongly-typed API client responses using Axios (axios.get<Todo>) & fetch() |
Location:
15th Ts Folder/
The culmination of the learning journey integrates TypeScript into a modern Vite + React single-page application.
React Component โโ> Typed Props Interface โโ> Strict State Types โโ> Generic Custom Hooks
The React application demonstrates real-world component design patterns:
| ๐งฉ Component | ๐ Location | ๐ฏ Purpose & TypeScript Usage |
|---|---|---|
Card |
Card.tsx |
Renders item information using an explicit CardProps interface with optional isSpecial?: boolean and default values. |
CardLayout |
Children.tsx |
Demonstrates React layout wrapping using PropsWithChildren<{ title: string; footer?: ReactNode }> for container component composition. |
Lists |
Lists.tsx |
Receives array props (List[]), map-renders nested Card components, and performs conditional prop computations (isSpecial={price > 30}). |
OrderForm |
OrderForm.tsx |
Controlled form input with typed event handlers (React.FormEvent<HTMLFormElement>) and typed callback props (onSubmit(order: { name: string; cups: number })). |
Counter |
counter.tsx |
Simple stateful component utilizing typed state hooks (useState<number>(1)). |
File:
useFetch.ts
The application features a reusable, generic asynchronous custom hook for network requests:
interface FetchState<T> {
data: T | null;
loading: boolean;
error: string | null;
}
export function useFetch<T>(url: string): FetchState<T> {
// Generic state management for API calls
}- ๐งฌ Generics (
<T>): AllowsuseFetchto fetch any data payload (e.g.List[],User,Todo) while preserving end-to-end type safety. - ๐ก๏ธ Discriminated Union / State Shape: Guarantees consumers check
loadinganderrorstates safely. - ๐ฆ Reusability: One hook satisfies all API endpoints without resorting to
any.
File:
types.ts
Shared type definitions are centralized to maintain a single source of truth across components:
export interface List {
id: number;
name: string;
price: number;
}This interface is exported and imported into App.tsx and Lists.tsx, enforcing consistent data models across component boundaries.
TypeScript Concept React Application Implementation
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Interface / Type Alias โโโ> Component Props (CardProps, OrderFormProps)
Generics (<T>) โโโ> Generic Custom Hooks (useFetch<T>)
Union Types โโโ> Component Variants & Dynamic UI States
Optional Fields (?) โโโ> Optional Props with Default Fallbacks
Type Guards (typeof) โโโ> Event Handlers & Form Input Parsing
PropsWithChildren โโโ> Layout Wrappers & Slot Composition
typescript-zero-to-advanced/
โโโ ๐ข 00 Ts Folder/ # Basic setup & compiler error checks
โ โโโ ๐ basic.ts
โโโ ๐ 1st Ts Folder/ # Function annotations
โโโ ๐ 2nd Ts Folder/ # Type inference
โโโ ๐ 3rd Ts Folder/ # Union & literal types
โโโ ๐ 4th Ts Folder/ # Type narrowing & typeof
โโโ ๐ 5th Ts Folder/ # unknown type vs assertions
โโโ ๐ 6th Ts Folder/ # Type aliases
โโโ ๐ 7th Ts Folder/ # Object shapes & type inference
โโโ ๐ 8th Ts Folder/ # Functions & Partial/Required/Readonly
โโโ ๐ 9th Ts Folder/ # Arrays, Tuples & Enums
โโโ ๐ 10th Ts Folder/ # Classes & OOP access modifiers
โโโ ๐ 11th Ts Folder/ # Interfaces & merging
โโโ ๐ 12th Ts Folder/ # Generics (<T>)
โโโ โก 13th Ts Folder/ # Axios API integration
โโโ โก 14th Ts Folder/ # Native fetch API integration
โโโ โ๏ธ 15th Ts Folder/ # React + TypeScript Application
โ โโโ ๐ Components/
โ โ โโโ ๐ Card.tsx # Typed props & defaults
โ โ โโโ ๐ Children.tsx # PropsWithChildren layout
โ โ โโโ ๐ Lists.tsx # List rendering & array props
โ โ โโโ ๐ OrderForm.tsx # Typed form & event handlers
โ โ โโโ ๐ counter.tsx # Typed useState hook
โ โโโ ๐ Hooks/
โ โ โโโ ๐ useFetch.ts # Generic custom hook <T>
โ โโโ ๐ types.ts # Shared app interfaces
โ โโโ ๐ App.tsx # Main React entry component
โ โโโ ๐ main.tsx # React DOM mount point
โ โโโ ๐ package.json # App dependencies & scripts
โ โโโ ๐ vite.config.ts # Vite configuration
โโโ ๐ README.md # Documentation
Navigate to any standalone lesson folder and compile/run with TypeScript:
# Using tsc (TypeScript Compiler) + Node
cd "00 Ts Folder"
npx tsc basic.ts
node basic.js
# Or run directly with ts-node / bun (if installed)
npx ts-node basic.tsNavigate into the React project directory, install dependencies, and start the Vite development server:
# Navigate to React project directory
cd "15th Ts Folder"
# Install dependencies
npm install
# Start Vite local development server
npm run devThen open http://localhost:5173 in your browser.
Learn Concept โโ> Write Code โโ> Compile โโ> Debug โโ> Refactor โโ> Build React App
- ๐ Learn: Understand type system mechanics and static analysis.
- โ๏ธ Write: Practice syntax in isolated TypeScript files.
- โ๏ธ Compile: Let the TypeScript compiler catch errors before runtime.
- ๐ Debug: Inspect type errors, fix narrowing issues, and refine types.
- โ๏ธ Build: Implement concepts into real-world React UIs.
- TypeScript Fundamentals: Primitive types, type annotations, compiler configuration
- Type System Mechanics: Type inference, union types, literal types
- Control-Flow Narrowing: Type guards,
typeof,unknownsafe assertions - Object & Function Modeling: Type aliases, optional parameters, function return signatures
- Built-in Utility Types:
Partial<T>,Required<T>,Readonly<T> - Data Structures: Typed arrays (
T[]), fixed-length tuples, readonly tuples - Enumerations: Numeric enums, string enums, performance-focused
const enum - Object-Oriented Programming: Classes, constructors,
public/private/protectedmodifiers - Interface Design: Object shape contracts,
extendsinheritance, optional fields - Generic Programming: Reusable generic functions (
<T>) and constraints - Asynchronous Type Safety: Typing Axios client responses & native
fetch()calls - React Integration: Typing component props,
PropsWithChildren,ReactNode - Event Handling: Typing form events (
React.FormEvent) and input change events - Custom React Hooks: Designing reusable generic custom state hooks (
useFetch<T>)
TypeScript Foundation (00 - 02)
โ
Unions, Narrowing & unknown (03 - 05)
โ
Type Aliases & Functions (06 - 08)
โ
Arrays, Tuples & Enums (09)
โ
Classes & Interfaces (10 - 11)
โ
Generics (<T>) (12)
โ
Async API Integration (13 - 14)
โ
React + TypeScript Application (15)
- ๐ก๏ธ Compile-Time Error Prevention: Eliminates
undefined is not a functionerrors before code hits production. - ๐ค Self-Documenting Code Contracts: Interfaces and type aliases serve as explicit documentation for API boundaries and component props.
- ๐ Confident Refactoring: Change data structures with confidence knowing compiler errors will flag every broken usage site.
- โ๏ธ Production-Ready React Patterns: Demonstrates type-safe component props, layout children composition, form event handling, and generic custom hooks.
Note: The following topics are planned for future learning expansion and advanced TypeScript study.
- โฌ Advanced Generics: Conditional types (
T extends U ? X : Y), infer keyword usages - โฌ Mapped & Template Literal Types: Dynamic type transformations and string template types
- โฌ Declaration Files (
.d.ts): Authoring custom ambient type definitions for untyped packages - โฌ Type-Level Programming: Utility types implementation from scratch
- โฌ Advanced React Patterns: Polymorphic components,
useReducerwith typed action unions - โฌ Full-Stack TypeScript: End-to-end type safety using Node.js, Express/NestJS, and Prisma ORM
Built and maintained with passion as part of a continuous frontend engineering and TypeScript learning journey.
โญ If you find this repository helpful for learning TypeScript, consider giving it a star! โญ
Happy Coding! ๐