deno.land / x / typebox@0.32.21 / changelog / 0.24.44.md

0.24.44

Updates:

  • 189 Both Value.Error(T, value) and TypeCheck.Error(value) now return an iterator for validation errors.
  • 191 TypeBox now provides a TypeGuard API that can be used to check the structural validity of TypeBox type. The TypeGuard can be used in reflection / code generation scenarios to resolve the appropriate inner TSchema type while traversing a outer type.
  • 197 TypeBox now implements conditional runtime type mapping. This functionality is offered as separate import for the 0.24.0 release but may be provided as standard type in later releases. This API enables type T = Foo extends Bar ? true : false conditional checks to be implemented at runtime. This API also provides the Exclude and Extract utility types which are implemented through conditional types in TypeScript.
  • 199 TypeBox now provides better support for variadic function and constructor signatures. Currently variadic types are mapped as Tuple types.
  • 200 The types TPick and TOmit now support types of TUnion<TLiteral<string>[]> to be used to select properties. Additionally, KeyOf now returns TUnion<TLiteral<string>[]>, allowing KeyOf schemas to be passed to TPick and TOmit.
  • 214 TypeBox now provides better support for i18n. To achieve this, TypeBox includes fixed mappable error codes on the ValueError type. These codes can be used by external implementers to create localized error messages. TypeBox may include localized error codes as an optional import in future releases.
  • 288 TypeBox now allows users to implement custom string validator formats. These formats are internally shared between the Value and TypeCompiler API's. TypeBox does not currently provide any built in formats, however the standard expected set (email, uuid, uri, etc) may be provided via optional import (inline with ajv-formats usage)
  • 229 The Value.Cast() function now implements automatic coercion of string, number and Boolean types.
  • 231 TypeBox provides a new Value.Diff<T>() and Value.Patch<T>() utility API for JavaScript values. This API is intended to provide a basis for the efficient transmission of state updates across a network. This API can diff any JavaScript value (typed or untyped) but is recommended to be used in conjunction with a formal static type.
  • 236 TypeBox now implements the TNever type. This type is analogous to TypeScript's never type and is used in instances a composition results in a non-reconcilable type. Currently this type is implemented for empty TUnion<[]> types only. Future releases may utilize this type for planned updates to TIntersect (for example string & number resolves to never)
  • 241 247 TypeBox now exposes a ValuePointer API that can be used to mutate a value via an RFC6901 JSON Pointer. Previously this functionality was internally used by Value.Diff() and Value.Patch() functions but is now offered as an optional import for implementations that need to update values manually through pointer references.

Additional:

  • This project now includes two reference code generation utilities that can be used in custom build tooling. The first is TypeScriptCodeGen which will remap TypeScript interface and type definitions to TypeBox types. The second is TypeBoxCodeGen which will map existing TypeBox types into TypeScript type definitions. These implementations are not expected to be part of the TypeBox package, but users are free to clone and enhance them in their existing tool chains. Reference implementations can be found https://github.com/sinclairzx81/typebox/tree/master/codegen
typebox

Version Info

Tagged at
4 weeks ago