drizzle-team / drizzle-team/drizzle-orm

[BUG]: TypeScript Errors with skipLibCheck: false

Open
#5,187 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

## Environment

| Dependency | Version |
|------------|---------|
| drizzle-orm | 0.45.1 |
| typescript | 5.9.3 |
| Node.js | v22+ |
| Package Manager | pnpm 10.25.0 |

## Description

When using `skipLibCheck: false` in tsconfig.json, **82 TypeScript errors** are generated in drizzle-orm's `.d.ts` files. This forces users to enable `skipLibCheck: true`, which disables type validation for all dependencies.

## Error Categories

### 1. TS2420 - Classes not implementing `SQLWrapper` (missing `getSQL`)

```
drizzle-orm/mysql-core/query-builders/delete.d.ts(36,22): error TS2420:
Class 'MySqlDeleteBase' incorrectly implements interface 'SQLWrapper'.
Property 'getSQL' is missing in type 'MySqlDeleteBase' but required in type 'SQLWrapper'.
```

**Affected classes:**
- `MySqlDeleteBase`
- `SingleStoreDeleteBase`
- `PgRelationalQuery`
- `GelRelationalQuery`

### 2. TS2515 - Non-abstract classes missing abstract member implementations

```
drizzle-orm/mysql-core/query-builders/select.d.ts(611,22): error TS2515:
Non-abstract class 'MySqlSelectBase' does not implement inherited abstract member
getSQL from class 'MySqlSelectQueryBuilderBase'.
```

**Affected classes:** All SingleStore column builders (~30 classes):
- `SingleStoreBigInt53Builder`
- `SingleStoreBinaryBuilder`
- `SingleStoreBooleanBuilder`
- `SingleStoreCharBuilder`
- `SingleStoreDateBuilder`
- `SingleStoreDateTimeBuilder`
- `SingleStoreDecimalBuilder`
- `SingleStoreDoubleBuilder`
- `SingleStoreFloatBuilder`
- `SingleStoreIntBuilder`
- `SingleStoreJsonBuilder`
- `SingleStoreMediumIntBuilder`
- `SingleStoreRealBuilder`
- `SingleStoreSerialBuilder`
- `SingleStoreSmallIntBuilder`
- `SingleStoreTextBuilder`
- `SingleStoreTimeBuilder`
- `SingleStoreTimestampBuilder`
- `SingleStoreTinyIntBuilder`
- `SingleStoreVarBinaryBuilder`
- `SingleStoreVarCharBuilder`
- `SingleStoreVectorBuilder`
- `SingleStoreYearBuilder`
- etc.

### 3. TS2344 - Type constraints not satisfied

```
drizzle-orm/mysql-core/query-builders/select.d.ts(294,244): error TS2344:
Type 'string' does not satisfy the constraint 'keyof this & string'.
Type '"session"' is not assignable to type '"offset" | "intersect" | "as" | ...'.
```

### 4. TS2559 - Incompatible types

```
drizzle-orm/pg-core/roles.d.ts(7,22): error TS2559:
Type 'PgRole' has no properties in common with type 'PgRoleConfig'.
```

## Minimal Reproduction

```bash
# 1. Create project
mkdir drizzle-ts-bug && cd drizzle-ts-bug
pnpm init
pnpm add drizzle-orm postgres
pnpm add -D typescript @types/node

# 2. Create tsconfig.json
cat > tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"skipLibCheck": false,
"noEmit": true
},
"include": ["src/**/*"]
}
EOF

# 3. Create minimal file
mkdir src && cat > src/index.ts << 'EOF'
import { pgTable, text } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
id: text("id").primaryKey(),
});
EOF

# 4. Run typecheck
npx tsc --noEmit
# → 82+ errors in node_modules/drizzle-orm
```

## Impact

1. **Forces `skipLibCheck: true`** - Disables type validation for all dependencies
2. **Breaks Hono RPC integration** - The `hc` client requires a valid type chain
3. **Silent regression risk** - Type errors in third-party libs are no longer detected

## Current Workaround

```json
{
"compilerOptions": {
"skipLibCheck": true
}
}
```

## Related Issues

- [#1207 - Many TypeScript Compile Errors](https://github.com/drizzle-team/drizzle-orm/issues/1207)
- [#2604 - Broken typings with TypeScript 5.5](https://github.com/drizzle-team/drizzle-orm/issues/2604)

## Root Cause Analysis

The `.d.ts` files generated by drizzle-orm's build process are not validated with `skipLibCheck: false` before publishing. The issues appear to stem from:

1. **SQLWrapper interface** - Not correctly implemented in several query builder classes
2. **Generic constraints** - Overly strict constraints in select query builders that don't account for all possible method names
3. **SingleStore support** - Many column builders are missing the `generatedAlwaysAs` abstract method implementation
4. **Role types** - `PgRole` and `GelRole` types have no overlap with their config counterparts

## Suggested Fix

Run `tsc --noEmit --skipLibCheck false` as part of the CI/CD pipeline before publishing to npm to catch these declaration file issues.

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction and run `npx tsc --noEmit` using `skipLibCheck: false` to confirm the declaration errors. Inspect the mentioned `mysql-core/query-builders/*.d.ts`, SingleStore column-builder declarations, `pg-core/roles.d.ts`, and related generated declarations; done means the published declarations type-check without these errors and the validation is covered before publishing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.