type

type Animal = { breath: true };
type Mammal = Animal & { breed: true };
type Human = Mammal & { think: true };

const minhyeong: Human = { breath: true, breed: true, think: true };
// 만약 아래같이 적는다면 에러가 발생한다. 
const minhyeong: Human = { breath: true }; 

Untitled

Untitled

interface로 동일하게 나타내면?

interface

interface Animal {
  breath: true;
}

interface Mammal extends Animal {
  breed: true;
}

interface Human extends Mammal {
  think: true;
}

const minhyeong: Human = { breath: true, breed: true, think: true };

마찬가지로, 아래처럼만 적는다면 에러가 발생한다.

const minhyeong: Human = { breath: true }; 

Untitled

근데 뭔가 interface 때가 에러메세지가 좀 더 깔끔한 듯?

interface로 중복 선언하기