Open btab opened 1 month ago
Based on a suggestion from @thomasballinger, I tried playing around with extra saves on the various generated files to see whether one such save would nudge the Svelte server into catching up. The good news is that re-saving / touch
ing api.d.ts
seems to do so (the added table springs to life in the autocomplete). There might be something about the way that convex is saving that file that is somehow defeating Svelte's file watching - maybe it's being done as a write-then-rename?
So this means that this problem should exist irrespective of whether schemas are involved right? That generated file just comes from the set of api modules in the convex source directory, if I understand it correctly?
Ah great find! To be clear, of 1 viewing the file in VSCode, 2) saving the file from VSCode, or 3) touching it from the terminal it's 2 and 3 that both fix the problem, making svelte types catch up?
Yep, api.d.ts
contains a list of .ts
files in the convex/
directory , but doesn't change when the contents of those files change. Without Svelte involved, adding new tables or columns to convex/schema.ts
or new export convex functions to other files in the convex/
folder updates types in the browser and autocomplete on things like api.filename.functionName
immediately.
Yes indeed - anything that would bump the mtime on that generated api TS definition file does the trick.
I also have a secondary (rather weak) signal that I haven't had a chance to investigate. When rapidly building up api files in the convex
dir, I found myself quite naturally copying whole existing files (specifically by selecting the file in VS CODE and then copy-pasting it) ... and then modifying the new file accordingly. So foods.ts
would be joined by foods copy.ts
, which I'd then rename and start hacking on. During this process convex dev
is running the whole time.
I have had to force reload the windows a couple of times under these circumstances to get the right code completion even in scripts that have nothing to do with Svelte.
I'm mentioning all this here in case its another mini-clue that the generated files are being instantiated in a somehow LSP-unfriendly way. This problem is proving difficult to reproduce though so I'm not confident in the signal yet.
Ported over from a discussion on the Convex Community Discord.
goats.ts
containing...export const get = query({ args: {}, handler: async (ctx) => { return await ctx.db.query("goats").collect(); }, });
import { defineSchema, defineTable } from "convex/server"; import { v } from "convex/values";
export default defineSchema({ [snip...] goats: defineTable({ name: v.string(), }), [snip...] });