// Explicit typing let username: string = "Alice"; let age: number = 30; let isActive: boolean = true; // Type inference (hover to see TS inferred type) let city = "Paris"; // string let score = 99.5; // number

// Typed parameters and return value function greet(name: string, greeting?: string): string return `$greeting ?? "Hello", $name`;

console.log(fruits, numbers, person, taskStatus); src/features/3-functions.ts

// Generic function function identity<T>(value: T): T return value;

// Generic constraint function getLength<T extends length: number >(item: T): number return item.length;

// Literal types let direction: "north" | "south" | "east" | "west"; direction = "north"; // OK // direction = "up"; // Error