Skip to content

Commit

Permalink
Revision 0.33.11 (#995)
Browse files Browse the repository at this point in the history
* Reference Issue on Unit | Formatting

* TypeScript 5.6.2

* Version
  • Loading branch information
sinclairzx81 authored Sep 14, 2024
1 parent a82c224 commit ddd85e1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion hammer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function benchmark() {
// Test
// -------------------------------------------------------------------------------
export async function test_typescript() {
for (const version of ['4.9.5', '5.0.4', '5.1.3', '5.1.6', '5.2.2', '5.3.2', '5.3.3', '5.4.3', '5.4.5', '5.5.2', '5.5.3', 'next', 'latest']) {
for (const version of ['4.9.5', '5.0.4', '5.1.3', '5.1.6', '5.2.2', '5.3.2', '5.3.3', '5.4.3', '5.4.5', '5.5.2', '5.5.3', '5.5.4', 'next', 'latest']) {
await shell(`npm install typescript@${version} --no-save`)
await test_static()
}
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sinclair/typebox",
"version": "0.33.10",
"version": "0.33.11",
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
"keywords": [
"typescript",
Expand Down Expand Up @@ -37,6 +37,6 @@
"ajv-formats": "^2.1.1",
"mocha": "^10.4.0",
"prettier": "^2.7.1",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
1 change: 0 additions & 1 deletion src/value/default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ function FromUnion(schema: TUnion, references: TSchema[], value: unknown): any {
const defaulted = ValueOrDefault(schema, value)
for (const inner of schema.anyOf) {
const result = Visit(inner, references, Clone(defaulted))

if (Check(inner, result)) {
return result
}
Expand Down
10 changes: 7 additions & 3 deletions test/runtime/value/default/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Value } from '@sinclair/typebox/value'
import { Type, Kind, TypeRegistry } from '@sinclair/typebox'
import { Assert } from '../../assert/index'

// prettier-ignore
describe('value/default/Union', () => {
it('Should use default', () => {
const T = Type.Union([Type.Number(), Type.String()], { default: 1 })
Expand Down Expand Up @@ -82,10 +83,13 @@ describe('value/default/Union', () => {
const R = Value.Default(T, { x: 3, y: 4 })
Assert.IsEqual(R, { x: 3, y: 4 })
})
it('Should return the original value if no schemas match', async () => {
// ----------------------------------------------------------------
// https://github.com/sinclairzx81/typebox/issues/993
// ----------------------------------------------------------------
it('Should return the original value if no schemas match (cloned interior variant)', async () => {
const T = Type.Union([
Type.Tuple([Type.Number(), Type.Number()]),
Type.Array(Type.Number()),
Type.Tuple([Type.Number(), Type.Number()]),
Type.Array(Type.Number())
])
const value = ['hello']
const R = Value.Default(T, value)
Expand Down

0 comments on commit ddd85e1

Please sign in to comment.