@sinclair/typebox
Advanced tools
Comparing version 0.34.12 to 0.34.13
@@ -14,16 +14,29 @@ import type { TSchema, SchemaOptions } from '../schema/index'; | ||
/** | ||
* @deprecated `[Json]` Creates a Ref type. The referenced type MUST contain a $id. The Ref(TSchema) signature was | ||
* deprecated on 0.34.0 in support of a new type referencing model (Module). Existing implementations using Ref(TSchema) | ||
* can migrate using the following. The Ref(TSchema) validation behavior of Ref will be preserved how the construction | ||
* of legacy Ref(TSchema) will require wrapping in TUnsafe (where TUnsafe is used for inference only) | ||
* @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass | ||
* a `string` value for the reference (and not a schema). | ||
* | ||
* To adhere to the 0.34.0 signature, Ref implementations should be updated to the following. | ||
* | ||
* ```typescript | ||
* // pre-0.34.0 | ||
* | ||
* const T = Type.String({ $id: 'T' }) | ||
* | ||
* const R = Type.Ref(T) | ||
* ``` | ||
* to | ||
* should be changed to the following | ||
* | ||
* ```typescript | ||
* const R = Type.Unsafe<Static<T>>(T.$id) | ||
* // post-0.34.0 | ||
* | ||
* const T = Type.String({ $id: 'T' }) | ||
* | ||
* const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T')) | ||
* ``` | ||
* You can also create a generic function to replicate the pre-0.34.0 signature if required | ||
* | ||
* ```typescript | ||
* const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!)) | ||
* ``` | ||
*/ | ||
export declare function Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>; |
@@ -154,15 +154,28 @@ import { type TAny } from '../any/index'; | ||
/** | ||
* @deprecated `[Json]` Creates a Ref type. The referenced type MUST contain a $id. The Ref(TSchema) signature was | ||
* deprecated on 0.34.0 in support of a new type referencing model (Module). Existing implementations using Ref(TSchema) | ||
* can migrate using the following. The Ref(TSchema) validation behavior of Ref will be preserved how the construction | ||
* of legacy Ref(TSchema) will require wrapping in TUnsafe (where TUnsafe is used for inference only) | ||
* @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass | ||
* a `string` value for the reference (and not a schema). | ||
* | ||
* To adhere to the 0.34.0 signature, Ref implementations should be updated to the following. | ||
* | ||
* ```typescript | ||
* // pre-0.34.0 | ||
* | ||
* const T = Type.String({ $id: 'T' }) | ||
* | ||
* const R = Type.Ref(T) | ||
* ``` | ||
* to | ||
* should be changed to the following | ||
* | ||
* ```typescript | ||
* const R = Type.Unsafe<Static<T>>(T.$id) | ||
* // post-0.34.0 | ||
* | ||
* const T = Type.String({ $id: 'T' }) | ||
* | ||
* const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T')) | ||
* ``` | ||
* You can also create a generic function to replicate the pre-0.34.0 signature if required | ||
* | ||
* ```typescript | ||
* const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!)) | ||
* ``` | ||
*/ | ||
@@ -169,0 +182,0 @@ Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>; |
@@ -73,3 +73,3 @@ "use strict"; | ||
function TryConvertString(value) { | ||
return IsValueToString(value) ? value.toString() : (0, index_5.IsSymbol)(value) && value.description !== undefined ? value.description.toString() : value; | ||
return (0, index_5.IsSymbol)(value) && value.description !== undefined ? value.description.toString() : IsValueToString(value) ? value.toString() : value; | ||
} | ||
@@ -76,0 +76,0 @@ function TryConvertNumber(value) { |
{ | ||
"name": "@sinclair/typebox", | ||
"version": "0.34.12", | ||
"version": "0.34.13", | ||
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1692966
28220