Skip to content

A comprehensive guide to learning Object-Oriented Programming (OOP) in TypeScript, complete with detailed notes and hands-on exercises.

License

Notifications You must be signed in to change notification settings

ah-materials/typescript-oop-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TypeScript OOP Learning Guide

A comprehensive guide to learning Object-Oriented Programming (OOP) in TypeScript, complete with detailed notes and hands-on exercises.

πŸ“š What's Included

This repository contains everything you need to master TypeScript OOP concepts:

Study Notes (8 Topics + Reference)

All documentation is organized in the docs/ folder:

  1. Real-World Use Cases - Understanding when and why to use classes
  2. Classes and Objects - Comprehensive guide covering classes, objects, properties, constructors, methods, and the this keyword
  3. Static Members - Class-level properties and methods
  4. Inheritance - Extending classes, super keyword, and method overriding
  5. Getters and Setters - Property accessors, validation, and computed properties
  6. Access Modifiers & Encapsulation - public, private, protected, and readonly
  7. Abstract Classes - Abstraction, abstract methods, and templates
  8. Interfaces & Polymorphism - Contracts, multiple implementations, and polymorphism

Quick Reference:

  • Keywords Reference - Complete reference for all OOP keywords (class, new, this, static, extends, super, etc.)

Exercises (37 Challenges)

Progressive exercises organized by lesson:

πŸš€ Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • TypeScript (v4 or higher)
  • A code editor (VS Code recommended)

Installation

For Learners (Tracking Your Own Progress)

  1. Fork this repository on GitHub (click the "Fork" button at the top right)

  2. Clone YOUR fork to your local machine:

git clone https://github.com/YOUR-USERNAME/typescript-oop-guide.git
cd typescript-oop-guide
  1. Set up the upstream remote (this is how you'll get updates):
git remote add upstream https://github.com/ah-materials/typescript-oop-guide.git
git remote -v  # Verify it's set up correctly
  1. Install dependencies:
npm install

For Contributors (Adding New Content/Fixes)

See CONTRIBUTING.md for detailed instructions.

πŸ“– How to Use This Guide

For Learners

  1. Read the notes in order:

  2. Complete the exercises:

    • Each lesson has its own folder in exercises/ (e.g., exercises/lesson-01/)
    • Lesson 01 contains 7 exercises covering all foundational concepts; other lessons contain 5 exercises each
    • Exercises have progressive difficulty (Easy β†’ Medium β†’ Hard)
    • Read the README.md in each lesson folder for exercise descriptions
    • Complete exercises in order within each lesson
    • Run your solutions with: npx ts-node exercises/lesson-<number>/<file-name>.ts
    • Commit your solutions to your forked repository to track your progress
  3. Practice and experiment:

    • Modify the examples from the notes
    • Try creating your own classes
    • Combine concepts in creative ways

Working with Exercises

Finding exercises:

Each lesson has its own directory:

exercises/
β”œβ”€β”€ lesson-01/          # Classes, Objects, Properties, Constructors, Methods, and `this`
β”‚   β”œβ”€β”€ README.md       # Exercise descriptions and requirements
β”‚   β”œβ”€β”€ 01-simple-class-easy.ts
β”‚   β”œβ”€β”€ 02-class-with-methods-easy.ts
β”‚   β”œβ”€β”€ 03-multiple-objects-medium.ts
β”‚   β”œβ”€β”€ 04-object-interactions-medium.ts
β”‚   β”œβ”€β”€ 05-library-system-hard.ts
β”‚   β”œβ”€β”€ 06-parameter-properties-medium.ts
β”‚   └── 07-this-context-problem-medium.ts
β”œβ”€β”€ lesson-02/          # Static Members
β”œβ”€β”€ lesson-03/          # Inheritance
β”œβ”€β”€ lesson-04/          # Getters and Setters
β”œβ”€β”€ lesson-05/          # Access Modifiers and Encapsulation
└── ... (lesson-06 through lesson-07)

Completing exercises:

  1. Navigate to the lesson folder (e.g., exercises/lesson-01/)
  2. Read the README.md for exercise requirements
  3. Edit the exercise TypeScript files (they start as empty templates)
  4. Run your solution: npx ts-node exercises/lesson-01/01-simple-class-easy.ts
  5. Test thoroughly and move to the next exercise

Running exercise files:

# Run exercises from any lesson
npx ts-node exercises/lesson-01/01-simple-class-easy.ts
npx ts-node exercises/lesson-01/08-parameter-properties-medium.ts
npx ts-node exercises/lesson-09/05-complete-application-hard.ts

Saving your work:

  • Commit your exercise solutions in your forked repository to track your learning progress
  • Your solutions are personal - don't create PRs to submit exercise solutions
  • Focus on learning at your own pace!

πŸ”„ Keeping Your Fork Updated

IMPORTANT: This repository is regularly updated with new exercises, bug fixes, and improvements. Check for updates weekly!

⚠️ DO NOT create Pull Requests from your fork back to this repository if you're just completing exercises. That's not how you get updates - follow the steps below instead.

How to Get New Updates

Every week (or before starting a new lesson), run these commands to pull the latest changes:

# 1. Check what's new in the original repository
git fetch upstream

# 2. Make sure you're on your main branch
git checkout main

# 3. Merge the updates from the original repo into your fork
git merge upstream/main

# 4. Push the updates to your fork on GitHub
git push origin main

What this does:

  • git fetch upstream - Downloads the latest changes from the original repository
  • git merge upstream/main - Combines those changes with your work (your exercise solutions stay intact!)
  • git push origin main - Updates your fork on GitHub

Tip: Always commit your work before updating to avoid losing your progress!

Recommended Workflow for Learners

Work directly on your main branch to keep things simple:

  1. Complete exercises and commit regularly:

    git add .
    git commit -m "Complete lesson 3 exercises"
    git push origin main
  2. When you need updates, follow the steps in "How to Get New Updates" above

Why work on main? Working directly on main keeps your workflow simple and prevents GitHub from showing the "Compare & pull request" button that appears when you push feature branches. This helps avoid confusion since learners should NOT create pull requests for their exercise solutions.

πŸ“‹ Learning Path

The documentation is structured to build progressively:

Basics (Understanding the Foundation)
β”œβ”€β”€ 00: Why use classes?
└── 01: Comprehensive guide - classes, objects, properties, constructors, methods, and `this`
    ↓
Class-Level Features
└── 02: Static members (class-level vs instance-level)
    ↓
Code Reuse Through Inheritance
└── 03: Inheritance (code reuse through extension, subclasses)
    ↓
Advanced Property Access
β”œβ”€β”€ 04: Getters and setters (controlled access patterns)
└── 05: Access control (public, private, protected, readonly)
    ↓
Advanced Concepts (Abstraction and Contracts)
β”œβ”€β”€ 06: Abstract classes (templates for subclasses)
└── 07: Interfaces & polymorphism (contracts and flexibility)

🀝 Contributing

Are You a Learner or Contributor?

πŸ‘¨β€πŸŽ“ If you're just completing exercises: DO NOT create Pull Requests! Just commit your solutions to your fork and use git fetch upstream + git merge upstream/main to get updates. See the Keeping Your Fork Updated section above.

πŸ› οΈ If you want to contribute improvements to the learning materials: We welcome contributions! See below.


What We're Looking For

Contributions to improve the learning materials are welcome:

  • Additional exercises with clear requirements and examples
  • Improvements to existing notes (clarity, examples, corrections)
  • Advanced topics (generics, decorators, mixins, design patterns)
  • Code examples demonstrating real-world use cases
  • Bug fixes or typo corrections

Quick Start for Contributors

  1. Fork this repository
  2. Clone your fork and set up the upstream remote
  3. Create a new branch (git checkout -b your-name/feature-description)
  4. Make your changes to the learning materials
  5. Test thoroughly
  6. Commit and push to your fork
  7. Open a Pull Request describing your improvements

For detailed contribution instructions, including how to set up your development environment and guidelines for different types of contributions, see CONTRIBUTING.md.

πŸ“ Exercise Solutions

Solutions are intentionally not included to encourage independent learning. If you're stuck:

  1. Review the relevant note file in the docs/ folder
  2. Check the Keywords Reference
  3. Check TypeScript documentation
  4. Experiment with different approaches
  5. Ask for help in the discussions section

πŸ“š Additional Resources

πŸ“„ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

Created as a comprehensive learning resource for developers learning TypeScript OOP concepts.


Happy Learning! πŸš€

If you find this guide helpful, please consider giving it a star ⭐

About

A comprehensive guide to learning Object-Oriented Programming (OOP) in TypeScript, complete with detailed notes and hands-on exercises.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published