Migration Stack post code is JavaScript, not TypeScript
I'm currently trying to run a migration and I'm getting type errors when using the code given in this stack post (https://stack.convex.dev/migrating-data-with-mutations). I tried inferring the types but then got this error when testing in the dashboard:
Was there an update to Convex since this article was published?
3 Replies
Ah the code in the article is JavaScript and doesn’t have the typescript types. When we have a function without types we give them the types of “unknown”
The type is likely
{cursor, numItems}: {cursor: string | null, numItems: number }
I would recommend using the migration helpers in the convex-helpers repo linked from the doc, it’s how I do migrations. Let me know if it gives any troubleIs there a way to import the convex-helper library? I tried to just add the mutations.ts file by hand and got a error importing MutationCtx
You might need to change the import path because it's relative (so if you're in a nested folder under
convex/
you'll need another set of ..
and vice versa)