[BUG]: TypeError: Object literal may only specify known properties
Problem
What version of `drizzle-orm` are you using? 0.32.0 What version of `drizzle-kit` are you using? 0.23.0 Describe the Bug I bumped the versions of drizzle-orm 0.31.4 -> 0.32.0 and drizzle-kit 0.22.8 -> 0.23.0. After that my project stopped from building because some of the columns are not being recognized by the type system. I provided the error log, table definition and code that uses it below. TS compiler error log: [code block] Table definition in schema.ts: [code block] Usage of table to perform queries: [code block] Expected behavior All specified columns being recognized by the type system on writing queries Environment & setup Node.js v20.12.2 drizzle-kit v0.32.0 drizzle-orm v0.23.0
Error Output
error log, table definition and code that uses it below.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix TypeError in drizzle-orm and drizzle-kit Integration
The TypeError occurs because the type definitions in drizzle-orm 0.32.0 and drizzle-kit 0.23.0 may have introduced changes that are incompatible with the existing schema definitions in your project. Specifically, the columns defined in your schema may not match the expected types or structure defined by the new versions of these libraries.
Awaiting Verification
Be the first to verify this fix
- 1
Check and Update Column Definitions
Review the column definitions in your schema.ts file to ensure they match the expected types in drizzle-orm 0.32.0. Update any mismatched types or structures.
typescripttype User = { id: number; name: string; email: string; }; // Ensure all columns are correctly typed - 2
Review and Update Query Usage
Examine the code where you are using the table to perform queries. Ensure that the queries reference the updated column types and structures as defined in the schema.
typescriptconst userQuery = db.users.find({ id: 1 }); // Ensure this matches the updated User type - 3
Check for Breaking Changes in Documentation
Consult the changelogs or migration guides for drizzle-orm and drizzle-kit to identify any breaking changes that may affect your current implementation.
bashnpm info drizzle-orm changelog - 4
Reinstall Node Modules
After making the necessary updates, delete the node_modules folder and reinstall the dependencies to ensure that all packages are correctly updated and compatible.
bashrm -rf node_modules && npm install - 5
Run TypeScript Compiler
After making the changes, run the TypeScript compiler to check for any remaining type errors. This will help confirm that all issues related to the TypeError have been resolved.
bashtsc
Validation
Confirm that the TypeScript compiler runs without errors and that the application builds successfully. Additionally, run any existing tests to ensure functionality remains intact.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep