FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[BUG]: TypeScript error on optional fields during update (and insert) operation

Fresh11 months ago
Mar 14, 20260 views
Confidence Score80%
80%

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've encountered a TypeScript error when trying to update an optional field using the set method. The error occurs only for optional fields, while required fields work as expected. Steps to reproduce: - Define a table with both required and optional fields: [code block] - Attempt to update the table with both required and optional fields: [code block] Expected behavior: The update operation should work without any TypeScript errors, as all fields being updated are defined in the table schema. Actual behavior: TypeScript throws an error for the optional 'description' field: "Object literal may only specify known properties, and 'description' does not exist in type" The error does not occur for the required 'title' field. Additional notes: - The error only occurs for optional fields (those without .notNull()) - Using `as any` type assertion works as a temporary workaround, but it's not a proper solution Please let me know if you need any additional information or clarification to investigate this issue. Expected behavior The update operation should work without any TypeScript errors, as all fields being updated are defined in the table schema. Environment & setup Database: SQLite Node: 20 Typescript: 5.3.3

Error Output

error when trying to update an optional field using the set method. The error occurs only for optional fields, while required fields work as expected.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
78% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: [BUG]: TypeScript error on optional fields during update (and insert) operation

Low Risk

> I was facing the same problem when upgrading to version >0.31.4, there's a post in discord where rphlmr said that you need `strict` mode on your `tsconfig.json`. That solved for me. > > ps: I needed to remove all other strict tags and let only strict tag true. While this does seem to fix the issue, I'd argue that this is an incredibly disruptive change to make to a project when it was not a r

78

Trust Score

6 verifications

100% success
  1. 1

    > I was facing the same problem when upgrading to version >0.31.4, there's a pos

    > > ps: I needed to remove all other strict tags and let only strict tag true.

  2. 2

    While this does seem to fix the issue, I'd argue that this is an incredibly disr

    While this does seem to fix the issue, I'd argue that this is an incredibly disruptive change to make to a project when it was not a requirement before now. Hopefully this can be resolved without resorting to flipping `strict: true` in projects that have been previously successfully using Drizzle without this compiler flag.

Validation

Resolved in drizzle-team/drizzle-orm GitHub issue #2654. Community reactions: 15 upvotes.

Verification Summary

Worked: 6
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugpriority