typebox 1.0.32 → 1.0.34
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/build/type/engine/object/from-intersect.d.mts +5 -2
- package/build/type/engine/object/from-intersect.mjs +8 -4
- package/build/type/script/mapping.d.mts +2 -2
- package/build/type/script/mapping.mjs +1 -1
- package/build/type/script/parser.d.mts +3 -3
- package/build/type/script/parser.mjs +2 -2
- package/build/type/types/object.d.mts +4 -1
- package/build/type/types/object.mjs +3 -1
- package/package.json +2 -2
|
@@ -2,11 +2,14 @@ import { Memory } from '../../../system/memory/index.mjs';
|
|
|
2
2
|
import { type TSchema } from '../../types/schema.mjs';
|
|
3
3
|
import { type TProperties } from '../../types/properties.mjs';
|
|
4
4
|
import { type TFromType } from './from-type.mjs';
|
|
5
|
-
|
|
5
|
+
import { type TEvaluateIntersect } from '../evaluate/evaluate.mjs';
|
|
6
|
+
type TCollapseIntersectProperties<Left extends TProperties, Right extends TProperties, LeftKeys extends keyof Left = Exclude<keyof Left, keyof Right>, RightKeys extends keyof Right = Exclude<keyof Right, keyof Left>, SharedKeys extends keyof Left & keyof Right = Extract<keyof Left, keyof Right>, LeftProperties extends TProperties = {
|
|
6
7
|
[Key in LeftKeys]: Left[Key];
|
|
7
8
|
}, RightProperties extends TProperties = {
|
|
8
9
|
[Key in RightKeys]: Right[Key];
|
|
9
|
-
},
|
|
10
|
+
}, SharedProperties extends TProperties = {
|
|
11
|
+
[Key in SharedKeys]: TEvaluateIntersect<[Left[Key], Right[Key]]>;
|
|
12
|
+
}, Unique extends TProperties = Memory.TAssign<LeftProperties, RightProperties>, Shared extends TProperties = Memory.TAssign<Unique, SharedProperties>> = Shared;
|
|
10
13
|
export type TFromIntersect<Types extends TSchema[], Result extends TProperties = {}> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromIntersect<Right, TCollapseIntersectProperties<Result, TFromType<Left>>> : {
|
|
11
14
|
[Key in keyof Result]: Result[Key];
|
|
12
15
|
});
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
3
|
import { Guard } from '../../../guard/index.mjs';
|
|
4
4
|
import { FromType } from './from-type.mjs';
|
|
5
|
+
import { EvaluateIntersect } from '../evaluate/evaluate.mjs';
|
|
5
6
|
function CollapseIntersectProperties(left, right) {
|
|
6
7
|
const leftKeys = Guard.Keys(left).filter((key) => !Guard.HasPropertyKey(right, key));
|
|
7
8
|
const rightKeys = Guard.Keys(right).filter((key) => !Guard.HasPropertyKey(left, key));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
const sharedKeys = Guard.Keys(left).filter((key) => Guard.HasPropertyKey(right, key));
|
|
10
|
+
const leftProperties = leftKeys.reduce((result, key) => ({ ...result, [key]: left[key] }), {});
|
|
11
|
+
const rightProperties = rightKeys.reduce((result, key) => ({ ...result, [key]: right[key] }), {});
|
|
12
|
+
const sharedProperties = sharedKeys.reduce((result, key) => ({ ...result, [key]: EvaluateIntersect([left[key], right[key]]) }), {});
|
|
13
|
+
const unique = Memory.Assign(leftProperties, rightProperties);
|
|
14
|
+
const shared = Memory.Assign(unique, sharedProperties);
|
|
15
|
+
return shared;
|
|
12
16
|
}
|
|
13
17
|
export function FromIntersect(types) {
|
|
14
18
|
return types.reduce((result, left) => {
|
|
@@ -222,8 +222,8 @@ type TPropertiesReduce<PropertiesList extends T.TProperties[], Result extends [p
|
|
|
222
222
|
});
|
|
223
223
|
export type TPropertiesMapping<Input extends [unknown, unknown, unknown], Result extends [T.TProperties, T.TProperties] = Input extends ['{', infer PropertyList extends T.TProperties[], '}'] ? TPropertiesReduce<PropertyList> : [{}, {}]> = Result;
|
|
224
224
|
export declare function PropertiesMapping(input: [unknown, unknown, unknown]): unknown;
|
|
225
|
-
export type
|
|
226
|
-
export declare function
|
|
225
|
+
export type T_Object_Mapping<Input extends unknown> = (Input extends [infer Properties extends T.TProperties, infer _PatternProperties extends T.TProperties] ? T.TObject<Properties> : never);
|
|
226
|
+
export declare function _Object_Mapping(input: unknown): unknown;
|
|
227
227
|
export type TElementNamedMapping<Input extends [unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown] | [unknown, unknown, unknown]> = (Input extends [string, '?', ':', 'readonly', infer Type extends T.TSchema] ? T.TReadonlyAdd<T.TOptionalAdd<Type>> : Input extends [string, /**/ ':', 'readonly', infer Type extends T.TSchema] ? T.TReadonlyAdd<Type> : Input extends [string, '?', ':', /* */ infer Type extends T.TSchema] ? T.TOptionalAdd<Type> : Input extends [string, /**/ ':', /* */ infer Type extends T.TSchema] ? Type : never);
|
|
228
228
|
export declare function ElementNamedMapping(input: [unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown] | [unknown, unknown, unknown]): unknown;
|
|
229
229
|
export type TElementReadonlyOptionalMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['readonly', infer Type extends T.TSchema, '?'] ? T.TReadonlyAdd<T.TOptionalAdd<Type>> : never);
|
|
@@ -303,7 +303,7 @@ function PropertiesReduce(propertyList) {
|
|
|
303
303
|
export function PropertiesMapping(input) {
|
|
304
304
|
return PropertiesReduce(input[1]);
|
|
305
305
|
}
|
|
306
|
-
export function
|
|
306
|
+
export function _Object_Mapping(input) {
|
|
307
307
|
const [properties, patternProperties] = input;
|
|
308
308
|
const options = Guard.IsEqual(Guard.Keys(patternProperties).length, 0) ? {} : { patternProperties };
|
|
309
309
|
return T.Object(properties, options);
|
|
@@ -41,7 +41,7 @@ export type TKeyOf<Input extends string> = ((Token.TConst<'keyof', Input> extend
|
|
|
41
41
|
export type TIndexArray_0<Input extends string, Result extends unknown[] = []> = ((Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0, infer Input extends string] ? TIndexArray_0<Input, [...Result, _0]> : [Result, Input];
|
|
42
42
|
export type TIndexArray<Input extends string> = TIndexArray_0<Input> extends [infer _0 extends ([unknown, unknown, unknown] | [unknown, unknown])[], infer Input extends string] ? [S.TIndexArrayMapping<_0>, Input] : [];
|
|
43
43
|
export type TExtends<Input extends string> = ((Token.TConst<'extends', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5], Input] : []) : []) : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExtendsMapping<_0>, Input] : [];
|
|
44
|
-
export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : TKeyword<Input> extends [infer _0, infer Input extends string] ? [_0, Input] :
|
|
44
|
+
export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : TKeyword<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Object_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTuple<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTemplateLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TConstructor<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TFunction<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TMapped<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TOptions<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericCall<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TReference<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | unknown, infer Input extends string] ? [S.TBaseMapping<_0>, Input] : [];
|
|
45
45
|
export type TFactor<Input extends string> = (TKeyOf<Input> extends [infer _0, infer Input extends string] ? (TBase<Input> extends [infer _1, infer Input extends string] ? (TIndexArray<Input> extends [infer _2, infer Input extends string] ? (TExtends<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TFactorMapping<_0>, Input] : [];
|
|
46
46
|
export type TExprTermTail<Input extends string> = ((Token.TConst<'&', Input> extends [infer _0, infer Input extends string] ? (TFactor<Input> extends [infer _1, infer Input extends string] ? (TExprTermTail<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExprTermTailMapping<_0>, Input] : [];
|
|
47
47
|
export type TExprTerm<Input extends string> = (TFactor<Input> extends [infer _0, infer Input extends string] ? (TExprTermTail<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TExprTermMapping<_0>, Input] : [];
|
|
@@ -63,7 +63,7 @@ export type TPropertyDelimiter<Input extends string> = ((Token.TConst<',', Input
|
|
|
63
63
|
export type TPropertyList_0<Input extends string, Result extends unknown[] = []> = (TProperty<Input> extends [infer _0, infer Input extends string] ? (TPropertyDelimiter<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TPropertyList_0<Input, [...Result, _0]> : [Result, Input];
|
|
64
64
|
export type TPropertyList<Input extends string> = (TPropertyList_0<Input> extends [infer _0, infer Input extends string] ? (((TProperty<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TPropertyListMapping<_0>, Input] : [];
|
|
65
65
|
export type TProperties<Input extends string> = (Token.TConst<'{', Input> extends [infer _0, infer Input extends string] ? (TPropertyList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'}', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TPropertiesMapping<_0>, Input] : [];
|
|
66
|
-
export type
|
|
66
|
+
export type T_Object_<Input extends string> = TProperties<Input> extends [infer _0 extends unknown, infer Input extends string] ? [S.T_Object_Mapping<_0>, Input] : [];
|
|
67
67
|
export type TElementNamed<Input extends string> = ((Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _2, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _3, infer Input extends string] ? (TType<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (TType<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown] | [unknown, unknown, unknown], infer Input extends string] ? [S.TElementNamedMapping<_0>, Input] : [];
|
|
68
68
|
export type TElementReadonlyOptional<Input extends string> = (Token.TConst<'readonly', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TElementReadonlyOptionalMapping<_0>, Input] : [];
|
|
69
69
|
export type TElementReadonly<Input extends string> = (Token.TConst<'readonly', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TElementReadonlyMapping<_0>, Input] : [];
|
|
@@ -190,7 +190,7 @@ export declare const PropertyDelimiter: (input: string) => [unknown, string] | [
|
|
|
190
190
|
export declare const PropertyList_0: (input: string, result?: unknown[]) => [unknown[], string];
|
|
191
191
|
export declare const PropertyList: (input: string) => [unknown, string] | [];
|
|
192
192
|
export declare const Properties: (input: string) => [unknown, string] | [];
|
|
193
|
-
export declare const
|
|
193
|
+
export declare const _Object_: (input: string) => [unknown, string] | [];
|
|
194
194
|
export declare const ElementNamed: (input: string) => [unknown, string] | [];
|
|
195
195
|
export declare const ElementReadonlyOptional: (input: string) => [unknown, string] | [];
|
|
196
196
|
export declare const ElementReadonly: (input: string) => [unknown, string] | [];
|
|
@@ -44,7 +44,7 @@ export const KeyOf = (input) => If(If(If(Token.Const('keyof', input), ([_0, inpu
|
|
|
44
44
|
export const IndexArray_0 = (input, result = []) => If(If(If(Token.Const('[', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(If(Token.Const('[', input), ([_0, input]) => If(Token.Const(']', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => IndexArray_0(input, [...result, _0]), () => [result, input]);
|
|
45
45
|
export const IndexArray = (input) => If(IndexArray_0(input), ([_0, input]) => [S.IndexArrayMapping(_0), input]);
|
|
46
46
|
export const Extends = (input) => If(If(If(Token.Const('extends', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('?', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const(':', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExtendsMapping(_0), input]);
|
|
47
|
-
export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(Keyword(input), ([_0, input]) => [_0, input], () => If(
|
|
47
|
+
export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(Keyword(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(Tuple(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral(input), ([_0, input]) => [_0, input], () => If(Literal(input), ([_0, input]) => [_0, input], () => If(Constructor(input), ([_0, input]) => [_0, input], () => If(Function(input), ([_0, input]) => [_0, input], () => If(Mapped(input), ([_0, input]) => [_0, input], () => If(Options(input), ([_0, input]) => [_0, input], () => If(GenericCall(input), ([_0, input]) => [_0, input], () => If(Reference(input), ([_0, input]) => [_0, input], () => [])))))))))))), ([_0, input]) => [S.BaseMapping(_0), input]);
|
|
48
48
|
export const Factor = (input) => If(If(KeyOf(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [S.FactorMapping(_0), input]);
|
|
49
49
|
export const ExprTermTail = (input) => If(If(If(Token.Const('&', input), ([_0, input]) => If(Factor(input), ([_1, input]) => If(ExprTermTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTermTailMapping(_0), input]);
|
|
50
50
|
export const ExprTerm = (input) => If(If(Factor(input), ([_0, input]) => If(ExprTermTail(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ExprTermMapping(_0), input]);
|
|
@@ -66,7 +66,7 @@ export const PropertyDelimiter = (input) => If(If(If(Token.Const(',', input), ([
|
|
|
66
66
|
export const PropertyList_0 = (input, result = []) => If(If(Property(input), ([_0, input]) => If(PropertyDelimiter(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => PropertyList_0(input, [...result, _0]), () => [result, input]);
|
|
67
67
|
export const PropertyList = (input) => If(If(PropertyList_0(input), ([_0, input]) => If(If(If(Property(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.PropertyListMapping(_0), input]);
|
|
68
68
|
export const Properties = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(PropertyList(input), ([_1, input]) => If(Token.Const('}', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.PropertiesMapping(_0), input]);
|
|
69
|
-
export const
|
|
69
|
+
export const _Object_ = (input) => If(Properties(input), ([_0, input]) => [S._Object_Mapping(_0), input]);
|
|
70
70
|
export const ElementNamed = (input) => If(If(If(Token.Ident(input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => If(Token.Const(':', input), ([_2, input]) => If(Token.Const('readonly', input), ([_3, input]) => If(Type(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [_0, input], () => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Token.Const('readonly', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => If(Token.Const(':', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Type(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.ElementNamedMapping(_0), input]);
|
|
71
71
|
export const ElementReadonlyOptional = (input) => If(If(Token.Const('readonly', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('?', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.ElementReadonlyOptionalMapping(_0), input]);
|
|
72
72
|
export const ElementReadonly = (input) => If(If(Token.Const('readonly', input), ([_0, input]) => If(Type(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ElementReadonlyMapping(_0), input]);
|
|
@@ -10,8 +10,11 @@ export interface TObject<Properties extends TProperties = TProperties> extends T
|
|
|
10
10
|
required: TRequiredArray<Properties>;
|
|
11
11
|
}
|
|
12
12
|
/** Creates an Object type. */
|
|
13
|
-
|
|
13
|
+
declare function _Object_<Properties extends TProperties>(properties: Properties, options?: TObjectOptions): TObject<Properties>;
|
|
14
|
+
/** `[Json]` Creates an Object type */
|
|
15
|
+
export declare var Object: typeof _Object_;
|
|
14
16
|
/** Returns true if the given value is TObject. */
|
|
15
17
|
export declare function IsObject(value: unknown): value is TObject;
|
|
16
18
|
/** Extracts options from a TObject. */
|
|
17
19
|
export declare function ObjectOptions(type: TObject): TObjectOptions;
|
|
20
|
+
export {};
|
|
@@ -6,11 +6,13 @@ import { RequiredArray } from './properties.mjs';
|
|
|
6
6
|
// Factory
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
/** Creates an Object type. */
|
|
9
|
-
|
|
9
|
+
function _Object_(properties, options = {}) {
|
|
10
10
|
const requiredKeys = RequiredArray(properties);
|
|
11
11
|
const required = requiredKeys.length > 0 ? { required: requiredKeys } : {};
|
|
12
12
|
return Memory.Create({ '~kind': 'Object' }, { type: 'object', ...required, properties }, options);
|
|
13
13
|
}
|
|
14
|
+
/** `[Json]` Creates an Object type */
|
|
15
|
+
export var Object = _Object_; // Required for CommonJS ES Interop
|
|
14
16
|
// ------------------------------------------------------------------
|
|
15
17
|
// Guard
|
|
16
18
|
// ------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typebox",
|
|
3
3
|
"description": "A Runtime Type System for JavaScript",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.34",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
7
7
|
"jsonschema"
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"./build/compile/index.d.mts"
|
|
81
81
|
],
|
|
82
82
|
".": [
|
|
83
|
-
"./build
|
|
83
|
+
"./build/index.d.mts"
|
|
84
84
|
]
|
|
85
85
|
}
|
|
86
86
|
}
|