@sinclair/typebox 0.27.6 → 0.27.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/typebox.d.ts +6 -5
- package/typebox.js +1 -1
package/package.json
CHANGED
package/typebox.d.ts
CHANGED
|
@@ -183,7 +183,7 @@ export type TKeyOfTuple<T extends TSchema> = {
|
|
|
183
183
|
} extends infer U ? UnionToTuple<Exclude<{
|
|
184
184
|
[K in keyof U]: U[K];
|
|
185
185
|
}[keyof U], undefined>> : never;
|
|
186
|
-
export type TKeyOf<T extends TSchema = TSchema> = (T extends
|
|
186
|
+
export type TKeyOf<T extends TSchema = TSchema> = (T extends TRecursive<infer S> ? TKeyOfTuple<S> : T extends TComposite ? TKeyOfTuple<T> : T extends TIntersect ? TKeyOfTuple<T> : T extends TUnion ? TKeyOfTuple<T> : T extends TObject ? TKeyOfTuple<T> : T extends TRecord<infer K> ? [K] : [
|
|
187
187
|
]) extends infer R ? TUnionResult<Assert<R, TSchema[]>> : never;
|
|
188
188
|
export type TLiteralValue = string | number | boolean;
|
|
189
189
|
export interface TLiteral<T extends TLiteralValue = TLiteralValue> extends TSchema {
|
|
@@ -248,7 +248,7 @@ export type TOmitArray<T extends TSchema[], K extends keyof any> = Assert<{
|
|
|
248
248
|
[K2 in keyof T]: TOmit<Assert<T[K2], TSchema>, K>;
|
|
249
249
|
}, TSchema[]>;
|
|
250
250
|
export type TOmitProperties<T extends TProperties, K extends keyof any> = Evaluate<Assert<Omit<T, K>, TProperties>>;
|
|
251
|
-
export type TOmit<T extends TSchema = TSchema, K extends keyof any = keyof any> = T extends TComposite<infer S> ? TComposite<TOmitArray<S, K>> : T extends TIntersect<infer S> ? TIntersect<TOmitArray<S, K>> : T extends TUnion<infer S> ? TUnion<TOmitArray<S, K>> : T extends TObject<infer S> ? TObject<TOmitProperties<S, K>> : T;
|
|
251
|
+
export type TOmit<T extends TSchema = TSchema, K extends keyof any = keyof any> = T extends TRecursive<infer S> ? TRecursive<TOmit<S, K>> : T extends TComposite<infer S> ? TComposite<TOmitArray<S, K>> : T extends TIntersect<infer S> ? TIntersect<TOmitArray<S, K>> : T extends TUnion<infer S> ? TUnion<TOmitArray<S, K>> : T extends TObject<infer S> ? TObject<TOmitProperties<S, K>> : T;
|
|
252
252
|
export type TParameters<T extends TFunction> = TTuple<T['parameters']>;
|
|
253
253
|
export type TPartialObjectArray<T extends TObject[]> = Assert<{
|
|
254
254
|
[K in keyof T]: TPartial<Assert<T[K], TObject>>;
|
|
@@ -259,14 +259,14 @@ export type TPartialArray<T extends TSchema[]> = Assert<{
|
|
|
259
259
|
export type TPartialProperties<T extends TProperties> = Evaluate<Assert<{
|
|
260
260
|
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonlyOptional<U> : T[K] extends TReadonly<infer U> ? TReadonlyOptional<U> : T[K] extends TOptional<infer U> ? TOptional<U> : TOptional<T[K]>;
|
|
261
261
|
}, TProperties>>;
|
|
262
|
-
export type TPartial<T extends TSchema> = T extends TComposite<infer S> ? TComposite<TPartialArray<S>> : T extends TIntersect<infer S> ? TIntersect<TPartialArray<S>> : T extends TUnion<infer S> ? TUnion<TPartialArray<S>> : T extends TObject<infer S> ? TObject<TPartialProperties<S>> : T;
|
|
262
|
+
export type TPartial<T extends TSchema> = T extends TRecursive<infer S> ? TRecursive<TPartial<S>> : T extends TComposite<infer S> ? TComposite<TPartialArray<S>> : T extends TIntersect<infer S> ? TIntersect<TPartialArray<S>> : T extends TUnion<infer S> ? TUnion<TPartialArray<S>> : T extends TObject<infer S> ? TObject<TPartialProperties<S>> : T;
|
|
263
263
|
export type TPickArray<T extends TSchema[], K extends keyof any> = {
|
|
264
264
|
[K2 in keyof T]: TPick<Assert<T[K2], TSchema>, K>;
|
|
265
265
|
};
|
|
266
266
|
export type TPickProperties<T extends TProperties, K extends keyof any> = Pick<T, Assert<Extract<K, keyof T>, keyof T>> extends infer R ? ({
|
|
267
267
|
[K in keyof R]: Assert<R[K], TSchema> extends TSchema ? R[K] : never;
|
|
268
268
|
}) : never;
|
|
269
|
-
export type TPick<T extends TSchema = TSchema, K extends keyof any = keyof any> = T extends TComposite<infer S> ? TComposite<TPickArray<S, K>> : T extends TIntersect<infer S> ? TIntersect<TPickArray<S, K>> : T extends TUnion<infer S> ? TUnion<TPickArray<S, K>> : T extends TObject<infer S> ? TObject<TPickProperties<S, K>> : T;
|
|
269
|
+
export type TPick<T extends TSchema = TSchema, K extends keyof any = keyof any> = T extends TRecursive<infer S> ? TRecursive<TPick<S, K>> : T extends TComposite<infer S> ? TComposite<TPickArray<S, K>> : T extends TIntersect<infer S> ? TIntersect<TPickArray<S, K>> : T extends TUnion<infer S> ? TUnion<TPickArray<S, K>> : T extends TObject<infer S> ? TObject<TPickProperties<S, K>> : T;
|
|
270
270
|
export interface TPromise<T extends TSchema = TSchema> extends TSchema {
|
|
271
271
|
[Kind]: 'Promise';
|
|
272
272
|
static: Promise<Static<T, this['params']>>;
|
|
@@ -303,6 +303,7 @@ export interface TThis extends TSchema {
|
|
|
303
303
|
}
|
|
304
304
|
export type TRecursiveReduce<T extends TSchema> = Static<T, [TRecursiveReduce<T>]>;
|
|
305
305
|
export interface TRecursive<T extends TSchema> extends TSchema {
|
|
306
|
+
[Hint]: 'Recursive';
|
|
306
307
|
static: TRecursiveReduce<T>;
|
|
307
308
|
}
|
|
308
309
|
export interface TRef<T extends TSchema = TSchema> extends TSchema {
|
|
@@ -317,7 +318,7 @@ export type TRequiredArray<T extends TSchema[]> = Assert<{
|
|
|
317
318
|
export type TRequiredProperties<T extends TProperties> = Evaluate<Assert<{
|
|
318
319
|
[K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonly<U> : T[K] extends TReadonly<infer U> ? TReadonly<U> : T[K] extends TOptional<infer U> ? U : T[K];
|
|
319
320
|
}, TProperties>>;
|
|
320
|
-
export type TRequired<T extends TSchema> = T extends TComposite<infer S> ? TComposite<TRequiredArray<S>> : T extends TIntersect<infer S> ? TIntersect<TRequiredArray<S>> : T extends TUnion<infer S> ? TUnion<TRequiredArray<S>> : T extends TObject<infer S> ? TObject<TRequiredProperties<S>> : T;
|
|
321
|
+
export type TRequired<T extends TSchema> = T extends TRecursive<infer S> ? TRecursive<TRequired<S>> : T extends TComposite<infer S> ? TComposite<TRequiredArray<S>> : T extends TIntersect<infer S> ? TIntersect<TRequiredArray<S>> : T extends TUnion<infer S> ? TUnion<TRequiredArray<S>> : T extends TObject<infer S> ? TObject<TRequiredProperties<S>> : T;
|
|
321
322
|
export type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex';
|
|
322
323
|
export interface StringOptions<Format extends string> extends SchemaOptions {
|
|
323
324
|
minLength?: number;
|
package/typebox.js
CHANGED
|
@@ -2049,7 +2049,7 @@ class StandardTypeBuilder extends TypeBuilder {
|
|
|
2049
2049
|
options.$id = `T${TypeOrdinal++}`;
|
|
2050
2050
|
const thisType = callback({ [exports.Kind]: 'This', $ref: `${options.$id}` });
|
|
2051
2051
|
thisType.$id = options.$id;
|
|
2052
|
-
return this.Create({ ...options, ...thisType });
|
|
2052
|
+
return this.Create({ ...options, [exports.Hint]: 'Recursive', ...thisType });
|
|
2053
2053
|
}
|
|
2054
2054
|
/** `[Standard]` Creates a Ref type. The referenced type must contain a $id */
|
|
2055
2055
|
Ref(schema, options = {}) {
|