Kamu bisa mendengarkan dan download lagu MP3 Conditional Types in TypeScript: The API Wrapper That Returned any (Day 25/90) secara gratis di lagu123.biz. Jangan lupa untuk membeli kaset dan CD original serta menjadikan lagu ini sebagai ringtone kamu.
Data lagu:
Day 25 of the 90 Day TypeScript Challenge. A thin request() wrapper around fetch returned Promise‹any› because res.json() is typed any, so every call site lost autocomplete and a typo (order.totalCent) shipped as $NaN. We recover the real type with a conditional type and the infer keyword.
What we cover:
- How res.json()'s Promise‹any› collapses a whole wrapper's return type
- Conditional types: the T extends U ? X : Y type-level if statement
- The infer keyword: pattern-matching to extract Promise‹infer U› and array element types
- Distributive conditional types over unions, and [T] extends [U] to turn distribution off
- Building NonNullable, Awaited, and ReturnType from scratch
Code from this episode is in the blog post linked below. New episode every day.
————————————————————
📚 TypeScript in 90 Days — Day 25 of 90
▶️ Full course playlist (start here):
💌 Free weekly cheatsheet on Substack:
🔔 Subscribe & follow everywhere:
▶️ YouTube:
🧑💻 Dev.to:
✍️ Medium:
📰 Substack:
🐙 GitHub:
𝕏 Twitter:
🎵 TikTok:
🦋 Bluesky:
🐘 Mastodon:
🧵 Threads:
📸 Inst