TypeScript 5.4 and convex
Are there known issues with convex and typescript 5.4.2? If my vscode project is set to use 5.4.2 all my mutations and query functions come back with an error of
'create' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
But when i switch to 5.3.2 it fixes that. But im using 5.4.2 for a reason, because it allows my path aliases to work like expected in my yarn workspace project10 Replies
What libraries are you using? Anything from convex-helpers? If so this may be known
Yes im using quite a lot from convex-helpers indeed
If you can stay with 5.3 for a bit, we'll look at this soon
Alright, i'll take a look and see what would work across the board.
Kinda funky too, because reason i switched to 5.4.2 was due to my apps/expo having no problems picking up my path alias and provide auto suggestions. But the apps/next didnt want to
looks like 5.4 is a week old but TypeScript gets so much better every release I know I want to upgrade right away
Switching to 5.4.2 just solved that, and then i ran into the issue with my packages/db-service where convex lives
Ahh i see! yeah it sure does, i bet its not just easy like that
Alright i just locked in 5.3.3 and seems i have both convex types happy and path aliases across the board. SUCCESS!
š
I'm running 5.3.3 and typescript randomly freaks out about all the queries with the same error. I can sometimes get rid of it by just closing everything but its super annoying.
The convex-helpers / TypeScript 5.4 issue upthread should be resolved for the newest version of convex-helpers.
This issue is frustrating, there are plans to move to less circular types. But you may be able to solve by type-annotating the variable the return value of calling another action is stored in everywhere that happens.
I was mistaken, we are on 5.4.3. My biggest issue is performance, the problem above seems to happen after typescript slows down to like 5-10+ second waits . I was using more convex-helpers then switched to ents and it feels like performance has dropped but were also working with 33 tables now in the schema and a lot more to add. I'm still new to typescript so can you give a example of a more complex return that is paginated with like team with a map to users etc. I've only seen it done in old examples.
The file that really gets triggered is the hooks.tsx, similar to the one in the convex ents saas-starter template
We still can't seem to get typescript to be anywhere close a reasonable speed IMHO on a fast computer. Is there anything to reference on what would be the absolute and even annoying best practices with typescript. I have reviewed so many templates and i haven't noticed any consistent trend. At least not for simple database interactions. My hooks.ts file is still the most likely place to get angry. Stuff like this: export function getSiteSettings() {
const result = useQuery(api.siteSettings.getSiteSettings);
return result;
}
Should I annotate all these returns or in convex, or both? I cant simply toss a Ents<"siteSettings"> on it.
I have not seen anyone annotating useQuery call sites, but of course would be curious if this helps. Slowdowns seem more likely when this is done from Convex actions where this could help, e.g.
Annotating return types of Convex functions is not a bad idea, but again I'm very intersted to hear if this helps.
I forget if we've asked, but it'd be interesting to see this codebase to look into the performance issues. TypeScript performance is a thing we can improve aspects of but we need real test cases to make sure we're improving things that matter