@sinclair/typebox@1.x introduces changes that break at least oneOf and possibly other outputs.
Evaluation
Migration guide
- ESM - already done that
- Kind, Hint, ReadonlyKind, OptionalKind replaced - affects
oneOf
- Type.Date and Type.Uint8Array removed - not used (dates are based on Type.String())
- Type.Recursive replaced - not used
- Type.Regex removed - check b/c I'm not sure
- Type.Composite replaced - used in experiment
- Type.Transform renamed - used in experiment
- Type.Const removed in favor of Script - not used
- Type.Pick and Type.Omit changed - not used
- TypeCompiler changes - not used
- Referential type support - seems to be TypeCompiler and Transform related
- FormatRegistry moved - not used
- TypeRegistry removed in favor of Type.Base - affects
oneOf
- TypeGuard removed - not used
- Value.Errors changes from iterator to array - not used
- Value.Cast renamed Repair - not used
- SetErrorFunction removed - not used
- CustomError handling - not used
To do
Notes
For use cases I'm most concerned with, I'm using AJV for validation, so code that uses output from to4ft doesn't care about changes to TypeBox's validator, validator error handling, validator formats. If you're using any of those TypeBox features, you need to update to TypeBox 1.x as part of moving to to4ft@2.x
to4ft doesn't use Type.Date because it works with the application/json media type where date and time data is a string and Fastify's JSON serializer. See #20, #21, #22, and #25 for previous work that ended with using Type.Unsafe<Date>() that supports passing a Date type to the serializer so Fastify will format it correctly while representing it as a string in input parameters. The application/json condition might change if #34 happens.
Items for later
- Revisit the concept of Type.Date and decide if it makes sense or not given our use case.
@sinclair/typebox@1.xintroduces changes that break at leastoneOfand possibly other outputs.Evaluation
Migration guide
oneOfoneOfTo do
oneOfneeds changes for TypeRegistry and Kind changes in TypeBox 1.xpatterninstead offormat: timeare painful to read in comparison.Type.CodecType.InterfaceandType.Evaluate.Notes
For use cases I'm most concerned with, I'm using AJV for validation, so code that uses output from
to4ftdoesn't care about changes to TypeBox's validator, validator error handling, validator formats. If you're using any of those TypeBox features, you need to update to TypeBox 1.x as part of moving toto4ft@2.xto4ftdoesn't useType.Datebecause it works with theapplication/jsonmedia type where date and time data is a string and Fastify's JSON serializer. See #20, #21, #22, and #25 for previous work that ended with usingType.Unsafe<Date>()that supports passing a Date type to the serializer so Fastify will format it correctly while representing it as a string in input parameters. Theapplication/jsoncondition might change if #34 happens.Items for later