
type Animal = {
name: string;
color: string;
};
type Dog = {
name: string;
color: string;
breed: string;
};
let animal: Animal = {
name: "기린",
color: "yellow",
};
let dog: Dog = {
name: "두부",
color: "white",
breed: "포메라니안",
};
animal = dog;
dog = animal;
실제 타입에 정의하지 않은 프로퍼티를 작성했을 때 발생
let book3: Book = programmingBook;
function func(book: Book) {}
func({
name: "TypeScript",
price: 33000,
// skill: "typeScript",
});
func(programmingBook);
이처럼 서브 타입 객체를 넣기 위해서는 객체 리터럴을 이용하는게 아닌 변수에 저장해두었다 인수로 변수를 전달해야 함.
한 입 크기로 잘라먹는 타입스크립트
https://www.inflearn.com/course/한입-크기-타입스크립트/dashboard