Skip to content

Hands on TypeScript learning repository with comprehensive examples covering core types, advanced patterns, React, and Node.js. Features structured curriculum, practical exercises, and progressive difficulty. Perfect for JavaScript developers transitioning to TypeScript and building type-safe full stack applications with modern best practices.

License

Notifications You must be signed in to change notification settings

pranav89624/Learn-Typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ“š Learn TypeScript - Complete Hands-On Guide

TypeScript License: MIT Node.js React

A comprehensive, hands-on TypeScript learning repository covering everything from basic types to advanced patterns, React integration, and Node.js backend development.

Welcome to your complete TypeScript learning journey! This repository is designed to take you from TypeScript beginner to advanced developer through practical, real-world examples and structured learning paths.


🎯 What You'll Learn

This repository covers everything you need to become proficient in TypeScript:

  • βœ… Core TypeScript Fundamentals - Master the building blocks
  • βœ… Intermediate Concepts - Object-oriented programming, interfaces, and advanced patterns
  • βœ… Advanced Type System - Generics, conditional types, utility types, and type-level programming
  • βœ… React + TypeScript - Build type-safe, scalable frontend applications
  • βœ… Node.js + TypeScript - Create robust backend services and APIs

πŸ—‚οΈ Repository Structure

Learning TypeScript/
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“‚ 1-core-types/           # TypeScript Fundamentals
β”‚   β”‚   β”œβ”€β”€ 01-primitives.ts       # Basic types (string, number, boolean)
β”‚   β”‚   β”œβ”€β”€ 02-arrays-tuples.ts    # Collections and fixed arrays
β”‚   β”‚   β”œβ”€β”€ 03-enums.ts           # Enumeration types
β”‚   β”‚   β”œβ”€β”€ 04-objects.ts         # Object typing and interfaces
β”‚   β”‚   β”œβ”€β”€ 05-functions.ts       # Function signatures and overloads
β”‚   β”‚   β”œβ”€β”€ 06-union-types.ts     # Multiple possible types
β”‚   β”‚   β”œβ”€β”€ 07-type-guards.ts     # Runtime type checking
β”‚   β”‚   β”œβ”€β”€ 08-intersection-types.ts # Combining types
β”‚   β”‚   β”œβ”€β”€ 09-literal-types.ts   # Exact values as types
β”‚   β”‚   β”œβ”€β”€ 10-type-inference.ts  # Automatic type detection
β”‚   β”‚   β”œβ”€β”€ 11-type-assertions.ts # Manual type casting
β”‚   β”‚   β”œβ”€β”€ 12-never-type.ts      # Impossible values
β”‚   β”‚   β”œβ”€β”€ 13-typeof-keyof.ts    # Type operators
β”‚   β”‚   β”œβ”€β”€ πŸ“ notes.md           # Detailed explanations
β”‚   β”‚   β”œβ”€β”€ πŸ“ README.md          # Section guide
β”‚   β”‚   β”œβ”€β”€ πŸ“ recap.md           # Key takeaways
β”‚   β”‚   └── πŸ“ quiz-answers.md    # Practice solutions
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ 2-intermediate-types/   # Intermediate Concepts
β”‚   β”‚   β”œβ”€β”€ 01-type-aliases.ts    # Custom type definitions
β”‚   β”‚   β”œβ”€β”€ 02-interfaces.ts      # Contract definitions
β”‚   β”‚   β”œβ”€β”€ 03-aliases-vs-interfaces.ts # When to use each
β”‚   β”‚   β”œβ”€β”€ πŸ“ 04-oop/            # Object-Oriented Programming
β”‚   β”‚   β”‚   β”œβ”€β”€ 01-classes-objects.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 02-constructors.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 03-this-keyword.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 04-access-modifiers.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 05-inheritance.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 06-getters-setters.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 07-static-members.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 08-abstract-classes.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ 09-oop-patterns.ts
β”‚   β”‚   β”‚   β”œβ”€β”€πŸ“ oop-notes.md           # Detailed explanations
β”‚   β”‚   β”‚   β”œβ”€β”€πŸ“ README.md              # Section guide
β”‚   β”‚   β”‚   β””β”€β”€πŸ“ recap.md               # Key takeaways
β”‚   β”‚   β”œβ”€β”€ 05-method-overloading.ts
β”‚   β”‚   β”œβ”€β”€ 06-function-overloading.ts
β”‚   β”‚   β”œβ”€β”€ 07-namespaces.ts
β”‚   β”‚   β”œβ”€β”€ 08-modules.ts
β”‚   β”‚   β”œβ”€β”€ 09-index-signatures.ts
β”‚   β”‚   β”œβ”€β”€ 10-optional-readonly.ts
β”‚   β”‚   β”œβ”€β”€ 11-unknown-vs-any.ts
β”‚   β”‚   β”œβ”€β”€ 12-satisfies-operator.ts
β”‚   β”‚   β”œβ”€β”€ 13-declaration-merging.ts
β”‚   β”‚   β”œβ”€β”€ πŸ“ notes.md           # Detailed explanations
β”‚   β”‚   β”œβ”€β”€ πŸ“ README.md          # Section guide
β”‚   β”‚   β”œβ”€β”€ πŸ“ recap.md           # Key takeaways
β”‚   β”‚   └── πŸ“ quiz-answers.md    # Practice solutions
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ 3-advanced-types/       # Advanced Type System
β”‚   β”‚   β”œβ”€β”€ 01-type-narrowing.ts  # Smart type refinement
β”‚   β”‚   β”œβ”€β”€ 02-generics.ts        # Reusable type parameters
β”‚   β”‚   β”œβ”€β”€ 03-conditional-types.ts # Type-level conditionals
β”‚   β”‚   β”œβ”€β”€ 04-infer-keyword.ts   # Type inference in conditions
β”‚   β”‚   β”œβ”€β”€ 05-discriminated-unions.ts # Tagged unions
β”‚   β”‚   β”œβ”€β”€ 06-mapped-types.ts    # Transform existing types
β”‚   β”‚   β”œβ”€β”€ 07-key-remapping.ts   # Advanced key manipulation
β”‚   β”‚   β”œβ”€β”€ 08-template-literal-types.ts # String type manipulation
β”‚   β”‚   β”œβ”€β”€ 09-utility-types.ts   # Built-in helper types
β”‚   β”‚   β”œβ”€β”€ 10-type-level-functions.ts # Complex type operations
β”‚   β”‚   β”œβ”€β”€ 11-branded-types.ts   # Nominal typing patterns
β”‚   β”‚   β”œβ”€β”€ 12-recursive-types.ts # Self-referencing types
β”‚   β”‚   β”œβ”€β”€ πŸ“ notes.md           # Detailed explanations
β”‚   β”‚   β”œβ”€β”€ πŸ“ README.md          # Section guide
β”‚   β”‚   β”œβ”€β”€ πŸ“ recap.md           # Key takeaways
β”‚   β”‚   └── πŸ“ quiz-answers.md    # Practice solutions
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ 4-typescript-in-react/  # React + TypeScript
β”‚   β”‚   β”œβ”€β”€ πŸ“ react-playground/  # Live React examples
β”‚   β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ components/   # Typed React components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ concepts/     # Learning modules
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 01-props-and-state/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 02-events-and-forms/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 03-hooks-and-refs/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 04-context-api/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 05-custom-hooks-generics/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 06-component-composition/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ 07-typing-external-data/
β”‚   β”‚   β”‚   β”‚   β”‚   └── 08-practical-ui-types/
β”‚   β”‚   β”‚   β”‚   └── App.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ package.json      # React dependencies
β”‚   β”‚   β”‚   └── vite.config.ts    # Vite configuration
β”‚   β”‚   β”œβ”€β”€ πŸ“ notes.md           # Detailed explanations
β”‚   β”‚   β”œβ”€β”€ πŸ“ README.md          # Section guide
β”‚   β”‚   β”œβ”€β”€ πŸ“ recap.md           # Key takeaways
β”‚   β”‚   └── πŸ“ quiz-answers.md    # Practice solutions
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ 5-typescript-in-node/   # Node.js + TypeScript
β”‚   β”‚   β”œβ”€β”€ src/
|   |   |   β”œβ”€β”€ 01-basic-types.ts     # Node.js type basics
β”‚   β”‚   |   β”œβ”€β”€ 02-modules-and-esm.ts # Module systems   
β”‚   β”‚   |   β”œβ”€β”€ 03-working-with-fs.ts # File system operations
β”‚   β”‚   |   β”œβ”€β”€ 04-node-builtins.ts   # Built-in modules
β”‚   β”‚   |   β”œβ”€β”€ 05-type-safe-env.ts   # Environment variables
β”‚   β”‚   |   β”œβ”€β”€ 06-simple-server.ts   # HTTP server basics
β”‚   β”‚   |   β”œβ”€β”€ 07-express-basics.ts  # Express.js with TypeScript
β”‚   β”‚   |   β”œβ”€β”€ 08-error-handling.ts  # Type-safe error handling
β”‚   β”‚   |   β”œβ”€β”€ 09-routing.ts         # Route typing
β”‚   β”‚   |   β”œβ”€β”€ 10-controllers-and-services.ts
β”‚   β”‚   |   β”œβ”€β”€ 11-middlewares.ts     # Middleware typing
β”‚   β”‚   |   β”œβ”€β”€ 12-global-types.ts    # Global type definitions
β”‚   β”‚   |   β”œβ”€β”€ 13-api-response-types.ts # API response typing
β”‚   β”‚   |   β”œβ”€β”€ 14-utils-and-helpers.ts # Utility functions
β”‚   β”‚   |   β”œβ”€β”€ 15-auth-jwt.ts        # Authentication patterns
β”‚   β”‚   |   └── 16-testing-basics.test.ts # Testing with TypeScript
β”‚   β”‚   β”œβ”€β”€ πŸ“ notes.md           # Detailed explanations
β”‚   β”‚   β”œβ”€β”€ πŸ“ README.md          # Section guide
β”‚   β”‚   β”œβ”€β”€ πŸ“ recap.md           # Key takeaways
β”‚   β”‚   └── πŸ“ quiz-answers.md    # Practice solutions
β”‚   β”‚
β”œβ”€β”€ πŸ“„ package.json               # Project dependencies
β”œβ”€β”€ πŸ“„ tsconfig.json             # TypeScript configuration  
└── πŸ“„ README.md                 # This guide

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ - Download here
  • Basic JavaScript knowledge - ES6+ features
  • Code editor - VS Code recommended with TypeScript extensions

Installation

  1. Clone the repository

    git clone https://github.com/pranav89624/Learn-Typescript.git
    cd Learn-Typescript
  2. Install dependencies

    npm install
  3. Verify TypeScript installation

    npx tsc --version

Running the Code

Option 1: Compile and Run

# Compile all TypeScript files
npm run build

# Run a specific compiled file
node dist/1-core-types/01-primitives.js

Option 2: Direct TypeScript Execution

# Install ts-node globally (optional)
npm install -g ts-node

# Run TypeScript files directly
npx ts-node src/1-core-types/01-primitives.ts

Option 3: Watch Mode

# Automatically recompile on changes
npm run watch

πŸ“š Learning Path & Progression

πŸ₯‰ Beginner Level (Start Here!)

Path: src/1-core-types/

Begin your TypeScript journey with fundamental concepts:

  • Basic types and type annotations
  • Arrays, tuples, and enums
  • Object and function typing
  • Union and intersection types
  • Type inference and assertions

Goal: Understand TypeScript syntax and basic type system

πŸ₯ˆ Intermediate Level

Path: src/2-intermediate-types/

Advance to more complex patterns:

  • Interfaces vs type aliases
  • Object-oriented programming in TypeScript
  • Function and method overloading
  • Modules and namespaces
  • Advanced type modifiers

Goal: Write maintainable, object-oriented TypeScript code

πŸ₯‡ Advanced Level

Path: src/3-advanced-types/

Master the advanced type system:

  • Generic programming
  • Conditional and mapped types
  • Template literal types
  • Utility types and type manipulation
  • Type-level programming

Goal: Create flexible, reusable type-safe abstractions

βš›οΈ React Specialization

Path: src/4-typescript-in-react/

Apply TypeScript to frontend development:

  • Component and prop typing
  • Hooks and context with TypeScript
  • Event handling and forms
  • Custom hooks and composition patterns
  • External API integration

Goal: Build production-ready React applications

🌐 Node.js Specialization

Path: src/5-typescript-in-node/

Develop backend services with TypeScript:

  • Node.js built-ins and modules
  • Express.js with type safety
  • API design and error handling
  • Authentication and middleware
  • Testing strategies

Goal: Create robust backend services and APIs


πŸ’‘ How to Use This Repository

For Self-Study

  1. Follow the numbered sequence - Each section builds upon previous concepts
  2. Read the README first - Each folder has a detailed guide
  3. Study the notes - Every section includes comprehensive explanations
  4. Practice actively - Modify examples and create your own variations
  5. Test yourself - Use the quiz files to verify understanding

For Instructors

  • Modular curriculum - Each section can be taught independently
  • Progressive complexity - Concepts build naturally
  • Real-world examples - Practical, applicable code samples
  • Assessment materials - Built-in quizzes and exercises

For Reference

  • Quick lookup - Well-organized, searchable content
  • Copy-paste friendly - Production-ready code patterns
  • Best practices - Industry-standard approaches
  • Common pitfalls - Warnings about frequent mistakes

πŸ› οΈ Project Configuration

TypeScript Configuration (tsconfig.json)

{
  "compilerOptions": {
    "target": "ES6",                    // Modern JavaScript output
    "module": "commonjs",               // Node.js compatibility  
    "strict": true,                     // Maximum type safety
    "outDir": "./dist",                 // Compiled output directory
    "rootDir": "./src",                 // Source code location
    "esModuleInterop": true,            // Module interoperability
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true,
    "strictNullChecks": true,           // Prevent null/undefined errors
    "lib": ["ES2017", "DOM"]            // Available APIs
  },
  "include": ["src/**/*"]               // Files to compile
}

Available NPM Scripts

{
  "scripts": {
    "build": "tsc",                     // Compile TypeScript to JavaScript
    "start": "tsc && node dist/index.js", // Build and run
    "watch": "tsc --watch"              // Auto-recompile on changes
  }
}

πŸŽ“ Learning Tips & Best Practices

Getting the Most Out of This Repository

  1. Start with the basics - Don't skip fundamental concepts
  2. Practice regularly - Consistency beats intensity
  3. Experiment freely - Modify examples to test understanding
  4. Read error messages - TypeScript errors are educational
  5. Use strict mode - Learn proper TypeScript from the start

Common Beginner Mistakes to Avoid

  • ❌ Using any type everywhere - defeats the purpose of TypeScript
  • ❌ Ignoring compiler errors - they prevent runtime bugs
  • ❌ Not reading the notes - context and explanations are crucial
  • ❌ Rushing through sections - understanding > speed
  • ❌ Avoiding strict mode - makes learning harder later

Debugging TypeScript

# Check types without compiling
npx tsc --noEmit

# See detailed error information  
npx tsc --listFiles --explainFiles

# Generate declaration files for learning
npx tsc --declaration --emitDeclarationOnly

🌟 Key Features

  • πŸ“– Comprehensive Coverage - Everything from basics to advanced patterns
  • 🎯 Practical Examples - Real-world, applicable code samples
  • πŸ“š Extensive Documentation - Detailed notes and explanations for every concept
  • πŸ”„ Progressive Structure - Each concept builds naturally on previous ones
  • βš›οΈ Framework Integration - Specific sections for React and Node.js
  • βœ… Self-Assessment - Quizzes and exercises to test understanding
  • πŸ› οΈ Production Ready - Industry-standard configurations and practices
  • πŸ“± Beginner Friendly - Clear explanations without assuming prior knowledge

πŸ“– Additional Resources

Official Documentation

Community Resources

Advanced Learning


🀝 Contributing

We welcome contributions to improve this learning resource!

Ways to Contribute

  • πŸ› Bug Reports - Found an error? Open an issue
  • πŸ’‘ Suggestions - Ideas for new examples or explanations
  • πŸ“ Documentation - Improve existing notes and guides
  • πŸ”§ Code Examples - Add more practical examples
  • 🎯 Exercises - Create additional practice problems

Contribution Guidelines

  1. Fork the repository
  2. Create a new branch (git checkout -b feature)
  3. Make your changes with clear commit messages
  4. Test your code changes
  5. Submit a pull request with a detailed description

For detailed steps visit CONTRIBUTING.md.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

What this means:

  • βœ… Free to use for personal and commercial projects
  • βœ… Modify and distribute as needed
  • βœ… No warranty - use at your own discretion
  • βœ… Attribution appreciated but not required

πŸ‘¨β€πŸ’» Author

Pranav Verma


πŸ™ Acknowledgments

  • TypeScript Team - For creating an amazing language
  • Open Source Projects - For inspiration and examples

🎯 Ready to Master TypeScript?

⭐ Star this repository if you find it helpful!

πŸš€ Start Learning Now β€’ πŸ“š Browse Examples β€’ πŸ’¬ Get Help


Happy coding and enjoy your TypeScript learning journey! πŸš€

About

Hands on TypeScript learning repository with comprehensive examples covering core types, advanced patterns, React, and Node.js. Features structured curriculum, practical exercises, and progressive difficulty. Perfect for JavaScript developers transitioning to TypeScript and building type-safe full stack applications with modern best practices.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Languages