Fix types on customFunctions - #638
Draft
benjavicente wants to merge 3 commits into
Draft
Conversation
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>,
> |
Member
|
Yes I haven't figured out whether TypeScript's generics can actually
support doing the nesting and having the types flow through without
changing the API.
This is why the current recommendation is to only have one level and share
code within them - e.g. a function that adds something to ctx, or makes a
bunch of shared things like loggers
…On Sun, Jun 8, 2025 at 9:00 PM Benjamín Vicente ***@***.***> wrote:
*benjavicente* left a comment (get-convex/convex-helpers#638)
<#638 (comment)>
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 unless consumed in InnerArgsValidator.
InnerMadeArgs;
ModArgsValidator extends PropertyValidators,
ModCtx extends Record<string, any>,
ModMadeArgs extends Record<string, any>,>
—
Reply to this email directly, view it on GitHub
<#638 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACZQWYFJVOI5ZQ3JAR4ZWD3CUBGVAVCNFSM6AAAAAB633HGOOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJUGU3DOMRZGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.