Menu

1 / 2

Promise.withResolvers: The Pattern That Killed Half Your Deferred Helpers

DEV Community·Gabriel Anhaia·6 months ago
#Sj1P3AsF
#pattern#typescript#javascript#promise#reject
Reading 0:00
15s threshold

Book: TypeScript Essentials — From Working Developer to Confident TS, Across Node, Bun, Deno, and the Browser

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

Open any non-trivial TypeScript codebase and search for the

string createDeferred . You will probably find one. Maybe

two. They are usually about ten lines long, written by the

same engineer, copied between repos, and tucked into a file

called utils/promise.ts next to a helper for sleep and a

helper for withTimeout . They all do the same thing: build

a Promise , capture resolve and reject from inside the

executor, and hand the trio back to the caller. By the third

repo most engineers carry a createDeferred helper around

like a houseplant.

That helper has been obsolete since 2024.…

Continue reading — create a free account

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