glucinater
glucinater17mo ago

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:
Uncaught Error: Must provide arg 1 `id` to patch
at <anonymous> (../convex/courses.ts:69:27)
Uncaught Error: Must provide arg 1 `id` to patch
at <anonymous> (../convex/courses.ts:69:27)
Was there an update to Convex since this article was published?
No description
3 Replies
ian
ian17mo ago
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 trouble
glucinater
glucinaterOP17mo ago
Is 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
Michal Srb
Michal Srb17mo ago
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)

Did you find this page helpful?