Files
learning-platform/app/services/ingestion/test-files/sample.md
RaymondVerhoef 472685f0d7 Add specifications for gamification, generation, and R42 chat services
- Introduced gamification service spec detailing responsibilities, API surface, XP calculation, levels, streaks, badges, milestone cards, and heatmap data.
- Added generation service spec outlining the process for generating micro learning content, including API endpoints, AI call configuration, prompt strategies, and error handling.
- Created R42 chat service spec covering chatbot interactions, retrieval pipeline, prompt construction, response generation, and stateless design principles.
2026-05-23 18:13:08 +02:00

2.2 KiB

Introduction to TypeScript

TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.

Type System

TypeScript adds optional static typing and class-based object-oriented programming to the language. Types provide a way to describe the shape of an object, providing better documentation, and allowing TypeScript to validate that your code is working correctly.

Basic Types

TypeScript supports several basic types including string, number, boolean, array, and tuple. These types allow you to add type annotations to your variables and function parameters.

Interfaces

Interfaces define the shape of an object in TypeScript. They are a powerful way to define contracts within your code as well as contracts with code outside of your project.

interface User {
  name: string;
  age: number;
  email?: string;
}

An interface can define optional properties using the ? operator. This is useful when some properties may or may not be present.

Classes

TypeScript supports full class-based object-oriented programming with inheritance, interfaces, and access modifiers. Classes provide a clean and reusable way to create objects.

class Animal {
  private name: string;
  
  constructor(name: string) {
    this.name = name;
  }
  
  public move(distance: number = 0): void {
    console.log(`${this.name} moved ${distance}m.`);
  }
}

Access modifiers (public, private, protected) control visibility of class members.

Generics

Generics provide a way to make components work with any data type and not restrict to one data type. They allow users to consume these components and use their own types.

function identity<T>(arg: T): T {
  return arg;
}

Generics are particularly useful for building reusable data structures and functions that work across multiple types.

Enums

Enumerations allow you to define a set of named constants. TypeScript provides both numeric and string-based enums.

enum Direction {
  Up = "UP",
  Down = "DOWN",
  Left = "LEFT",
  Right = "RIGHT",
}

String enums are more readable than numeric enums because they provide meaningful string values at runtime.