// type alias function
type EatType = (food: string) => void;

// interface function
interface IEat {
  (food: string): void;
}

// type alias array
type personList = string[];

// interface array
interface IPersonList {
  //indexable
  [index: number]: string;
}
//intersection
interface ErrorHandling {
  success: boolean;
  error?: { message: string };
}

interface ArtistData {
  artists: { name: string }[];
}

// type alias
type ArtistsResponseType = ArtistData & ErrorHandling;

//interface
interface IArtistsResponse extends ArtistData, ErrorHandling {}

let art: ArtistsResponseType;
let iar: IArtistsResponse;
//union types
interface Bird {
  fly(): void;
  layEggs(): void;
}

interface Fish {
  swin(): void;
  layEgges(): void;
}

type PetType = Bird | Fish;

interface IPet extends PetType {} // error!

class Pet implements PetType {} // error!
//Declaration Merging - interface (alias 불가능)
//기존의 인터페이스에서 뭔가를 추가 할 때 유용하다.
interface MergingInterface {
  a: string;
}

interface MergingInterface {
  b: string;
}

// 이름이 같아서 합쳐졌다. a , b 모두 접근 가능하다.
const mm: MergingInterface = {
  a: 'a',
  b: 'b',
};

mm.a;
mm.b;
console.log(mm.a, mm.b); // a b

// 나중에 기존의 인터페이스에 뭔가를 추가 할 때 한번 더 선언해서 추가 해 줄 수 있다.