[251124] TIL

Today I Learned (2025-11-24)

였늘 개발 ν•œ 것

  • ν›ˆλ ¨μž 톡계 API 연동함
  • ν›ˆλ ¨μž 상세보기 νŽ˜μ΄μ§€ API 연동함
  • ν›ˆλ ¨μž μŠ€ν‚€λ§ˆ discriminatedUnion νƒ€μž… μ μš©ν•¨
  • κΈ°κ΄€ μΆ”κ°€ ExistInfo μ΄ˆκΈ°ν™” μˆ˜μ •ν•¨
  • 둜그인 μ‹œ μ „μ—­ μƒνƒœμ— κΈ°κ΄€ID μ£Όμž… μˆ˜μ •ν•¨
  • boolean false인 경우 query param μ μš©λ˜λ„λ‘ μˆ˜μ •ν•¨
  • νšŒμ›/κΈ°κ΄€ μ†Œμ† 고객 μƒμˆ˜ν™”ν•¨
  • ν…Œμ΄λΈ” κΈ°λ³Έκ°’ truncate = true 섀정함
  • μŠ€νƒ€μΌ μˆ˜μ •, λ ˆμ΄μ•„μ›ƒ μˆ˜μ •, 문ꡬ λ³€κ²½, 넀이밍 변경함

κ°œλ°œν•˜λ©΄μ„œ λŠλ‚€ 것

  1. type predicate μ–΄λ–€ 값이 νŠΉμ • νƒ€μž…μΈμ§€ ν™•μΈν•΄μ£ΌλŠ” ν•¨μˆ˜μ˜ λ°˜ν™˜ νƒ€μž… ν‘œκΈ°
    • predicate : μ–΄λ–€ 사싀이 참인지 거짓인지 λ§ν•΄μ£ΌλŠ” 것, 주어에 λŒ€ν•΄ μ„€λͺ…ν•΄μ£ΌλŠ”κ²ƒ
type Animal =
  | { type: "cat"; meow: () => void }
  | { type: "dog"; bark: () => void };

function isCat(animal: Animal): animal is { type: "cat"; meow: () => void } {
  return animal.type === "cat";
}

const pet: Animal = { type: "dog", bark: () => {} };

if (isCat(pet)) {
  pet.meow(); // ok!
} else {
  pet.bark(); // ok!
}

Categories:

Updated:

Leave a comment