타입스크립트 핸드북 16장 - 조건부 타입

https://typescript-kr.github.io/pages/advanced-types.html#%EC%A1%B0%EA%B1%B4%EB%B6%80-%ED%83%80%EC%9E%85-conditional-types T extends U ? X : Y T가 U에 할당될 수 있다면 X 타입이 된다. T가 U에 할당 불가능한 경우 Y 타입이 된다. 조건부 타입은 다음의 특징을 가진다. 타입이 X 또는 Y로 결

타입스크립트 핸드북 15장 - 매핑 타입

https://typescript-kr.github.io/pages/advanced-types.html#%EB%A7%A4%ED%95%91-%ED%83%80%EC%9E%85-mapped-types 기존 타입을 ‘매핑’ 하여 각 프로퍼티를 변환한 신규 타입을 만드는 방법 type Readonly<T> = { readonly [P in keyof T]: T[P]; } type Partial<T> = { [P in keyof T]?: T[P]; } type PersonPartial = Partial<Person>; type readonlyPerson

타입스크립트 핸드북 14장 - 인덱스 타입

https://typescript-kr.github.io/pages/advanced-types.html#%EC%9D%B8%EB%8D%B1%EC%8A%A4-%ED%83%80%EC%9E%85-index-types 동적인 프로퍼티 이름을 사용하는 코드를 컴파일러가 알게 하고 싶은 경우 function pluck<T, K extends keyof T>(o: T, propertyNames: K[]): T[K][] { return propertyNames.map(n => o[n]); } interface Car { manufacturer: string; model: string; year: number; } let taxi: Car = { manufacturer: 'Toyota', model: 'Camry', year: 2014 }; //

타입스크립트 핸드북 13장 - 다형성 this 타입

https://typescript-kr.github.io/pages/advanced-types.html#%EB%8B%A4%ED%98%95%EC%84%B1-this-%ED%83%80%EC%9E%85-polymorphic-this-types class BasicCalculator { public constructor(protected value: number = 0) { } public currentValue(): number { return this.value; } public add(operand: number): this { this.value += operand; return this; } public multiply(operand: number): this { this.value *= operand; return this; } // ... 다른 연산들은 여기에 작성 ... } let v = new BasicCalculator(2) .multiply(5) .add(1) .currentValue(); class ScientificCalculator extends BasicCalculator { public

타입스크립트 핸드북 12장 - 판별 유니온

https://typescript-kr.github.io/pages/advanced-types.html#%ED%8C%90%EB%B3%84-%EC%9C%A0%EB%8B%88%EC%96%B8-discriminated-unions 싱글톤 패턴 + 유니언 타입 + 타입 가드 + type alias의 짬뽕 아래의 3가지 요소로 구성된다. 공통 싱글톤 타입 프로퍼티를 가지는 타입 해당 타입들의 유니언으로써

타입스크립트 핸드북 11장 - 널러블 타입

https://typescript-kr.github.io/pages/advanced-types.html#%EB%84%90%EB%9F%AC%EB%B8%94-%ED%83%80%EC%9E%85-nullable-types Nullable Types null과 undefined는 아무 것에나 할당 가능하다. 이를 방지하기 위한 tsconfig 플래그 값이 --strictNullChecks TS 3.7 이후부터는 optional chaining을 사용할 수 있다. 타