Skip to content

Mastering TypeScript is a beginner-friendly yet powerful project designed to help developers understand and apply TypeScript fundamentals through hands-on examples. Whether you're transitioning from JavaScript or starting fresh, this project walks you through TypeScript's syntax, type system, and modular architecture with clear, practical code.

Notifications You must be signed in to change notification settings

alexcarcar/MasteringTypeScript

Repository files navigation

🧰 Mastering TypeScript

Welcome to the Mastering TypeScript Project! This simple project is designed to help you understand the basics of TypeScript, including how to set up a project, use static typing, and organize code with modules.

This Git repository contains my personal notes, code snippets, and reflections as I read through Programming with Types by Vlad Riscutia. The book offers a deep dive into TypeScript's type system, exploring concepts like structural typing, type inference, and advanced patterns for building robust applications. My notes aim to reinforce key ideas from the book and provide practical examples that complement the theoretical insights. You can learn more about the book here.

My notes on TypeScript can be accessed here.


🚀 Getting Started

1. Clone the Repository

git clone https://github.com/alexcarcar/MasteringTypeScript.git
cd typescript-demo

2. Install Dependencies

npm install

3. Compile the TypeScript Code

npx tsc

4. Run the Project

node dist/index.js

📁 Project Structure

typescript-demo/
├── src/
│   ├── index.ts        # Entry point
│   ├── utils.ts        # Utility functions
│   └── models.ts       # Type definitions
├── dist/               # Compiled JavaScript output
├── package.json        # Project metadata and scripts
└── tsconfig.json       # TypeScript configuration

🧪 Code Overview

models.ts

Defines a User interface with optional properties.

export interface User {
  id: number;
  name: string;
  email?: string;
}

utils.ts

Contains a function that uses the User type.

import { User } from './models';

export function greet(user: User): string {
  return `Hello, ${user.name}!`;
}

index.ts

Creates a user and prints a greeting.

import { greet } from './utils';
import { User } from './models';

const user: User = {
  id: 1,
  name: 'Alice'
};

console.log(greet(user));

⚙️ TypeScript Features Demonstrated

  • ✅ Static typing with interfaces
  • ✅ Optional properties
  • ✅ Modular imports/exports
  • ✅ Configuration via tsconfig.json
  • ✅ Compilation to JavaScript

📚 Resources

About

Mastering TypeScript is a beginner-friendly yet powerful project designed to help developers understand and apply TypeScript fundamentals through hands-on examples. Whether you're transitioning from JavaScript or starting fresh, this project walks you through TypeScript's syntax, type system, and modular architecture with clear, practical code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published