Skip to content

Fix types on customFunctions - #638

Draft
benjavicente wants to merge 3 commits into
get-convex:mainfrom
benjavicente:main
Draft

Fix types on customFunctions#638
benjavicente wants to merge 3 commits into
get-convex:mainfrom
benjavicente:main

Conversation

@benjavicente

Copy link
Copy Markdown

Note: Currently, this PR only adds missing test that fail type checking but correctly passes tests.


Custom functions are incorrectly typed because the given query/mutation/action to extend is assumed that has the same type definition as the base convex function builders. This is inconvenient when a custom function want's to extend another, like in the new added tests.

@benjavicente

benjavicente commented Jun 9, 2025

Copy link
Copy Markdown
Author

I couldn't understand the types, I will try later but would happily accept if someone continues this PR 😵‍💫


This are my notes:

// 1. When `inner` (the first argument of a custom query) is `CustomBuilder` (function override?)

// 2. Take the inner context, input parameters and added parameters
inner: CustomBuilder<"query", InnerArgsValidator, InnerCtx, InnerMadeArgs, GenericQueryCtx<DataModel>, Visibility>

// 3. Pass the resulting context from inner?
mod: Mod<
  InnerCtx,
  // NEW?: what args inner took, added to the function args.
  // Each element here can't be present on outer args unless added on InnerMadeArgs.
  InnerArgsValidator,
  // NEW?: what args inner added, added as "default" args.
  // Those args will be propagated down to outer unless consumed in InnerArgsValidator.
  InnerMadeArgs;
  ModArgsValidator extends PropertyValidators,
  ModCtx extends Record<string, any>,
  ModMadeArgs extends Record<string, any>,
>

@ianmacartney

ianmacartney commented Jun 9, 2025 via email

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants