Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Jul 26, 2023
1 parent 5ae137d commit 8fbfdca
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions changelog/0.30.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This revision includes breaking representation changes to Extended Types and Mod
- [Optional and Readonly](#Optional-and-Readonly)
- [Iterator and AsyncIterator](#Iterator-and-AsyncIterator)
- [Order Independent References](#Order-Independent-References)
- [Value Submodules](#Value-Submodules)
- [Additional Array Constaints](#Additional-Array-Constaints)
- [Reducing Package Size](#Reducing-Package-Size)
- Breaking
Expand All @@ -24,9 +25,11 @@ This revision includes breaking representation changes to Extended Types and Mod

## Extended Type Representations

Revision 0.30.0 updates representations for all extended types. These changes are made due to TypeBox's observed role as a general purpose JavaScript validation library as well as to deprecate support for extended type validation in Ajv. For some history, attempts were made on Revision 0.25.0 to restructure extended type respresentations to provide Ajv hooks for custom type configuration. These hooks used the `type` property where `{ type: 'object', instanceOf: 'TypeName' }` was used to configure schematics for JavaScript objects, and `{type: 'null', typeOf: 'PrimitiveName' }` was used for JavaScript primitives. Despite providing these hooks, Ajv would still struggle with validation of primitive types (such as `undefined`), and generally types of `Function`, `Constructor` and `Promise` were meaningless to Ajv (and TypeBox) in terms of validation. For this reason, expressing hooks for Ajv for non-validatable schematics does not seem to make much sense in the long term, particularily when these schematics are used principally as framing schematics to describe callable interfaces.
Revision 0.30.0 updates representations for all extended types. This change is made due to TypeBox's observed role as a general purpose JavaScript validation library as well as to deprecate support for extended type validation in Ajv (which was partially functional at best)

This change mostly represents a move towards a formal specification to express pure JavaScript constructs. This change however will implicate the use of `Uint8Array` and `Date` objects when configuring for Ajv. A supplimentary fallback will be provided in the `/examples` directory.
Attempts were made on Revision 0.25.0 to restructure extended types to provide Ajv hooks for custom type configuration. These hooks used the `type` property where `{ type: 'object', instanceOf: 'TypeName' }` was used to configure schematics for JavaScript objects, and `{ type: 'null', typeOf: 'PrimitiveName' }` was used for JavaScript primitives. Despite these hooks, Ajv would still struggle with validation of primitive types (such as `undefined`), and for the types `Function`, `Constructor` and `Promise`; these were meaningless to Ajv and it did not make sense to try provide hooks for a validator that could not use them anyway.

This change mostly represents a move towards a formal specification to express pure JavaScript constructs. The change will implicate the use of `Uint8Array` and `Date` objects when configuring for Ajv. A supplimentary fallback will be provided in the `/examples` directory using `Type.Unsafe`

```typescript
// Revision 0.29.0
Expand All @@ -46,9 +49,7 @@ const U = Type.Undefined() // const U: TUndefined = { ty

## Optional and Readonly

Revision 0.30.0 deprecates the `[Modifier]` symbol and introduces the `[Readonly]` and `[Optional]` symbols. This change was carried out to simplify internal type inference as well as to streamline runtime mapping logic where adding and removing individual `[Readonly]` and `[Optional]` symbols is cleaner than conditionally checking 3 variants states of `[Modifier]`.

This change should not implicate users leveraging the `Type.*` for type construction, however implementors building runtime mapping utilities should update to use the new symbols.
Revision 0.30.0 deprecates the `[Modifier]` symbol and introduces two new symbols, `[Readonly]` and `[Optional]`. This change is carried out to simplify internal type inference as well as to simplify runtime mapping logic. This change should not implicate users leveraging the `Type.*` for type construction, however implementors building runtime mapping utilities should update to use the new symbols.

```typescript
// Revision 0.29.0
Expand Down Expand Up @@ -142,6 +143,28 @@ const T = Type.Object({
}, { $id: 'T' })
```

<a name="Value-Submodules"></a>

## Value Submodules

Revision 0.30.0 refactors the `Value.*` module to allow each submodule to be imported individually. This change is part of larger refactoring to reduce the size of the Value module, but also to address issues with bundlers unable to tree-shake against the internal namespaces.

The `Value.*` namespace is retained on Revision 0.30.0

```typescript
// Revision 0.29.0
//
import { Value } from '@sinclair/typebox/value' // Value.* namespace
const A = Value.Create(Type.String())

// Revision 0.30.0
//
import { Create } from '@sinclair/typebox/value/create' // Create function only
const B = Create(Type.String())
```

<a name="Additional Array Constaints"></a>

## Additional Array Constaints
Expand Down Expand Up @@ -206,7 +229,7 @@ For information on configuring custom formats on Ajv, refer to https://ajv.js.or

## Reducing Package Size

Revision 0.30.0 marks a more concentrated effort to try and reduce TypeBox installable package sizes with initial work carried out on `typebox.ts` to refactor `TypeExtends` on the 0.30.0 Revision. Additional work will be carried out over the next few revisions to try and optimize compression, as well as investigating techniques more condusive to tree shaking.
Revision 0.30.0 implements a number of code refactorings to attempt to reduce package size. These changes were primarily focused on the `Value` module which has increased in size due to functionality being introduced over the past several revisions.

```typescript
// Revision 0.29.0
Expand All @@ -226,10 +249,10 @@ Revision 0.30.0 marks a more concentrated effort to try and reduce TypeBox insta
┌──────────────────────┬────────────┬────────────┬─────────────┐
│ (index) │ CompiledMinifiedCompression
├──────────────────────┼────────────┼────────────┼─────────────┤
typebox/compiler'130.3 kb'' 59.0 kb''2.21 x'
typebox/errors'112.0 kb'' 50.1 kb''2.24 x'
typebox/compiler'129.5 kb'' 58.7 kb''2.21 x'
typebox/errors'111.2 kb'' 49.8 kb''2.23 x'
typebox/system' 75.4 kb'' 31.3 kb''2.41 x'
typebox/value'181.7 kb'' 79.2 kb''2.29 x'
typebox/value'174.3 kb'' 76.4 kb''2.28 x'
typebox' 74.3 kb'' 30.8 kb''2.41 x'
└──────────────────────┴────────────┴────────────┴─────────────┘
```

0 comments on commit 8fbfdca

Please sign in to comment.