Skip to content

patch undefined over null type error #87

Open
@franckdsf

Description

@franckdsf

When creating a table with a null variable, it's possible to pass an undefined value to the patch function without TypeScript raising an error — even though this will crash at runtime.

export const test = defineTable({
  nullVariable: v.union(v.null(), v.string()),
  undefinedVariable: v.optional(v.string()),
})
await ctx.db.patch(testId, {
  nullVariable: undefined,   // <--------- no TypeScript error
  undefinedVariable: null    // <--------- TypeScript error
})

Expected behavior: TypeScript should warn that undefined is not a valid value for nullVariable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions