Types aren't being inferred properly

I have the following schema.
export const taskFolders = pgTable('task_folders', {
id: uuid('id').primaryKey().defaultRandom(),
taskId: uuid('taskId').references(() => tasks.id, { onDelete: 'cascade' }),
name: text('name').notNull(),
createdAt: timestamp('created_at', { mode: 'string' }).notNull().defaultNow(),
deletedAt: timestamp('deleted_at'),
});
export type InsertTaskFolder = typeof taskFolders.$inferInsert;
// ?^ { name: string }
export const taskFolders = pgTable('task_folders', {
id: uuid('id').primaryKey().defaultRandom(),
taskId: uuid('taskId').references(() => tasks.id, { onDelete: 'cascade' }),
name: text('name').notNull(),
createdAt: timestamp('created_at', { mode: 'string' }).notNull().defaultNow(),
deletedAt: timestamp('deleted_at'),
});
export type InsertTaskFolder = typeof taskFolders.$inferInsert;
// ?^ { name: string }
I'm trying to update the deleted_at column but when I do, Typescript is erroring.
@Delete(':id')
async delete(@Param('id', new ParseUUIDPipe()) id: Guid) {
await this.db
.update(scheme.taskFolders)
.set({ deletedAt: new Date() }) // Typescript error here: Object literal may only specify known properties, and 'deletedAt' does not exist in type '{ name?: string | SQL<unknown>; }'.
.where(eq(scheme.taskFolders.id, id));
}
@Delete(':id')
async delete(@Param('id', new ParseUUIDPipe()) id: Guid) {
await this.db
.update(scheme.taskFolders)
.set({ deletedAt: new Date() }) // Typescript error here: Object literal may only specify known properties, and 'deletedAt' does not exist in type '{ name?: string | SQL<unknown>; }'.
.where(eq(scheme.taskFolders.id, id));
}
My question is why deletedAt isn't being inferred and how I can fix this
1 Reply
bigboyjo
bigboyjoOP3mo ago
Ended up fixing the issue. Strict mode was set to false
Want results from more Discord servers?
Add your server