Skip to content

Commit ed4c89a

Browse files
authored
Revision 0.33.8 (#983)
* 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
1 parent 1aee5c0 commit ed4c89a

File tree

36 files changed

+307
-257
lines changed

36 files changed

+307
-257
lines changed

changelog/0.32.0.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
2+
3+
### 0.32.0
4+
5+
- [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.
6+
- [Revision 0.32.34](https://github.com/sinclairzx81/typebox/pull/914) Fix template literal generation for template literals embedded within template literals.
7+
- [Revision 0.32.33](https://github.com/sinclairzx81/typebox/pull/905) Pin ESM compiler target to ES2020.
8+
- [Revision 0.32.32](https://github.com/sinclairzx81/typebox/pull/898) Fix for Enum properties when used with Mapped types.
9+
- [Revision 0.32.31](https://github.com/sinclairzx81/typebox/pull/881) Fix for Cast. Dereference Union variants before scoring.
10+
- [Revision 0.32.30](https://github.com/sinclairzx81/typebox/pull/868) Support null object prototypes for Encode/Decode.
11+
- [Revision 0.32.29](https://github.com/sinclairzx81/typebox/pull/862) Key derive optimization to improve Intersect Encode/Decode performance.
12+
- [Revision 0.32.28](https://github.com/sinclairzx81/typebox/pull/861) Fix for TransformEncode introduced with 0.32.24, 0.32.25 optimizations.
13+
- [Revision 0.32.27](https://github.com/sinclairzx81/typebox/pull/854) Support for esm.sh and general build tooling updates.
14+
- [Revision 0.32.26](https://github.com/sinclairzx81/typebox/pull/851) Optimization for number checks, use Number.isFinite(x) over typeof `number`.
15+
- [Revision 0.32.25](https://github.com/sinclairzx81/typebox/pull/849) Optimizations for type builder to improve schema creation performance for computed types.
16+
- [Revision 0.32.24](https://github.com/sinclairzx81/typebox/pull/848) Optimizations for Convert to avoid unnecessary object initialization and cloning.
17+
- [Revision 0.32.22](https://github.com/sinclairzx81/typebox/pull/840) Add Support for Optional and Readonly Function and Constructor Arguments.
18+
- [Revision 0.32.21](https://github.com/sinclairzx81/typebox/pull/836) Refactor Array Conversion logic. Discard TNever on TComposite.
19+
- [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.
20+
- [Revision 0.32.19](https://github.com/sinclairzx81/typebox/pull/805) Revert Union Convert logic added on 0.32.16.
21+
- [Revision 0.32.18](https://github.com/sinclairzx81/typebox/pull/801) Add explicit return type on TypeSystem.Type.
22+
- [Revision 0.32.17](https://github.com/sinclairzx81/typebox/pull/799) Detect ambiguous inference for StaticDecode when inferring as any.
23+
- [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.
24+
- [Revision 0.32.15](https://github.com/sinclairzx81/typebox/pull/774) Additional internal guards for Type Arrays, Map and Set structures.
25+
- [Revision 0.32.14](https://github.com/sinclairzx81/typebox/pull/753) Use barrel exports for submodules.
26+
- [Revision 0.32.13](https://github.com/sinclairzx81/typebox/pull/744) Add minLength and maxLength constraint for RegExp
27+
- [Revision 0.32.12](https://github.com/sinclairzx81/typebox/pull/740) Fix option assignment on Record types.
28+
- [Revision 0.32.11](https://github.com/sinclairzx81/typebox/pull/738) Optimize Extract, Exclude. Overloads for Template Literal
29+
- [Revision 0.32.10](https://github.com/sinclairzx81/typebox/pull/734) Export additional type infrastructure for Partial and Required
30+
- [Revision 0.32.9](https://github.com/sinclairzx81/typebox/pull/731) Generalize Composite to accept schematics of type TSchema[]
31+
- [Revision 0.32.8](https://github.com/sinclairzx81/typebox/pull/728) Ensure schema `default` annotation is cloned on Create.
32+
- [Revision 0.32.7](https://github.com/sinclairzx81/typebox/pull/727) Ensure schema `default` annotation is cloned on Default.
33+
- [Revision 0.32.6](https://github.com/sinclairzx81/typebox/pull/724) Export additional type infrastructure for mapping types
34+
- [Revision 0.32.5](https://github.com/sinclairzx81/typebox/pull/718) Update licence year span for 2024
35+
- [Revision 0.32.4](https://github.com/sinclairzx81/typebox/pull/708) Ensure ErrorFunctionParameter type is exported
36+
- [Revision 0.32.3](https://github.com/sinclairzx81/typebox/pull/703) Simplify Record Static Type
37+
- [Revision 0.32.1](https://github.com/sinclairzx81/typebox/pull/701) Specify default exports for Web Pack
38+
39+
140
## [0.32.0](https://www.npmjs.com/package/@sinclair/typebox/v/0.32.0)
241

342
## Overview

changelog/0.33.0.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### 0.33.0
2+
3+
- [Revision 0.33.8](https://github.com/sinclairzx81/typebox/pull/983)
4+
- [982](https://github.com/sinclairzx81/typebox/issues/982) Prevent Intersect Transform Encode callback from being called twice
5+
- [974](https://github.com/sinclairzx81/typebox/issues/974) Make strict the Encode and Decode return type
6+
- [975](https://github.com/sinclairzx81/typebox/issues/975) Support default annotation being assigned Functions for lazy value initialization on Create
7+
- [980](https://github.com/sinclairzx81/typebox/issues/980) Enable Mapping types to override user defined options from source type
8+
- [976](https://github.com/sinclairzx81/typebox/issues/976) Support Constraint Copy for Pick, Omit (inline with Partial / Required) (Trialing Implementation)
9+
- Flag Strict For Deprecation
10+
- [Revision 0.33.7](https://github.com/sinclairzx81/typebox/pull/964)
11+
- Additional updates to improve Default for enumerable objects.
12+
- [Revision 0.33.6](https://github.com/sinclairzx81/typebox/pull/963)
13+
- Add object traversal path for Default. Ensure enumerable objects are traversed.
14+
- [Revision 0.33.5](https://github.com/sinclairzx81/typebox/pull/959)
15+
- Provide better support for transforming properties with optional modifiers.
16+
- [Revision 0.33.4](https://github.com/sinclairzx81/typebox/pull/953)
17+
- Add Assert and Parse value functions. Add defacto AssertError type.
18+
- [Revision 0.33.3](https://github.com/sinclairzx81/typebox/pull/950)
19+
- Optimize Value Diff algorithm. Update edit sequence to INSERT, UPDATE then DELETE.
20+
- [Revision 0.33.2](https://github.com/sinclairzx81/typebox/pull/947)
21+
- Ensure user defined schema options are retained on mapping types, Pick, Omit and Mapped.
22+
- [Revision 0.33.1](https://github.com/sinclairzx81/typebox/pull/945)
23+
- Apply mutability fix for Intrinsic and Not schematics (inline with Default)
24+
- [Revision 0.33.0](https://github.com/sinclairzx81/typebox/pull/941)
25+
- Add InstanceMode to enable Clone, Freeze and Default schema initialization options. Optimize for Default.
26+

changelog/latest.md

Lines changed: 0 additions & 100 deletions
This file was deleted.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sinclair/typebox",
3-
"version": "0.33.7",
3+
"version": "0.33.8",
44
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
55
"keywords": [
66
"typescript",

readme.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ License MIT
7777
- [Transform](#types-transform)
7878
- [Guard](#types-guard)
7979
- [Unsafe](#types-unsafe)
80-
- [Strict](#types-strict)
8180
- [Values](#values)
8281
- [Assert](#values-assert)
8382
- [Create](#values-create)
@@ -1078,35 +1077,6 @@ if(TypeGuard.IsString(T)) {
10781077
}
10791078
```
10801079
1081-
<a name='types-strict'></a>
1082-
1083-
### Strict
1084-
1085-
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.
1086-
1087-
```typescript
1088-
const T = Type.Object({ // const T = {
1089-
name: Type.Optional(Type.String()) // [Symbol(TypeBox.Kind)]: 'Object',
1090-
}) // type: 'object',
1091-
// properties: {
1092-
// name: {
1093-
// type: 'string',
1094-
// [Symbol(TypeBox.Kind)]: 'String',
1095-
// [Symbol(TypeBox.Optional)]: 'Optional'
1096-
// }
1097-
// }
1098-
// }
1099-
1100-
const U = Type.Strict(T) // const U = {
1101-
// type: 'object',
1102-
// properties: {
1103-
// name: {
1104-
// type: 'string'
1105-
// }
1106-
// }
1107-
// }
1108-
```
1109-
11101080
<a name='values'></a>
11111081
11121082
## Values

src/compiler/compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ export class TypeCheck<T extends TSchema> {
105105
return this.checkFunc(value)
106106
}
107107
/** Decodes a value or throws if error */
108-
public Decode<R = StaticDecode<T>>(value: unknown): R {
108+
public Decode<Static = StaticDecode<T>, Result extends Static = Static>(value: unknown): Result {
109109
if (!this.checkFunc(value)) throw new TransformDecodeCheckError(this.schema, value, this.Errors(value).First()!)
110110
return (this.hasTransform ? TransformDecode(this.schema, this.references, value) : value) as never
111111
}
112112
/** Encodes a value or throws if error */
113-
public Encode<R = StaticEncode<T>>(value: unknown): R {
113+
public Encode<Static = StaticDecode<T>, Result extends Static = Static>(value: unknown): Result {
114114
const encoded = this.hasTransform ? TransformEncode(this.schema, this.references, value) : value
115115
if (!this.checkFunc(encoded)) throw new TransformEncodeCheckError(this.schema, value, this.Errors(value).First()!)
116116
return encoded as never

src/type/object/object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { Kind } from '../symbols/index'
3737
// ------------------------------------------------------------------
3838
// TypeGuard
3939
// ------------------------------------------------------------------
40-
import { IsOptional, IsSchema } from '../guard/kind'
40+
import { IsOptional } from '../guard/kind'
4141

4242
// ------------------------------------------------------------------
4343
// ObjectStatic

0 commit comments

Comments
 (0)