Skip to content

Fix types on customFunctions #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

benjavicente
Copy link

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
Copy link
Author

benjavicente commented Jun 9, 2025

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
Copy link
Collaborator

ianmacartney commented Jun 9, 2025 via email

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