fix(typebox): support typebox@1.3.x by replacing removed Type.Base#5985
Open
momomuchu wants to merge 1 commit into
Open
fix(typebox): support typebox@1.3.x by replacing removed Type.Base#5985momomuchu wants to merge 1 commit into
momomuchu wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
import 'drizzle-orm/typebox'throws at module load with typebox 1.3.x: "Class extends value undefined". typebox 1.3.0 removedType.Base, and the four custom column types insrc/typebox/column.tswere defined asclass extends Type.Base<T>, which becomesclass 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 publicnew TX()API and exported names via declaration merging, so no consumer or test changes. The typebox peer floor is raised to >=1.2.0 becauseValue.Checkonly honoursRefinepredicates 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