Skip to content

Commit 2bd9f58

Browse files
committed
satisfy built-in q/m/a
1 parent e623659 commit 2bd9f58

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

packages/convex-helpers/server/customFunctions.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,30 @@ customAction(
147147
customCtx((ctx) => ({})),
148148
) satisfies typeof action;
149149

150+
customQuery({} as any, {
151+
args: {},
152+
input: async () => ({
153+
ctx: {},
154+
args: {},
155+
}),
156+
}) satisfies typeof query;
157+
158+
customMutation(mutation, {
159+
args: {},
160+
input: async () => ({
161+
ctx: {},
162+
args: {},
163+
}),
164+
}) satisfies typeof mutation;
165+
166+
customAction(action, {
167+
args: {},
168+
input: async () => ({
169+
ctx: {},
170+
args: {},
171+
}),
172+
}) satisfies typeof action;
173+
150174
/**
151175
* Testing custom function modifications.
152176
*/

packages/convex-helpers/server/customFunctions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ export type CustomBuilder<
471471
ctx: Overwrite<InputCtx, ModCtx>,
472472
...args: ArgsForHandlerType<OneOrZeroArgs, ModMadeArgs>
473473
) => ReturnValue;
474-
} & ExtraArgs)
474+
} & {
475+
[key in keyof ExtraArgs as key extends "args" | "returns" | "handler"
476+
? never
477+
: key]: ExtraArgs[key];
478+
})
475479
| {
476480
(
477481
ctx: Overwrite<InputCtx, ModCtx>,
@@ -505,4 +509,4 @@ export type CustomCtx<Builder> =
505509
? Overwrite<InputCtx, ModCtx>
506510
: never;
507511

508-
type Overwrite<T, U> = Omit<T, keyof U> & U;
512+
type Overwrite<T, U> = keyof U extends never ? T : Omit<T, keyof U> & U;

0 commit comments

Comments
 (0)