This TypeScript error:
Type 'TableDefinition<VObject<...>>' is not assignable to type 'TableDefinition<Validator<any, any, any>, {}, {}, {}>'.
Types have separate declarations of a private property 'indexes'.ts(2322)
is a classic TypeScript issue that often arises in monorepo or multi-package setups when you have multiple copies of the Convex package (or any package that defines classes with private/protected members) installed in different parts of your project. TypeScript treats classes with private/protected members as incompatible if they come from different package instances, even if their code is identical. This is because the private members are considered unique to each package instance.
Where to start debugging:
- Check for duplicate Convex installations: Make sure that all parts of your monorepo are using the same instance of the Convex package. If you have multiple
node_modules folders (e.g., one in the root and one in a package), you might have multiple copies of Convex.
- Use a single version: Ensure that all packages reference the same version of Convex in their
package.json.
- Hoist dependencies: If you use a monorepo tool like Yarn Workspaces or pnpm, make sure dependencies are hoisted to the root to avoid duplication.
- Check your TypeScript config: Make sure your
tsconfig.json is set up to resolve modules consistently across your monorepo.
This is a well-known TypeScript quirk and not specific to Convex, but it can be especially confusing with class-based APIs like Convex's TableDefinition that use private members for type safety. For more on this, see the Convex API docs on TableDefinition.