Teos
Teos
CCConvex Community
Created by Teos on 3/14/2024 in #support-community
convex-helpers `Table` helper loses type safety
Hello, Convex community! First off, I want to express my admiration for Convex. I'm genuinely impressed by the onboarding process and the developer experience. It's been a delight working with the stack! However, I've run into a puzzling issue while exploring Convex, specifically related to type inference in TypeScript, and I'm hoping someone might help shed some light on it. In my project, I have a users.ts file that defines a User table using Convex's helper functions, like so: https://ibb.co/BwVsx0G in my schema.ts I use it as follows : https://ibb.co/N7QnHyB Here's the issue, on the user.ts file, if I hover-over the User type TS infers it as object of [x: string]: any https://ibb.co/fdx5GhK Hovering over the schema.users the type is like the below : https://ibb.co/8mQ9tLF Strangely, if I skip the Table() convex-helper and i export the userFields and directly use them in the schema.ts file with defineTable(userFields) <-- the types are inferred correctly (see below): https://ibb.co/xJLMGBS What am I doing wrong here ? Any insights or guidance would be greatly appreciated. Thanks in advance for your help!
18 replies