Skip to content

Commit

Permalink
Revision 0.33.8 (#983)
Browse files Browse the repository at this point in the history
* Prevent Intersect Transform Encode callback from being called twice

* Make strict the Encode and Decode return type

* Support default annotation being assigned Functions for lazy value initialization on Create

*  Enable Mapping types to override user defined options from source type

* Support Constraint Copy for Pick, Omit (inline with Partial / Required) (Trialing Implementation)

* Flag Strict For Deprecation
  • Loading branch information
sinclairzx81 authored Sep 2, 2024
1 parent 1aee5c0 commit ed4c89a
Show file tree
Hide file tree
Showing 36 changed files with 307 additions and 257 deletions.
39 changes: 39 additions & 0 deletions changelog/0.32.0.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@


### 0.32.0

- [Revision 0.32.35](https://github.com/sinclairzx81/typebox/pull/914) Support Any for Record keys, Revert error message on required property, Fix order dependency for Union Convert.
- [Revision 0.32.34](https://github.com/sinclairzx81/typebox/pull/914) Fix template literal generation for template literals embedded within template literals.
- [Revision 0.32.33](https://github.com/sinclairzx81/typebox/pull/905) Pin ESM compiler target to ES2020.
- [Revision 0.32.32](https://github.com/sinclairzx81/typebox/pull/898) Fix for Enum properties when used with Mapped types.
- [Revision 0.32.31](https://github.com/sinclairzx81/typebox/pull/881) Fix for Cast. Dereference Union variants before scoring.
- [Revision 0.32.30](https://github.com/sinclairzx81/typebox/pull/868) Support null object prototypes for Encode/Decode.
- [Revision 0.32.29](https://github.com/sinclairzx81/typebox/pull/862) Key derive optimization to improve Intersect Encode/Decode performance.
- [Revision 0.32.28](https://github.com/sinclairzx81/typebox/pull/861) Fix for TransformEncode introduced with 0.32.24, 0.32.25 optimizations.
- [Revision 0.32.27](https://github.com/sinclairzx81/typebox/pull/854) Support for esm.sh and general build tooling updates.
- [Revision 0.32.26](https://github.com/sinclairzx81/typebox/pull/851) Optimization for number checks, use Number.isFinite(x) over typeof `number`.
- [Revision 0.32.25](https://github.com/sinclairzx81/typebox/pull/849) Optimizations for type builder to improve schema creation performance for computed types.
- [Revision 0.32.24](https://github.com/sinclairzx81/typebox/pull/848) Optimizations for Convert to avoid unnecessary object initialization and cloning.
- [Revision 0.32.22](https://github.com/sinclairzx81/typebox/pull/840) Add Support for Optional and Readonly Function and Constructor Arguments.
- [Revision 0.32.21](https://github.com/sinclairzx81/typebox/pull/836) Refactor Array Conversion logic. Discard TNever on TComposite.
- [Revision 0.32.20](https://github.com/sinclairzx81/typebox/pull/810) Fix compiler regression (TS 5.3.3 -> 5.4.2) generating Diff declaration structures.
- [Revision 0.32.19](https://github.com/sinclairzx81/typebox/pull/805) Revert Union Convert logic added on 0.32.16.
- [Revision 0.32.18](https://github.com/sinclairzx81/typebox/pull/801) Add explicit return type on TypeSystem.Type.
- [Revision 0.32.17](https://github.com/sinclairzx81/typebox/pull/799) Detect ambiguous inference for StaticDecode when inferring as any.
- [Revision 0.32.16](https://github.com/sinclairzx81/typebox/pull/791) Enhance Composite, Mapped, Indexed and Transform types. Intersect and Union Convert updates, Include Path in Validation Error.
- [Revision 0.32.15](https://github.com/sinclairzx81/typebox/pull/774) Additional internal guards for Type Arrays, Map and Set structures.
- [Revision 0.32.14](https://github.com/sinclairzx81/typebox/pull/753) Use barrel exports for submodules.
- [Revision 0.32.13](https://github.com/sinclairzx81/typebox/pull/744) Add minLength and maxLength constraint for RegExp
- [Revision 0.32.12](https://github.com/sinclairzx81/typebox/pull/740) Fix option assignment on Record types.
- [Revision 0.32.11](https://github.com/sinclairzx81/typebox/pull/738) Optimize Extract, Exclude. Overloads for Template Literal
- [Revision 0.32.10](https://github.com/sinclairzx81/typebox/pull/734) Export additional type infrastructure for Partial and Required
- [Revision 0.32.9](https://github.com/sinclairzx81/typebox/pull/731) Generalize Composite to accept schematics of type TSchema[]
- [Revision 0.32.8](https://github.com/sinclairzx81/typebox/pull/728) Ensure schema `default` annotation is cloned on Create.
- [Revision 0.32.7](https://github.com/sinclairzx81/typebox/pull/727) Ensure schema `default` annotation is cloned on Default.
- [Revision 0.32.6](https://github.com/sinclairzx81/typebox/pull/724) Export additional type infrastructure for mapping types
- [Revision 0.32.5](https://github.com/sinclairzx81/typebox/pull/718) Update licence year span for 2024
- [Revision 0.32.4](https://github.com/sinclairzx81/typebox/pull/708) Ensure ErrorFunctionParameter type is exported
- [Revision 0.32.3](https://github.com/sinclairzx81/typebox/pull/703) Simplify Record Static Type
- [Revision 0.32.1](https://github.com/sinclairzx81/typebox/pull/701) Specify default exports for Web Pack


## [0.32.0](https://www.npmjs.com/package/@sinclair/typebox/v/0.32.0)

## Overview
Expand Down
26 changes: 26 additions & 0 deletions changelog/0.33.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### 0.33.0

- [Revision 0.33.8](https://github.com/sinclairzx81/typebox/pull/983)
- [982](https://github.com/sinclairzx81/typebox/issues/982) Prevent Intersect Transform Encode callback from being called twice
- [974](https://github.com/sinclairzx81/typebox/issues/974) Make strict the Encode and Decode return type
- [975](https://github.com/sinclairzx81/typebox/issues/975) Support default annotation being assigned Functions for lazy value initialization on Create
- [980](https://github.com/sinclairzx81/typebox/issues/980) Enable Mapping types to override user defined options from source type
- [976](https://github.com/sinclairzx81/typebox/issues/976) Support Constraint Copy for Pick, Omit (inline with Partial / Required) (Trialing Implementation)
- Flag Strict For Deprecation
- [Revision 0.33.7](https://github.com/sinclairzx81/typebox/pull/964)
- Additional updates to improve Default for enumerable objects.
- [Revision 0.33.6](https://github.com/sinclairzx81/typebox/pull/963)
- Add object traversal path for Default. Ensure enumerable objects are traversed.
- [Revision 0.33.5](https://github.com/sinclairzx81/typebox/pull/959)
- Provide better support for transforming properties with optional modifiers.
- [Revision 0.33.4](https://github.com/sinclairzx81/typebox/pull/953)
- Add Assert and Parse value functions. Add defacto AssertError type.
- [Revision 0.33.3](https://github.com/sinclairzx81/typebox/pull/950)
- Optimize Value Diff algorithm. Update edit sequence to INSERT, UPDATE then DELETE.
- [Revision 0.33.2](https://github.com/sinclairzx81/typebox/pull/947)
- Ensure user defined schema options are retained on mapping types, Pick, Omit and Mapped.
- [Revision 0.33.1](https://github.com/sinclairzx81/typebox/pull/945)
- Apply mutability fix for Intrinsic and Not schematics (inline with Default)
- [Revision 0.33.0](https://github.com/sinclairzx81/typebox/pull/941)
- Add InstanceMode to enable Clone, Freeze and Default schema initialization options. Optimize for Default.

100 changes: 0 additions & 100 deletions changelog/latest.md

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sinclair/typebox",
"version": "0.33.7",
"version": "0.33.8",
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
"keywords": [
"typescript",
Expand Down
30 changes: 0 additions & 30 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ License MIT
- [Transform](#types-transform)
- [Guard](#types-guard)
- [Unsafe](#types-unsafe)
- [Strict](#types-strict)
- [Values](#values)
- [Assert](#values-assert)
- [Create](#values-create)
Expand Down Expand Up @@ -1078,35 +1077,6 @@ if(TypeGuard.IsString(T)) {
}
```
<a name='types-strict'></a>
### Strict
TypeBox types contain various symbol properties that are used for reflection, composition and compilation. These properties are not strictly valid Json Schema; so in some cases it may be desirable to omit them. TypeBox provides a `Strict` function that will omit these properties if necessary.
```typescript
const T = Type.Object({ // const T = {
name: Type.Optional(Type.String()) // [Symbol(TypeBox.Kind)]: 'Object',
}) // type: 'object',
// properties: {
// name: {
// type: 'string',
// [Symbol(TypeBox.Kind)]: 'String',
// [Symbol(TypeBox.Optional)]: 'Optional'
// }
// }
// }

const U = Type.Strict(T) // const U = {
// type: 'object',
// properties: {
// name: {
// type: 'string'
// }
// }
// }
```
<a name='values'></a>
## Values
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ export class TypeCheck<T extends TSchema> {
return this.checkFunc(value)
}
/** Decodes a value or throws if error */
public Decode<R = StaticDecode<T>>(value: unknown): R {
public Decode<Static = StaticDecode<T>, Result extends Static = Static>(value: unknown): Result {
if (!this.checkFunc(value)) throw new TransformDecodeCheckError(this.schema, value, this.Errors(value).First()!)
return (this.hasTransform ? TransformDecode(this.schema, this.references, value) : value) as never
}
/** Encodes a value or throws if error */
public Encode<R = StaticEncode<T>>(value: unknown): R {
public Encode<Static = StaticDecode<T>, Result extends Static = Static>(value: unknown): Result {
const encoded = this.hasTransform ? TransformEncode(this.schema, this.references, value) : value
if (!this.checkFunc(encoded)) throw new TransformEncodeCheckError(this.schema, value, this.Errors(value).First()!)
return encoded as never
Expand Down
2 changes: 1 addition & 1 deletion src/type/object/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { Kind } from '../symbols/index'
// ------------------------------------------------------------------
// TypeGuard
// ------------------------------------------------------------------
import { IsOptional, IsSchema } from '../guard/kind'
import { IsOptional } from '../guard/kind'

// ------------------------------------------------------------------
// ObjectStatic
Expand Down
Loading

0 comments on commit ed4c89a

Please sign in to comment.