~타입 애일리어스와 인터페이스의 상속(extends) 까지 수강
boolean, bigint, null, number, string, symbol, object와 undefined
에서 TypeScript는 추가로 any, unknown, never, void
가 있다.객체지향프로그래밍
을 하기 위해 인터페이스를 우선적으로 사용하고, 간단하게 특정 기능이 필요할 때 타입을 사용하기.객체 지향(Object oriented) 프로그래밍이란?
# 우리가 실생활에서 쓰는 모든 것을 객체라 하며,
객체 지향 프로그래밍은 프로그램 구현에 필요한 객체를 파악하고
각각의 객체들의 역할이 무엇인지를 정의하여
객체들 간의 상호작용을 통해 프로그램을 만드는 것을 말한다.
type A = { a: string };
const a: A = { a: 'hello' };
interface B { a: string }
const b: B = { a: 'hello' };
interface A { a: string }
interface A { b: string }
const obj1: A = { a: 'hello', b: 'world' }
type B = { a: string }
type B = { b: string }
const obj2: B = { a: 'hello', b: 'world' }
// example1
type MyBool = true | false;
// example2
type WindowStates = "open" | "closed" | "minimized";
// example3
type OddNumbersUnderTen = 1 | 3 | 5 | 7 | 9;
// example1
type StringArray = Array<string>;
// example2
type ObjectWithNameArray = Array<{ name: string }>;
interface Point {
x: number;
y: number;
}
function printPoint(p: Point) {
console.log(`${p.x}, ${p.y}`);
}
// "12, 26"를 출력합니다
const point = { x: 12, y: 26 };
printPoint(point);