Hey all—I ve gotten a PoC of ProseMirror
Hey all—I've gotten a PoC of ProseMirror OT collaborative editing running on Convex!
One challenge I've run into, though, is that my Convex mutation that does the server-side rebasing of the ProseMirror document needs to import modules (e.g.
prosemirror-model
) which reference the DOM API, so I'm getting type-checking errors via e.g. npx convex dev
and npx convex deploy
. Passing a flag to turn off type-checking works fine, but I'd of course prefer not to do that.
I suppose what I'm saying I'd prefer is for type-checking of Convex functions to take into account not the modules that I'm importing, but the specific terms and types, and their dependencies. But that sounds possibly quite tricky! Any recommendations?2 Replies
Great to hear! The thing you'd prefer does sound tricky, we're not looking to start a TypeScript compiler competitor 😆 (Edit: although TypeScript may have some options for this, things like not typechecking dependencies)
This is a great point, unless we were to do what you suggest we shouldn't be being as strict as we are. The ecosystem convention seems to be to allow browser APIs like the DOM to be used in libraries that run server-side and just fail at runtime. Our
tsconfig.json
is trying to be more strict than that to help users, but if it means there are important libraries that don't typecheck we may need to revisit this.
I'll file this and we can look at changing the tsconfig once I have a repro. If you twiddle with the convex/tsconfig.json (adding DOM
to the list of lib might do it) I'd love to hear if that helps. You might need to remove the include of "../node_modules/convex/dist/esm/environment/index.d.ts"
if you do this, since it redefines console.log.Yeah, that certainly makes sense—could be that the answer is to just advise users to add the DOM lib to
tsconfig.json
if they want to, with the caveat that they're more at risk of runtime errors.
Nice, I did run into the console.log
redefinition 🙂
I'll play around with it and report back with more
allows the mutation to type-check