drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.44k stars 484 forks source link

[BUG]: drizzle-valibot does not provide types for returned schemas #2521

Open valerii15298 opened 1 week ago

valerii15298 commented 1 week ago

What version of drizzle-orm are you using?

drizzle-orm 0.31.2

What version of drizzle-kit are you using?

drizzle-kit 0.22.7

Describe the Bug

I wanted to use drizzle-valibot package to create ready to use validation schemas from drizzle schema. I use this code from the example:

import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-valibot";
const users = pgTable("users", {
  id: serial("id").primaryKey(),
  name: text("name").notNull(),
  email: text("email").notNull(),
  role: text("role", { enum: ["admin", "user"] }).notNull(),
  createdAt: timestamp("created_at").notNull().defaultNow(),
});
// Schema for inserting a user - can be used to validate API requests
const insertUserSchema = createInsertSchema(users);

Expected behavior

insertUserSchema should be properly typed. But instead I get this:

Screenshot 2024-06-16 at 16 33 02

Note that insertUserSchema has any type...

Environment & setup

Nodejs, typescript 5.4.5 drizzle-valibot 0.2.0 drizzle-kit 0.22.7 drizzle-orm 0.31.2