Surely a bug (with TypeScript fanciness) ?
See screenshots. The only thing I am changing is the type of quotes (double quotes to back ticks, for variable interpolation) in line 156.
This breaks anterior bits of code... o.O
It complains about
request
implicitly being of type any
, but this error message persists, even after I add explicit type annotations.
Also, there is no circular reference (that I can see).
What is this dark evilness?21 Replies
The circular reference is happening because the return value of a convex function (
request
) is in the return value.
Assign request.status
to its own variable and use that in your interpolation to clear up the error.
-->
okay an explicit type annotation fixed this
thanks for your help ❤️
I can unequivocally say, though, that I do not remotely understand this.
the return value of one function is returned in the encapsulating function ... that's just standard procedural programming, no? XD
It is, but Convex generates types for these functions, and directly referencing the return value of one function from inside of another creates a circular reference.
Type annotation definitely works, but you can go back to letting the return value be inferred if you just don't directly reference the other function's return value, which could look like:
that's exactl;y what I did, before the explicit type annotation
what's the error above it from line 146
here's all 3:
I see
paymentId
on that line seems to be not creating an error - what happens if you don't destructure the return value of ctx.runQuery()
? Can you try assigning that to a variable and seeing if the type is correct?as in
const both = runQuery(...
and then destructuring both
?yes
(I am new to both JS and TS)
ok 2 mins
but mostly interested in whether
both
is typed in this scenario
If you need to just move on since you have a working solution, feel free to do so! I'm interested in troubleshooting it if you have the time.
still errors
I, unfortunately, am also a nerd who needs to get to the bottom of this so I can sleep tonight 😛
(also happy to have a brief call, capped at max 30' though, if you wanna do some live debugging)
screenshare etc.
Weird, I've definitely seen this resolved by not directly referencing the return value of the other function
I'm up for that, one sec
similarly, lemme get a glass of water
1 min
kk ready
do we need to become friends? 😄
I know discord has calling and screen sharing
yeah, but do we need to become discord friends ios what I meant
sent a request
For posterity: this seems to have been due to some tables not being in the schema and schema validation being off temporarily. Still to be confirmed.
This ended up being due to directly referencing the return value of a convex function within another convex function, annotating the referenced value was the simplest fix.
Huge thanks to Erquhart for taking the time to figure this out and explain this to me!
Once Convex introduces community medals... I have a recommendation! 🎖️
@erquhart is the best