[S5] 객체 타입
https://github.com/OneMoreBottlee/TypeScript-Master/tree/main/S5
function printName(person: { first: string; last: string }): void {
console.log(`${person.first} ${person.last}`);
}
printName({ first: "hh", last: "aaaaa" });초과 프로퍼티
// 초과 프로퍼티
// 아래와 같이 지정되지 않은 인자를 추가하면 에러가 발생함.
printName({ first: "Mike", last: "Jagger", age: 476 });
// 하지만 변수에 설정한 후 호출하면 에러가 사라짐
const sig = { first: "Mike", last: "Jagger", age: 476, isAlive: true }
printName(sig)
// 필요한 것만 전달하고 나머지는 전달하지 않음Type Alias 타입 별칭
중첩 객체
선택적 프로퍼티
readonly
교차 타입
Last updated