type UserID = string | number;

let user1: UserID = 123;
let user2: UserID = 'abc123';

// Interface nur für Objekte
interface Person {
  name: string;
}

// Type kann Union Types enthalten
type Direction = 'north' | 'south' | 'east' | 'west';
type Status = 'active' | 'inactive' | 'banned';

let status: Status = 'active';
let direction: Direction = 'west';

// Union Types
type Result<T> = {
  data: T;
  error: string | null;
};

// Funktion-Types
type CallbackFn = (error: Error | null, data: any) => void;

// Literal Types
type AddFunction = (a: number, b: number) => number;

const add: AddFunction = (x, y) => x + y;
console.log(add(3, 5)); // 8

type UserRoles = Record<string, 'admin' | 'user' | 'guest'>;

const roles: UserRoles = {
  alice: 'admin',
  bob: 'user',
  charlie: 'guest',
};
