3.0.8 (2026-05-23)
⚠️ Potential TypeScript breaking change
This may surface new typescript errors in existing code that previously compiled with overly narrow types. In practice, this means code that assumed the result was always Data may now need to handle additional catcher return values.
Although this can be a type-level breaking change, it is a correctness fix: the previous typings were incomplete and did not match actual runtime behavior.
👉 This change does not affect runtime behavior.
🐛 Bug fix(es)
wretch now reflects catcher callback return types in the final promise type.
For example, this is now inferred correctly:
const result = await wretch(url)
.get()
.notFound(() => "notFound" as const)
.json<Data>()And result is now typed as:
Data | "notFound"Catchers with no return value are now reflected as undefined, and the same typing improvement also applies through .resolve() and deferred catchers configured with .defer().
// a slightly more exhaustive example
const result = await wretch("https://example.com")
.catcher(404, () => "404" as const)
.catcher([401, 403, 407], () => "401/403/407" as const)
.catcherFallback(() => "fallback" as const)
.defer(w => w.catcher(404, () => "deferred" as const))
.get()
.notFound(() => "notFound" as const)
.internalError(() => "internalError" as const)
.error("custom", () => "customError" as const)
.fetchError(() => "Fetch error" as const)
.json<{ data: unknown }>()
const expected:
{ data: unknown }
| "404"
| "401/403/407"
| "fallback"
| "notFound"
| "internalError"
| "customError"
| "Fetch error"
| "deferred" = result⬆️ Version update(s)
✅ Test improvement(s)
- Properly typecheck tests (5af0e78)