REPL(Read-Eval-Print-Loop)
ํฐ๋ฏธ๋์์ ๊ฐ๋จํ๊ฒ REPL์ ์ฐ๊ณ ์ถ์ผ๋ฉด ts-node๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ค.
Interface vs Type
Interface์ Type Alias ๋ค์ ๋น์ทํด๋ณด์ด๋ ๊ฒ์ ์ฌ์ค์ด๋ ์ฌ์ฉ์ ์ ์ ํ์
์ด ํ ์ ์๋ ๊ฒ์ ์ธํฐํ์ด์ค๋ ํ ์ ์๋ค. ํ ์ ์๋ ๊ฒ ์ค ํ๋๋ ์ธํฐํ์ด์ค๋ ์ ์ธ์ ๋ณํฉํ ์ ์๋ค๋ ์ ์ด๋ค.
์๋์ ํ์
๋ค์ ๋ด๊ฐ ํ์ฌ ์ค๋ฌด์์ ์ฌ์ฉํ๊ณ ์๋ ํ๋ก๋ชจ์
ํ์
๋ค ์ค ์ผ๋ถ๋ถ์ ๊ฐ์ ธ์๋ค.
์ธํฐํ์ด์ค๋ ๋ช
์์ ์ผ๋ก ํ์ฅ์ ์ฌ์ฉํด์ ์ ์๋ฅผ ํด์ค ์๋ ์๋ค.
export interface PromotionCoupon {
promoId: string,
name: string,
issuanceType: PromotionIssuance,
createdAt: string,
expiryAt: string,
code: string,
discountType: PromotionDiscount,
discountRate: number,
}
export interface PromotionCouponList extends PromotionCoupon {
targetCount: number,
issuanceCount: number,
}
๋ Type Alias์์ ํ์ง ๋ชปํ๋ ์ ์ธ ๋ณํฉ์ ํ ์ ์๋ค.
์์ ๊ฐ์ด ์ ์ธ ๋์์ ๋ ์ธํฐํ์ด์ค๋ ์ค๋ฅ๊ฐ ๋์ง ์๋๋ค.
ํ์
์ ๋ณํฉํ๊ณ ์ ํ๋ ํ์
๊ณผ & ๊ธฐํธ๋ฅผ ํ์ฉํด์ ํ์
๋ณํฉ์ด ๊ฐ๋ฅํ๋ค.
ํ์
์์๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.
ํ์
์ถ๋ก ๊ณผ ํ์
๋จ์ธ
์์ ๊ฐ์ด x์ ๋ํ ํ์
์ ์ง์ ํ์ง ์๋๋ผ๋ numberํ์
์ผ๋ก y์ ๋ํ ํ์
์ ์ง์ ํ์ง ์๋๋ผ๋ stringํ์
์ผ๋ก ๊ฐ์ฃผ๋๋ค.
๋ณดํต JSX์์ ๋ง์ด ์ฐ๋ ํ์
๋จ์ธ์๋ divํ๊ทธ์์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ ์ํ์์ ํด๋น div์์ input์์ ๊ฐ์ ๊ฐ์ ธ์์ผ ํ๋ ๊ฒฝ์ฐ์ ํ์
๋จ์ธ์ ๋ง์ด ์ฌ์ฉํ๋ค.
Union Type vs Intersection Type
์ ๋์จ ํ์
(Union Type)์ A์ด๊ฑฐ๋ B์ด๋ค ๋ผ๋ ์๋ฏธ์ ํ์
์ด๋ค.
๋ณดํต ์ง์ ๋ ๊ฐ ์ด์ธ์ ๊ฐ์ด ๋ค์ด๊ฐ์ง ์์์ผ ํ ๋ ์ ๋์จ ํ์
์ ์ง์ ํด์ ๋ง์ด ์ฌ์ฉํ๋ ํธ์ด๋ค.
Intersection Type
์ธํฐ์น์
ํ์
(Intersection Type)์ ์ฌ๋ฌ ํ์
์ ๋ชจ๋ ๋ง์กฑํ๋ ํ๋์ ํ์
์ด๋ค.
Optional Parameter
JavaScript์์๋ ์กด์ฌํ์ง ์๋ ํ๋กํผํฐ์ ์ ๊ทผํ์์ ๋, ๋ฐํ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์๊ณ undefined ๊ฐ์ ์ป๊ฒ ๋๋ค.