fifth
fifth•2mo ago

VSCode keeps showing an error on functional Convex API Call

Hi! My issue is that in my Convex database, I have a table called submissions.ts and the table name in the schema.ts file is also submissions. Thus, when using the API call, I also use api.submissions, which is correct, but VSCode keeps wanting me to switch to api.submission, which is wrong (and if I change to it, the code stops working, which makes sense). How should I address this issue? Is there anything in particular I'm doing wrong with the IDE that is making this an issue? Thank you!
No description
13 Replies
lee
lee•2mo ago
troubleshooting: make sure npx convex dev is running (try restarting it). And restart the typescript server in vscode
ballingt
ballingt•2mo ago
@fifth note that the name is based on the name of the .ts file in the convex/ directory, not the name of the table in your scheme.ts.
fifth
fifthOP•2mo ago
Thanks Lee and Tom! My file is indeed submissions.ts, and I have also tried doing what @lee advised, but the same error is still present. What else can I try to address this situation? Thank you!
No description
ballingt
ballingt•2mo ago
Why do you think a convex dev process is running? What does convex/_generated/api.d.ts look like?
fifth
fifthOP•2mo ago
Hi Tom! I'm sorry the notification to this thread got away from my attention somehow... But this is what it looks like: / * Generated api utility. * * THIS CODE IS AUTOMATICALLY GENERATED. * * To regenerate, run npx convex dev. * @module */ import type { ApiFromModules, FilterApi, FunctionReference, } from "convex/server"; import type * as auth from "../auth.js"; import type * as http from "../http.js"; import type * as questions from "../questions.js"; import type * as quizzes from "../quizzes.js"; import type * as submission from "../submissions.js"; import type * as users from "../users.js"; / * A utility for referencing Convex functions in your app's API. * * Usage: *
* const myFunctionReference = api.myModule.myFunction;
*
* const myFunctionReference = api.myModule.myFunction;
*
*/ declare const fullApi: ApiFromModules<{ auth: typeof auth; http: typeof http; questions: typeof questions; quizzes: typeof quizzes; submission: typeof submission; users: typeof users; }>; export declare const api: FilterApi< typeof fullApi, FunctionReference<any, "public"> >; export declare const internal: FilterApi< typeof fullApi, FunctionReference<any, "internal"> >; It does says in here that it is submisisons.ts
ballingt
ballingt•2mo ago
import type * as submission from "../submissions.js"; is the funny line here, why is the file submissions.js being imported as submission I wonder What happens if you run npx convex codegen --typecheck=disable?
fifth
fifthOP•2mo ago
Here is what it says after I run npx convex codegen --typecheck=disable: / * Generated api utility. * * THIS CODE IS AUTOMATICALLY GENERATED. * * To regenerate, run npx convex dev. * @module */ import type { ApiFromModules, FilterApi, FunctionReference, } from "convex/server"; import type * as auth from "../auth.js"; import type * as http from "../http.js"; import type * as questions from "../questions.js"; import type * as quizzes from "../quizzes.js"; import type * as submission from "../submissions.js"; import type * as users from "../users.js"; / * A utility for referencing Convex functions in your app's API. * * Usage: *
* const myFunctionReference = api.myModule.myFunction;
*
* const myFunctionReference = api.myModule.myFunction;
*
*/ declare const fullApi: ApiFromModules<{ auth: typeof auth; http: typeof http; questions: typeof questions; quizzes: typeof quizzes; submission: typeof submission; users: typeof users; }>; export declare const api: FilterApi< typeof fullApi, FunctionReference<any, "public"> >; export declare const internal: FilterApi< typeof fullApi, FunctionReference<any, "internal"> >; It's importing as submission after running the command 😅
ballingt
ballingt•2mo ago
If you delete this file is it regenerated, are you sure this is updating? What does ls convex/ look like, is there perhaps also another file in there?
fifth
fifthOP•2mo ago
Here is the result if I run ls convex/ ls convex/ README.md questions.ts _generated quizzes.ts answers.ts schema.ts auth.config.ts submissions.ts auth.ts tsconfig.json http.ts users.ts I'm not quite sure what's happening in here 😢
ballingt
ballingt•2mo ago
@fifth and you think that convex dev / convex codegen is really running in the right place? If you delete the _generated directory, does it come back?
fifth
fifthOP•2mo ago
Oh it does, and it is indeed correct now: / * Generated api utility. * * THIS CODE IS AUTOMATICALLY GENERATED. * * To regenerate, run npx convex dev. * @module */ import type { ApiFromModules, FilterApi, FunctionReference, } from "convex/server"; import type * as answers from "../answers.js"; import type * as auth from "../auth.js"; import type * as http from "../http.js"; import type * as questions from "../questions.js"; import type * as quizzes from "../quizzes.js"; import type * as submissions from "../submissions.js"; import type * as users from "../users.js"; / * A utility for referencing Convex functions in your app's API. * * Usage: *
* const myFunctionReference = api.myModule.myFunction;
*
* const myFunctionReference = api.myModule.myFunction;
*
*/ declare const fullApi: ApiFromModules<{ answers: typeof answers; auth: typeof auth; http: typeof http; questions: typeof questions; quizzes: typeof quizzes; submissions: typeof submissions; users: typeof users; }>; export declare const api: FilterApi< typeof fullApi, FunctionReference<any, "public"> >; export declare const internal: FilterApi< typeof fullApi, FunctionReference<any, "internal"> >; What do you think? It is now showing submissions correctly
ballingt
ballingt•2mo ago
I wonder if it wasn't running before, or if your editor wasn't updating? That's all I can think of
fifth
fifthOP•2mo ago
It's pretty weird, but for now it is not complaining about the submissions.ts anymore. Thank you Tom! I'll update here should there be anything you guys need to be aware of

Did you find this page helpful?