interface IUser {
  name: string;
  email: string;
  getInfo(): string;
}

type UserType = {
  name: string;
  email: string;
  getInfo: () => string;
};

export class User implements IUser {
  constructor(public name: string, public email: string) {}

  getInfo(): string {
    return `${this.name} (${this.email})`;
  }
}

const _user: UserType = {
  name: 'Bob',
  email: 'bob@mail.com',
  getInfo: function (): string {
    return 'xy';
  },
};

interface IAdmin extends IUser {
  role: 'admin' | 'user';
}

const admin: Partial<IAdmin> = {
  role: 'admin',
};

interface IUserExtended {
  readonly id: string;
  name: string;
  email: string;
  phone?: string;
}

const user: IUserExtended = {
  id: 'id',
  name: 'Fritz',
  email: 'fritz@mail.com',
};

user.phone = '555';
user.name = 'Heinz';
// user.id = ""

interface UserAttribues {
  propertyName: string;
  [key: string]: string | number;
}

const userAttribues: UserAttribues = {
  propertyName: 'value',
  name: 'Charly',
};

console.log(userAttribues.propertyName);
console.log(userAttribues['propertyName']);

console.log(userAttribues['name']);

interface Animal {
  name: string;
}

interface Animal {
  age: number;
}

// const animal: Animal = {
//   age
// }

interface Dog extends Animal {
  breed: string;
}

type Vehicle = {
  brand: string;
};

type Model = {
  model: string;
};

// type Car = Vehicle & {
//   model: string;
// }
type Car = Vehicle & Model;

const car: Car = {
  model: 'X',
  brand: 'Car',
};
console.log(car);

type Status = 'success' | 'error' | 'loading';

interface HttpResponse {
  status: Status;
  data: any;
}

interface HttpResponse {
  headers: Record<string, string>;
}

const response: HttpResponse = {
  status: 'success',
  data: {},
  headers: {},
};
