Conversation
Breaking dependency change: the npm package renamed from @sinclair/typebox to typebox for the 1.0 release. Key migration changes: - Replace Kind symbol with Type.IsUnion()/Type.IsNever() guards - Replace Type.Uint8Array() with Type.Base<Uint8Array> custom type - Replace Type.Recursive() with Type.Cyclic() + Type.Ref() - Replace ValueErrorIterator with TLocalizedValidationError[] - Map error.instancePath → path for Ajv-aligned error format - Update TEnum type parameter from Record to array form - Widen procedure implementation handler types for overload compat - Update test assertions for new validation error messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TUint8Array now serializes with {"type": "Uint8Array"} instead of {}
by adding a `type` class field. Required-property validation errors
now expand to per-field paths via validationErrorToRiverErrors helper.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| * over River's existing handshake extension slot. | ||
| */ | ||
| const HandshakeBytesSchema = Type.Uint8Array(); | ||
| class TUint8Array extends Type.Base<Uint8Array> { |
There was a problem hiding this comment.
Type.Base is already deprecated, should be using Type.Refine with Type.Unsafe
We should also probably expose this type for backwards compat https://github.com/replit/river/pull/364/changes#diff-9a6d6522160cca40477e1d56e4be812ef47d78f2f7ffefdfcfda52dede2fb880R29-R30
There was a problem hiding this comment.
I also added Date for complete backwards compatibility.
- Add customSchemas/ with Uint8ArrayType and DateType for backwards compat (matching #364 pattern) - Replace deprecated Type.Base subclass with Type.Refine + Type.Unsafe - Fix procedure handler impl types: Function → typed any overload - Add ./customSchemas export to package.json and tsup entry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| export function validationErrorToRiverErrors( | ||
| error: TLocalizedValidationError, | ||
| ): Array<{ path: string; message: string }> { | ||
| if (error.keyword === 'required') { | ||
| const { requiredProperties } = (error as TRequiredError).params; | ||
|
|
||
| return requiredProperties.map((prop) => ({ | ||
| path: `${error.instancePath}/${prop}`, | ||
| message: error.message, | ||
| }); | ||
| })); | ||
| } | ||
|
|
||
| return result; | ||
| return [{ path: error.instancePath, message: error.message }]; | ||
| } | ||
|
|
||
| export function castTypeboxValueErrors( |
There was a problem hiding this comment.
Thoughts on adopting the new standard error format? https://github.com/replit/river/pull/364/changes#diff-6d1b576c8b42f3c38a9da7f660705f9720477793a6665ae30d0aeaf84a534b72R64-R69 I believe these errors match some sort of standard, forgot what it was but it's in the changelog.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
masad-frost
left a comment
There was a problem hiding this comment.
LGTM!
FYI only reason I didn't merge #364 is because I didn't have time to migrate river in our other repos, and didn't want to be in a situation where river changes have to continue to be backported to 0.x, so just beware!
Also, for our piece of mind, so that we can upgrade server independent of clients, might be worth throwing in a backwards compat test like the codec and serialization ones from the other PR, we'll delete it once we migrate.
typebox 1.x is ESM-only, so CJS require() entries would fail at runtime. Remove all "require" exports and drop cjs from tsup format. Expand validationErrorToRiverErrors to reconstruct per-field paths for additionalProperties, propertyNames, and unevaluatedProperties errors (not just required). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Summary
@sinclair/typebox0.34.x totypebox1.x (package was renamed for the 1.0 release)Breaking changes addressed
Kindsymbol removedType.IsUnion()/Type.IsNever()guardsType.Uint8Array()removedType.Base<Uint8Array>custom typeType.Recursive()removedType.Cyclic()+Type.Ref()ValueErrorIteratorremovedValue.Errors()now returnsTLocalizedValidationError[]error.instancePathmapped topathfor wire compatTEnumtype param changedTEnum<Record<string, string>>→TEnum<string[]>Test plan
tsc --noEmitpassesnpm run buildsucceeds🤖 Generated with Claude Code