Bug report
Description / Observed Behavior
When wrapping useSWRMutation in a generic helper function, the trigger return type becomes an uncallable union of TriggerWithoutArgs | TriggerWithOptionsArgs | TriggerWithArgs.
TypeScript error:
TS2349: This expression is not callable.
Each member of the union type
'TriggerWithoutArgs<Data, any, Key, Args> | TriggerWithOptionsArgs<Data, any, Key, Args> | TriggerWithArgs<...>'
has signatures, but none of those signatures are compatible with each other.
The conditional type that determines which trigger interface to use:
trigger: [ExtraArg] extends [never]
? TriggerWithoutArgs<...>
: IsUndefinedIncluded<ExtraArg> extends true
? TriggerWithOptionsArgs<...>
: TriggerWithArgs<...>
cannot be evaluated when ExtraArg is a generic type parameter (not yet resolved). TypeScript defers the conditional type rather than resolving it to a single branch. The deferred type is opaque and uncallable because TS cannot determine which of the three incompatible call signatures applies.
Note: the [ExtraArg] extends [never] wrapping correctly prevents union distribution — this is a deferred conditional type issue, not a distributive conditional type issue.
Expected Behavior
trigger should be callable when useSWRMutation is used inside a generic wrapper function.