Newt
Newt
DTDrizzle Team
Created by Newt on 4/15/2025 in #help
Type Error when Generating Typebox
the thing is, in Runtime it works without problems, i just get Runtime Errors, i also tried the Examples and i also get Compile Errors there: https://orm.drizzle.team/docs/typebox#select-schema Also Tried to Update my TS Config like described here: https://discord.com/channels/1043890932593987624/1318443104927223818
10 replies
DTDrizzle Team
Created by Newt on 4/15/2025 in #help
Type Error when Generating Typebox
Nope, still, but here is the FULL error: https://pastebin.com/CFYsN01P
10 replies
DTDrizzle Team
Created by Newt on 4/15/2025 in #help
Type Error when Generating Typebox
export const agent = pgTable("agents", {
id: text("id").primaryKey().$defaultFn(ulid),
//...other columns
});

export const table = {
agent,
//...other tables
} as const;
export const agent = pgTable("agents", {
id: text("id").primaryKey().$defaultFn(ulid),
//...other columns
});

export const table = {
agent,
//...other tables
} as const;
this is my export ^^
10 replies
DTDrizzle Team
Created by Newt on 4/15/2025 in #help
Type Error when Generating Typebox
table:
export const agent = pgTable(
"agents",
{
id: uuid("id").primaryKey().defaultRandom(),
enabled: boolean("enabled").default(true).notNull(),
// Character
name: text("name").notNull(),
username: text("username"),
system: text("system"),
bio: jsonb("bio").$type<string | string[]>().notNull(),
messageExamples: jsonb("message_examples")
.$type<MessageExample[][]>()
.default(sql`'[]'::jsonb`),
topics: jsonb("topics")
.$type<string[]>()
.default(sql`'[]'::jsonb`),
adjectives: jsonb("adjectives")
.$type<string[]>()
.default(sql`'[]'::jsonb`),
settings: jsonb("settings")
.$type<{
secrets?: { [key: string]: string | boolean | number };
[key: string]: unknown;
}>()
.default(sql`'{}'::jsonb`),
style: jsonb("style")
.$type<{
all?: string[];
chat?: string[];
}>()
.default(sql`'{}'::jsonb`),
createdAt: timestamp("created_at", { withTimezone: true, mode: "date" }).defaultNow().notNull(),
},
(table) => [unique("name_unique").on(table.name)],
);
export const agent = pgTable(
"agents",
{
id: uuid("id").primaryKey().defaultRandom(),
enabled: boolean("enabled").default(true).notNull(),
// Character
name: text("name").notNull(),
username: text("username"),
system: text("system"),
bio: jsonb("bio").$type<string | string[]>().notNull(),
messageExamples: jsonb("message_examples")
.$type<MessageExample[][]>()
.default(sql`'[]'::jsonb`),
topics: jsonb("topics")
.$type<string[]>()
.default(sql`'[]'::jsonb`),
adjectives: jsonb("adjectives")
.$type<string[]>()
.default(sql`'[]'::jsonb`),
settings: jsonb("settings")
.$type<{
secrets?: { [key: string]: string | boolean | number };
[key: string]: unknown;
}>()
.default(sql`'{}'::jsonb`),
style: jsonb("style")
.$type<{
all?: string[];
chat?: string[];
}>()
.default(sql`'{}'::jsonb`),
createdAt: timestamp("created_at", { withTimezone: true, mode: "date" }).defaultNow().notNull(),
},
(table) => [unique("name_unique").on(table.name)],
);
10 replies
DTDrizzle Team
Created by Newt on 4/15/2025 in #help
Type Error when Generating Typebox
My Code: Code:
import { table } from "$lib/db/schema.ts";
import { createSchemaFactory } from "drizzle-typebox";
import { t } from "elysia";

const { createInsertSchema, createSelectSchema, createUpdateSchema } = createSchemaFactory({ typeboxInstance: t });

const Content = t.Object({
text: t.String(),
data: t.String(),
});

const MessageExample = t.Object({
user: t.String(),
content: Content,
});

export const AgentSchema = {
//The Error Apears here:
insert: createInsertSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
select: createSelectSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
update: createUpdateSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
} as const;
import { table } from "$lib/db/schema.ts";
import { createSchemaFactory } from "drizzle-typebox";
import { t } from "elysia";

const { createInsertSchema, createSelectSchema, createUpdateSchema } = createSchemaFactory({ typeboxInstance: t });

const Content = t.Object({
text: t.String(),
data: t.String(),
});

const MessageExample = t.Object({
user: t.String(),
content: Content,
});

export const AgentSchema = {
//The Error Apears here:
insert: createInsertSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
select: createSelectSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
update: createUpdateSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
} as const;
10 replies
DTDrizzle Team
Created by The Rumbling on 12/17/2024 in #help
Cannot generate Typebox schema from Drizzle Enum
My Code: Code:
import { table } from "$lib/db/schema.ts";
import { createSchemaFactory } from "drizzle-typebox";
import { t } from "elysia";

const { createInsertSchema, createSelectSchema, createUpdateSchema } = createSchemaFactory({ typeboxInstance: t });

const Content = t.Object({
text: t.String(),
data: t.String(),
});

const MessageExample = t.Object({
user: t.String(),
content: Content,
});

export const AgentSchema = {
//The Error Apears here:
insert: createInsertSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
select: createSelectSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
update: createUpdateSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
} as const;
import { table } from "$lib/db/schema.ts";
import { createSchemaFactory } from "drizzle-typebox";
import { t } from "elysia";

const { createInsertSchema, createSelectSchema, createUpdateSchema } = createSchemaFactory({ typeboxInstance: t });

const Content = t.Object({
text: t.String(),
data: t.String(),
});

const MessageExample = t.Object({
user: t.String(),
content: Content,
});

export const AgentSchema = {
//The Error Apears here:
insert: createInsertSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
select: createSelectSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
//The Error Apears here:
update: createUpdateSchema(table.agent, {
messageExamples: t.Array(t.Array(MessageExample)),
}),
} as const;
8 replies
DTDrizzle Team
Created by The Rumbling on 12/17/2024 in #help
Cannot generate Typebox schema from Drizzle Enum
I'm encountering a type compatibility issue with Drizzle ORM and TypeBox. When using createSchemaFactory from drizzle-typebox with PostgreSQL tables, I'm getting type errors when trying to create schemas. But in Runtime it Works without any Problems, i also Tried to edit my tsconfig to:
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"noUncheckedIndexedAccess": true,
"baseUrl": ".",
"paths": {
"$server": ["./src/server.ts"],
"$lib/*": ["./src/lib/*"]
}
},
"include": ["src"]
}
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"noUncheckedIndexedAccess": true,
"baseUrl": ".",
"paths": {
"$server": ["./src/server.ts"],
"$lib/*": ["./src/lib/*"]
}
},
"include": ["src"]
}
Versions:
"drizzle-orm": "^0.41.0",
"drizzle-typebox": "^0.3.1",
"drizzle-orm": "^0.41.0",
"drizzle-typebox": "^0.3.1",
The error suggests that the PostgreSQL-specific column types (PgColumn) from my table definition aren't compatible with the generic Column type expected by the schema factory functions:
Argument of type 'PgTableWithColumns<...>' is not assignable to parameter
of type 'Table<...>'. The types of '_.config.columns' are incompatible...
Argument of type 'PgTableWithColumns<...>' is not assignable to parameter
of type 'Table<...>'. The types of '_.config.columns' are incompatible...
Has anyone encountered similar type mismatches when using PostgreSQL-specific types with the schema factory? Is there a proper way to handle this without type assertions?
8 replies