Skip to content

fix(typebox): support typebox@1.3.x by replacing removed Type.Base#5985

Open
momomuchu wants to merge 1 commit into
drizzle-team:rc5from
momomuchu:fix/typebox-cjs-module-load-5981
Open

fix(typebox): support typebox@1.3.x by replacing removed Type.Base#5985
momomuchu wants to merge 1 commit into
drizzle-team:rc5from
momomuchu:fix/typebox-cjs-module-load-5981

Conversation

@momomuchu

Copy link
Copy Markdown

import 'drizzle-orm/typebox' throws at module load with typebox 1.3.x: "Class extends value undefined". typebox 1.3.0 removed Type.Base, and the four custom column types in src/typebox/column.ts were defined as class extends Type.Base<T>, which becomes class extends undefined. The crash is version-gated (1.0-1.2 load fine, 1.3.0+ throw) under both ESM and CJS, not a module-system issue.

This replaces the four types with Type.Unsafe + Type.Refine (the documented 1.3 replacement), keeping the public new TX() API and exported names via declaration merging, so no consumer or test changes. The typebox peer floor is raised to >=1.2.0 because Value.Check only honours Refine predicates from 1.2.0.

Verified: the built entry loads under both ESM and CJS with typebox 1.3.3; the four types accept valid and reject invalid input; the typebox validator suite passes across all dialects on 1.3.3 and 1.2.19. Reverting the type change reproduces the load crash.

Targets rc5, which carries the affected 1.0.0-rc.4.

Closes #5981

typebox 1.3.0 removed the `Type.Base` class that `drizzle-orm/typebox`
extended to define its custom TBuffer / TDate / TBigIntString /
TUnsignedBigIntString types. With typebox >=1.3.0 installed, `Type.Base`
is `undefined`, so `import 'drizzle-orm/typebox'` throws
`Class extends value undefined is not a constructor or null` at module
load time, under both CJS and ESM (it is not a CJS-interop issue).
Fixes drizzle-team#5981.

Redefine the four custom types with `Type.Unsafe` + `Type.Refine`, the
replacement documented in the typebox 1.3.0 changelog. The public
`new TX()` API and the exported type names are preserved via declaration
merging (an interface extending `TUnsafe<T>` plus a class whose
constructor returns the refined schema), so no consumer changes are
required and `Static<TX>` stays unchanged.

`Value.Check` only honors `Refine` predicates from typebox@1.2.0 onward,
so the `typebox` peer dependency floor is raised from `>=1.0.0` to
`>=1.2.0` to avoid silently weakening validation on older versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant