From 0ed2071eed41194fb1d333299c85736ef670700c Mon Sep 17 00:00:00 2001 From: sinclairzx81 Date: Thu, 19 Sep 2024 02:39:40 +0900 Subject: [PATCH] Revision 0.33.12 (#1000) * Version + Formatting * ChangeLog --- changelog/0.33.0.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- src/value/convert/convert.ts | 2 +- test/runtime/value/convert/bigint.ts | 8 ++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/changelog/0.33.0.md b/changelog/0.33.0.md index b098d7e99..74913d5ec 100644 --- a/changelog/0.33.0.md +++ b/changelog/0.33.0.md @@ -1,4 +1,10 @@ ### 0.33.0 +- [Revision 0.33.12](https://github.com/sinclairzx81/typebox/pull/999) + - [998](https://github.com/sinclairzx81/typebox/issues/998) Avoid losing precision when converting to bigints +- [Revision 0.33.11](https://github.com/sinclairzx81/typebox/pull/994) + - [993](https://github.com/sinclairzx81/typebox/issues/993) Prevent mutation on union values during Convert +- [Revision 0.33.10](https://github.com/sinclairzx81/typebox/pull/991) + - [907](https://github.com/sinclairzx81/typebox/issues/907) Add package.json metadata to specify possible side effect modules - [Revision 0.33.9](https://github.com/sinclairzx81/typebox/pull/984) - [887](https://github.com/sinclairzx81/typebox/issues/887) Generate Nested Intersect Errors - [Revision 0.33.8](https://github.com/sinclairzx81/typebox/pull/983) diff --git a/package-lock.json b/package-lock.json index f084fe304..7ee28d5b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sinclair/typebox", - "version": "0.33.11", + "version": "0.33.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@sinclair/typebox", - "version": "0.33.11", + "version": "0.33.12", "license": "MIT", "devDependencies": { "@arethetypeswrong/cli": "^0.13.2", diff --git a/package.json b/package.json index 420747da9..062077bbc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sinclair/typebox", - "version": "0.33.11", + "version": "0.33.12", "description": "Json Schema Type Builder with Static Type Resolution for TypeScript", "keywords": [ "typescript", diff --git a/src/value/convert/convert.ts b/src/value/convert/convert.ts index cddb0cf22..46dae1b3f 100644 --- a/src/value/convert/convert.ts +++ b/src/value/convert/convert.ts @@ -119,7 +119,7 @@ function TryConvertBoolean(value: unknown) { return IsValueTrue(value) ? true : IsValueFalse(value) ? false : value } function TryConvertBigInt(value: unknown) { - const truncateInteger = (value: string) => value.split('.')[0]; + const truncateInteger = (value: string) => value.split('.')[0] return IsStringNumeric(value) ? BigInt(truncateInteger(value)) : IsNumber(value) ? BigInt(value | 0) : IsValueFalse(value) ? BigInt(0) : IsValueTrue(value) ? BigInt(1) : value } function TryConvertString(value: unknown) { diff --git a/test/runtime/value/convert/bigint.ts b/test/runtime/value/convert/bigint.ts index 350e7a1f4..383e692a6 100644 --- a/test/runtime/value/convert/bigint.ts +++ b/test/runtime/value/convert/bigint.ts @@ -26,22 +26,22 @@ describe('value/convert/BigInt', () => { it('Should convert bigint from string 5', () => { const T = Type.BigInt() const R = Value.Convert(T, '12345678901234567890') - Assert.IsEqual(R, BigInt("12345678901234567890")) + Assert.IsEqual(R, BigInt('12345678901234567890')) }) it('Should convert bigint from string 6', () => { const T = Type.BigInt() const R = Value.Convert(T, '-12345678901234567890') - Assert.IsEqual(R, BigInt("-12345678901234567890")) + Assert.IsEqual(R, BigInt('-12345678901234567890')) }) it('Should convert bigint from string 7', () => { const T = Type.BigInt() const R = Value.Convert(T, '12345678901234567890.123') - Assert.IsEqual(R, BigInt("12345678901234567890")) + Assert.IsEqual(R, BigInt('12345678901234567890')) }) it('Should convert bigint from string 8', () => { const T = Type.BigInt() const R = Value.Convert(T, '-12345678901234567890.123') - Assert.IsEqual(R, BigInt("-12345678901234567890")) + Assert.IsEqual(R, BigInt('-12345678901234567890')) }) it('Should convert bitint from number 1', () => { const T = Type.BigInt()