-
-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
Note: This issue was AI-generated, but the fix has been validated.
When chaining .addon() with .catcher() or .catcherFallback(), addon wretch-level methods are lost from the type.
Reproduction
import wretch from "wretch";
import AbortAddon from "wretch/addons/abort";
const base = wretch()
.addon(AbortAddon())
.catcher(404, (error) => { throw error; });
// ❌ TypeScript error: Property 'signal' does not exist
base.signal(new AbortController()).get("/test");Cause
catcher() and catcherFallback() return Wretch<Self, ...> instead of Self & Wretch<Self, ...>, dropping the addon interface intersection.
Fix
File: src/types.ts (lines ~270 and ~289)
- catcher(...): Wretch<Self, Chain, Resolver, ErrorType extends undefined ? WretchError : ErrorType>;
+ catcher(...): Self & Wretch<Self, Chain, Resolver, ErrorType extends undefined ? WretchError : ErrorType>;
- catcherFallback(...): Wretch<Self, Chain, Resolver, ErrorType extends undefined ? WretchError : ErrorType>;
+ catcherFallback(...): Self & Wretch<Self, Chain, Resolver, ErrorType extends undefined ? WretchError : ErrorType>;Note: customError() and resolve() already have the correct return type (Self & Wretch<...>).
Environment
- wretch: 3.0.5
Metadata
Metadata
Assignees
Labels
No labels