Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

`Awaited<T>`, `ReturnType<T>`, `Parameters<T>`: When You're Reaching for the Wrong One

DEV Community·Gabriel Anhaia·27 days ago
#ClVkvS1Y
Reading 0:00
15s threshold

Book: The TypeScript Type System — From Generics to DSL-Level Types Also by me: The TypeScript Library — the 5-book collection My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub A team I talked to last month shipped a typed API client. The handler reads ReturnType&lt;typeof fetchUser&gt; and binds that to its response shape. The endpoint compiles, the test for the happy path passes, the staging deploy goes out. Two days later a UI engineer opens a ticket: every field on user.profile is undefined . The function was async. The aliased shape was a Promise&lt;User&gt; that nobody noticed. The renderer was reading .profile off something the alias claimed was a User . Every TypeScript codebase that has been alive for two years has this bug somewhere. The four utility types from the handbook page that get reached for the most: Awaited&lt;T&gt; , ReturnType&lt;T&gt; , Parameters&lt;T&gt; , and ConstructorParameters&lt;T&gt; .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More