drizzle-team / drizzle-team/drizzle-orm

[BUG]: Extremely slow TypeScript inference when using drizzle-zod with nestjs

Open
#4,823 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

0.44.3

### What version of `drizzle-kit` are you using?

0.31.4

### Other packages

drizzle-zod@^0.8.2, zod@4.0.10, typescript@5.8.3, @nestjs/common@11.1.5

### Describe the Bug

When using `PipeTransform` with schemas generated from Drizzle-Zod, TypeScript inference becomes extremely slow or hangs indefinitely. Here's a minimal reproduction:

```typescript
// 1. Drizzle table definition
export const users = pgTable('users', {
firstName: text('first_name'),
});

// 2. Create Zod schemas from Drizzle
import { createInsertSchema, createSelectSchema } from 'drizzle-zod';

export const userInsertSchema = createInsertSchema(users);
export type CreateUserInput = z.infer;

// 3. Create Pipe: (https://docs.nestjs.com/pipes#binding-validation-pipes)

export class ZodValidationPipe implements PipeTransform {
constructor(private schema: z.ZodSchema) {}

transform(value: unknown) {
try {
const parsedValue = this.schema.parse(value);
return parsedValue;
} catch (error) {
throw new BadRequestException('Validation failed');
}
}
}

// 4. Usage in controller
@UsePipes(new ZodValidationPipe(userInsertSchema))
async createUser(@Body() createUserDto: CreateUserInput): Promise {
return this.userService.createUser(createUserDto);
}
```

**Expected Behavior:**
I want to be able to use drizzle-zod with nestjs for validation

**Actual Behavior:**
TypeScript inference becomes extremely slow (minutes) or never completes

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction in the issue and run TypeScript compilation around the createInsertSchema output, z.infer type, and ZodValidationPipe used by the controller. Compare compilation with and without the generated schema; done means inference completes promptly for the shown NestJS usage without changing validation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.