github elbywan/wretch 3.0.6

2 days ago

3.0.6 (2025-12-12)

🐛 Bug fix(es)

  • Add Self to return type (e5582d6)
import wretch from "wretch";
import AbortAddon from "wretch/addons/abort";

const base = wretch()
  .addon(AbortAddon())
  .catcher(404, (error) => { throw error; });

// Previously: ❌ TypeScript error: Property 'signal' does not exist
// Now: 🟢
base.signal(new AbortController()).get("/test");
  • Widen catcherFallback error type (d0a3fbe), closes #290
import wretch from "wretch";

class ApiError extends Error {
  constructor(public status: number, message: string) {
    super(message);
  }
}

const api = wretch()
  .customError(async (error) => {
    return new ApiError(error.status, error.message);
  })
  .catcherFallback((error) => {
    // Previously 🔴
    // Error was typed as "ApiError"
    // But if you block the URL in Chrome DevTools (or network is down):
    // `error` is actually `TypeError: Failed to fetch`
    //
    // Now: 🟢
    // error is properly typed as "unknown" 
    console.log(error); 

   
  });

✅ Test improvement(s)

  • Add core snippet testing infrastructure (fcea6f7)
  • Add directive system for snippet test control (106e0d6)
  • Add execution engine and test orchestration (28f60a1)
  • Add extensible plugin system with examples (262a40d)
  • Integrate snippet testing framework and document usage (9cdeb4c)

Don't miss a new wretch release

NewReleases is sending notifications on new releases.