mirror of
https://github.com/zoriya/typebox.git
synced 2025-12-06 06:46:10 +00:00
4.2 KiB
4.2 KiB
0.24.44
Updates:
- 189 Both
Value.Error(T, value)andTypeCheck.Error(value)now return an iterator for validation errors. - 191 TypeBox now provides a
TypeGuardAPI 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 innerTSchematype while traversing a outer type. - 197 TypeBox now implements conditional runtime type mapping. This functionality is offered as separate import for the
0.24.0release but may be provided as standard type in later releases. This API enablestype T = Foo extends Bar ? true : falseconditional checks to be implemented at runtime. This API also provides theExcludeandExtractutility 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
Tupletypes. - 200 The types
TPickandTOmitnow support types ofTUnion<TLiteral<string>[]>to be used to select properties. Additionally,KeyOfnow returnsTUnion<TLiteral<string>[]>, allowingKeyOfschemas to be passed toTPickandTOmit. - 214 TypeBox now provides better support for i18n. To achieve this, TypeBox includes fixed mappable error codes on the
ValueErrortype. 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
ValueandTypeCompilerAPI'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>()andValue.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
TNevertype. This type is analogous to TypeScript'snevertype and is used in instances a composition results in a non-reconcilable type. Currently this type is implemented for emptyTUnion<[]>types only. Future releases may utilize this type for planned updates toTIntersect(for examplestring & numberresolves tonever) - 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()andValue.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
TypeScriptCodeGenwhich will remap TypeScriptinterfaceandtypedefinitions to TypeBox types. The second isTypeBoxCodeGenwhich 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