@sinclair/typebox 0.32.0-dev-15 → 0.32.0-dev-16
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/import/index.d.mts +2 -2
- package/build/import/index.mjs +2 -2
- package/build/import/type/array/array.d.mts +1 -1
- package/build/import/type/constructor/constructor.d.mts +4 -4
- package/build/import/type/exclude/exclude.d.mts +3 -3
- package/build/import/type/extends/extends.mjs +1 -1
- package/build/import/type/extract/extract.d.mts +3 -3
- package/build/import/type/function/function.d.mts +4 -4
- package/build/import/type/indexed/indexed-result.d.mts +6 -6
- package/build/import/type/indexed/indexed-result.mjs +7 -7
- package/build/import/type/indexed/indexed.mjs +1 -1
- package/build/import/type/intersect/index.d.mts +2 -0
- package/build/import/type/intersect/index.mjs +2 -0
- package/build/import/type/intersect/intersect-create.d.mts +3 -0
- package/build/import/type/intersect/intersect-create.mjs +12 -0
- package/build/import/type/intersect/intersect-evaluated.d.mts +16 -0
- package/build/import/type/intersect/intersect-evaluated.mjs +35 -0
- package/build/import/type/intersect/intersect-type.d.mts +15 -0
- package/build/import/type/intersect/intersect-type.mjs +1 -0
- package/build/import/type/intersect/intersect.d.mts +4 -20
- package/build/import/type/intersect/intersect.mjs +5 -17
- package/build/import/type/keyof/keyof.d.mts +2 -2
- package/build/import/type/keyof/keyof.mjs +2 -2
- package/build/import/type/mapped/mapped.mjs +1 -2
- package/build/import/type/object/object.d.mts +5 -5
- package/build/import/type/record/record.d.mts +0 -1
- package/build/import/type/record/record.mjs +1 -1
- package/build/import/type/recursive/recursive.d.mts +3 -2
- package/build/import/type/recursive/recursive.mjs +1 -5
- package/build/import/type/template-literal/syntax.d.mts +4 -4
- package/build/import/type/template-literal/template-literal.d.mts +4 -4
- package/build/import/type/transform/transform.d.mts +3 -2
- package/build/import/type/transform/transform.mjs +1 -1
- package/build/import/type/tuple/tuple.d.mts +3 -3
- package/build/import/type/type/json.d.mts +4 -4
- package/build/import/type/union/index.d.mts +2 -0
- package/build/import/type/union/index.mjs +2 -0
- package/build/import/type/union/union-create.d.mts +3 -0
- package/build/import/type/union/union-create.mjs +5 -0
- package/build/import/type/union/union-evaluated.d.mts +16 -0
- package/build/import/type/union/union-evaluated.mjs +31 -0
- package/build/import/type/union/union-type.d.mts +12 -0
- package/build/import/type/union/union-type.mjs +1 -0
- package/build/import/type/union/union.d.mts +3 -13
- package/build/import/type/union/union.mjs +3 -10
- package/build/import/value/delta/delta.d.mts +1 -1
- package/build/require/index.d.ts +2 -2
- package/build/require/index.js +5 -2
- package/build/require/type/array/array.d.ts +1 -1
- package/build/require/type/constructor/constructor.d.ts +4 -4
- package/build/require/type/exclude/exclude.d.ts +3 -3
- package/build/require/type/extends/extends.js +5 -5
- package/build/require/type/extract/extract.d.ts +3 -3
- package/build/require/type/function/function.d.ts +4 -4
- package/build/require/type/indexed/indexed-result.d.ts +6 -6
- package/build/require/type/indexed/indexed-result.js +4 -4
- package/build/require/type/indexed/indexed.js +4 -4
- package/build/require/type/intersect/index.d.ts +2 -0
- package/build/require/type/intersect/index.js +2 -0
- package/build/require/type/intersect/intersect-create.d.ts +3 -0
- package/build/require/type/intersect/intersect-create.js +16 -0
- package/build/require/type/intersect/intersect-evaluated.d.ts +16 -0
- package/build/require/type/intersect/intersect-evaluated.js +39 -0
- package/build/require/type/intersect/intersect-type.d.ts +15 -0
- package/build/require/type/intersect/intersect-type.js +3 -0
- package/build/require/type/intersect/intersect.d.ts +4 -20
- package/build/require/type/intersect/intersect.js +5 -18
- package/build/require/type/keyof/keyof.d.ts +2 -2
- package/build/require/type/keyof/keyof.js +1 -1
- package/build/require/type/mapped/mapped.js +18 -19
- package/build/require/type/object/object.d.ts +5 -5
- package/build/require/type/record/record.d.ts +0 -1
- package/build/require/type/record/record.js +1 -2
- package/build/require/type/recursive/recursive.d.ts +3 -2
- package/build/require/type/recursive/recursive.js +1 -5
- package/build/require/type/template-literal/syntax.d.ts +4 -4
- package/build/require/type/template-literal/template-literal.d.ts +4 -4
- package/build/require/type/transform/transform.d.ts +3 -2
- package/build/require/type/transform/transform.js +4 -4
- package/build/require/type/tuple/tuple.d.ts +3 -3
- package/build/require/type/type/json.d.ts +4 -4
- package/build/require/type/union/index.d.ts +2 -0
- package/build/require/type/union/index.js +2 -0
- package/build/require/type/union/union-create.d.ts +3 -0
- package/build/require/type/union/union-create.js +9 -0
- package/build/require/type/union/union-evaluated.d.ts +16 -0
- package/build/require/type/union/union-evaluated.js +35 -0
- package/build/require/type/union/union-type.d.ts +12 -0
- package/build/require/type/union/union-type.js +3 -0
- package/build/require/type/union/union.d.ts +3 -13
- package/build/require/type/union/union.js +3 -11
- package/build/require/value/delta/delta.d.ts +1 -1
- package/package.json +1 -1
- package/readme.md +27 -19
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
2
|
import type { Static } from '../static/index.mjs';
|
|
3
3
|
import { Kind } from '../symbols/index.mjs';
|
|
4
|
-
type
|
|
5
|
-
type
|
|
4
|
+
type TupleStaticRest<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...TupleStaticRest<R, P>] : [];
|
|
5
|
+
type TupleStatic<T extends TSchema[], P extends unknown[], R extends unknown[] = TupleStaticRest<T, P>> = R;
|
|
6
6
|
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
7
7
|
[Kind]: 'Tuple';
|
|
8
|
-
static:
|
|
8
|
+
static: TupleStatic<T, this['params']>;
|
|
9
9
|
type: 'array';
|
|
10
10
|
items?: T;
|
|
11
11
|
additionalItems?: false;
|
|
@@ -10,7 +10,7 @@ import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResul
|
|
|
10
10
|
import { type TExtract, type TExtractFromMappedResult } from '../extract/index.mjs';
|
|
11
11
|
import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey } from '../indexed/index.mjs';
|
|
12
12
|
import { type IntegerOptions, type TInteger } from '../integer/index.mjs';
|
|
13
|
-
import {
|
|
13
|
+
import { Intersect, type IntersectOptions } from '../intersect/index.mjs';
|
|
14
14
|
import { type TCapitalize, type TUncapitalize, type TLowercase, type TUppercase } from '../intrinsic/index.mjs';
|
|
15
15
|
import { type TKeyOf, type TKeyOfFromMappedResult } from '../keyof/index.mjs';
|
|
16
16
|
import { type TLiteral, type TLiteralValue } from '../literal/index.mjs';
|
|
@@ -37,7 +37,7 @@ import { type TString, type StringOptions } from '../string/index.mjs';
|
|
|
37
37
|
import { type TTemplateLiteral, type TTemplateLiteralKind, type TemplateLiteralSyntax } from '../template-literal/index.mjs';
|
|
38
38
|
import { TransformDecodeBuilder } from '../transform/index.mjs';
|
|
39
39
|
import { type TTuple } from '../tuple/index.mjs';
|
|
40
|
-
import {
|
|
40
|
+
import { Union } from '../union/index.mjs';
|
|
41
41
|
import { type TUnknown } from '../unknown/index.mjs';
|
|
42
42
|
import { type TUnsafe, type UnsafeOptions } from '../unsafe/index.mjs';
|
|
43
43
|
export declare class JsonTypeBuilder {
|
|
@@ -64,7 +64,7 @@ export declare class JsonTypeBuilder {
|
|
|
64
64
|
Index<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TIndex<T, I>;
|
|
65
65
|
Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
|
|
66
66
|
Integer(options?: IntegerOptions): TInteger;
|
|
67
|
-
Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions):
|
|
67
|
+
Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): Intersect<T>;
|
|
68
68
|
KeyOf<T extends TMappedResult>(schema: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
|
|
69
69
|
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
70
70
|
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
@@ -97,7 +97,7 @@ export declare class JsonTypeBuilder {
|
|
|
97
97
|
Transform<I extends TSchema>(schema: I): TransformDecodeBuilder<I>;
|
|
98
98
|
Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
99
99
|
Uncapitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TUncapitalize<T>;
|
|
100
|
-
Union<T extends TSchema[]>(schemas: [...T], options?: SchemaOptions):
|
|
100
|
+
Union<T extends TSchema[]>(schemas: [...T], options?: SchemaOptions): Union<T>;
|
|
101
101
|
Unknown(options?: SchemaOptions): TUnknown;
|
|
102
102
|
Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
|
|
103
103
|
Uppercase<T extends TSchema>(schema: T, options?: SchemaOptions): TUppercase<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaOptions, TSchema } from '../schema/index.mjs';
|
|
2
|
+
import { type TNever } from '../never/index.mjs';
|
|
3
|
+
import { type TOptional } from '../optional/index.mjs';
|
|
4
|
+
import type { TReadonly } from '../readonly/index.mjs';
|
|
5
|
+
import type { TUnion } from './union-type.mjs';
|
|
6
|
+
type IsUnionOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : IsUnionOptional<R> : false);
|
|
7
|
+
declare function IsUnionOptional<T extends TSchema[]>(T: T): IsUnionOptional<T>;
|
|
8
|
+
type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromType<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
|
|
9
|
+
declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
|
|
10
|
+
type RemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromType<S> : T);
|
|
11
|
+
declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
|
|
12
|
+
type ResolveUnion<T extends TSchema[], R extends TSchema[] = RemoveOptionalFromRest<T>> = (IsUnionOptional<T> extends true ? TOptional<TUnion<R>> : TUnion<R>);
|
|
13
|
+
declare function ResolveUnion<T extends TSchema[]>(T: T, options: SchemaOptions): ResolveUnion<T>;
|
|
14
|
+
export type UnionEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveUnion<T>);
|
|
15
|
+
export declare function UnionEvaluated<T extends TSchema[], R = UnionEvaluated<T>>(T: [...T], options?: SchemaOptions): R;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OptionalKind } from '../symbols/index.mjs';
|
|
2
|
+
import { CloneType } from '../clone/type.mjs';
|
|
3
|
+
import { Discard } from '../discard/index.mjs';
|
|
4
|
+
import { Never } from '../never/index.mjs';
|
|
5
|
+
import { Optional } from '../optional/index.mjs';
|
|
6
|
+
import { UnionCreate } from './union-create.mjs';
|
|
7
|
+
import { TOptional as IsOptionalType } from '../guard/type.mjs';
|
|
8
|
+
function IsUnionOptional(T) {
|
|
9
|
+
const [L, ...R] = T;
|
|
10
|
+
return (T.length > 0
|
|
11
|
+
? IsOptionalType(L)
|
|
12
|
+
? true
|
|
13
|
+
: IsUnionOptional(R)
|
|
14
|
+
: false);
|
|
15
|
+
}
|
|
16
|
+
function RemoveOptionalFromRest(T) {
|
|
17
|
+
return (T.map(T => RemoveOptionalFromType(T)));
|
|
18
|
+
}
|
|
19
|
+
function RemoveOptionalFromType(T) {
|
|
20
|
+
return (Discard(T, [OptionalKind]));
|
|
21
|
+
}
|
|
22
|
+
function ResolveUnion(T, options) {
|
|
23
|
+
return (IsUnionOptional(T)
|
|
24
|
+
? Optional(UnionCreate(RemoveOptionalFromRest(T), options))
|
|
25
|
+
: UnionCreate(RemoveOptionalFromRest(T), options));
|
|
26
|
+
}
|
|
27
|
+
export function UnionEvaluated(T, options = {}) {
|
|
28
|
+
return (T.length === 0 ? Never(options) :
|
|
29
|
+
T.length === 1 ? CloneType(T[0], options) :
|
|
30
|
+
ResolveUnion(T, options));
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
+
import type { Static } from '../static/index.mjs';
|
|
3
|
+
import { Kind } from '../symbols/index.mjs';
|
|
4
|
+
type UnionStatic<T extends TSchema[], P extends unknown[]> = {
|
|
5
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
|
|
6
|
+
}[number];
|
|
7
|
+
export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
8
|
+
[Kind]: 'Union';
|
|
9
|
+
static: UnionStatic<T, this['params']>;
|
|
10
|
+
anyOf: T;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Kind } from '../symbols/index.mjs';
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
|
-
import type { Static } from '../static/index.mjs';
|
|
3
2
|
import { type TNever } from '../never/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export declare function UnionResolve<T extends TSchema[]>(T: [...T]): UnionResolve<T>;
|
|
8
|
-
export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
9
|
-
[Kind]: 'Union';
|
|
10
|
-
static: {
|
|
11
|
-
[K in keyof T]: T[K] extends TSchema ? Static<T[K], this['params']> : never;
|
|
12
|
-
}[number];
|
|
13
|
-
anyOf: T;
|
|
14
|
-
}
|
|
15
|
-
export declare function Union<T extends TSchema[]>(T: [...T], options?: SchemaOptions): UnionResolve<T>;
|
|
3
|
+
import type { TUnion } from './union-type.mjs';
|
|
4
|
+
export type Union<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TUnion<T>);
|
|
5
|
+
export declare function Union<T extends TSchema[]>(T: [...T], options?: SchemaOptions): Union<T>;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { Never } from '../never/index.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Kind } from '../symbols/index.mjs';
|
|
5
|
-
export function UnionResolve(T) {
|
|
6
|
-
return (T.length === 0 ? Never() :
|
|
7
|
-
T.length === 1 ? T[0] :
|
|
8
|
-
OptionalFromUnion(T));
|
|
9
|
-
}
|
|
2
|
+
import { CloneType } from '../clone/type.mjs';
|
|
3
|
+
import { UnionCreate } from './union-create.mjs';
|
|
10
4
|
export function Union(T, options = {}) {
|
|
11
5
|
return (T.length === 0 ? Never(options) :
|
|
12
6
|
T.length === 1 ? CloneType(T[0], options) :
|
|
13
|
-
|
|
14
|
-
});
|
|
7
|
+
UnionCreate(T, options));
|
|
15
8
|
}
|
|
@@ -17,7 +17,7 @@ export declare const Delete: import("../../type/object/object.mjs").TObject<{
|
|
|
17
17
|
path: import("../../type/string/string.mjs").TString;
|
|
18
18
|
}>;
|
|
19
19
|
export type Edit = Static<typeof Edit>;
|
|
20
|
-
export declare const Edit: import("../../type/union/union.mjs").TUnion<[import("../../type/object/object.mjs").TObject<{
|
|
20
|
+
export declare const Edit: import("../../type/union/union-type.mjs").TUnion<[import("../../type/object/object.mjs").TObject<{
|
|
21
21
|
type: import("../../type/literal/literal.mjs").TLiteral<"insert">;
|
|
22
22
|
path: import("../../type/string/string.mjs").TString;
|
|
23
23
|
value: import("../../type/unknown/unknown.mjs").TUnknown;
|
package/build/require/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { Increment, type Assert, type AssertType, type AssertRest, type AssertPr
|
|
|
24
24
|
export { Index, IndexPropertyKeys, IndexFromMappedKey, type TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey } from './type/indexed/index';
|
|
25
25
|
export { InstanceType, type TInstanceType } from './type/instance-type/index';
|
|
26
26
|
export { Integer, type TInteger, type IntegerOptions } from './type/integer/index';
|
|
27
|
-
export { Intersect, type TIntersect, type IntersectOptions } from './type/intersect/index';
|
|
27
|
+
export { Intersect, IntersectEvaluated, type TIntersect, type IntersectOptions } from './type/intersect/index';
|
|
28
28
|
export { Iterator, type TIterator } from './type/iterator/index';
|
|
29
29
|
export { Intrinsic, IntrinsicFromMappedKey, type TIntrinsic, Capitalize, type TCapitalize, Lowercase, type TLowercase, Uncapitalize, type TUncapitalize, Uppercase, type TUppercase } from './type/intrinsic/index';
|
|
30
30
|
export { KeyOf, type TKeyOf, type KeyOfFromMappedResult, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index';
|
|
@@ -60,7 +60,7 @@ export { Transform, type TTransform, type TransformOptions, type TransformFuncti
|
|
|
60
60
|
export { Tuple, type TTuple } from './type/tuple/index';
|
|
61
61
|
export { Uint8Array, type TUint8Array, type Uint8ArrayOptions } from './type/uint8array/index';
|
|
62
62
|
export { Undefined, type TUndefined } from './type/undefined/index';
|
|
63
|
-
export { Union, type TUnion } from './type/union/index';
|
|
63
|
+
export { Union, UnionEvaluated, type TUnion } from './type/union/index';
|
|
64
64
|
export { Unknown, type TUnknown } from './type/unknown/index';
|
|
65
65
|
export { Unsafe, type TUnsafe } from './type/unsafe/index';
|
|
66
66
|
export { Void, type TVoid } from './type/void/index';
|
package/build/require/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedKey = exports.IndexPropertyKeys = exports.Index = exports.Increment = exports.Function = exports.Extract = exports.ExtendsUndefinedCheck = exports.ExtendsResult = exports.ExtendsCheck = exports.Extends = exports.Exclude = exports.Enum = exports.Deref = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Any = exports.CloneRest = exports.CloneType = exports.ValueGuard = exports.TypeGuard = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternString = exports.PatternNumberExact = exports.PatternNumber = exports.PatternBooleanExact = exports.PatternBoolean = exports.TransformKind = exports.OptionalKind = exports.ReadonlyKind = exports.Hint = exports.Kind = void 0;
|
|
4
|
+
exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.UnionEvaluated = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.TemplateLiteralGenerate = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.IsTemplateLiteralFinite = exports.TemplateLiteral = exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = void 0;
|
|
5
|
+
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = void 0;
|
|
5
6
|
var index_1 = require("./type/symbols/index");
|
|
6
7
|
Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return index_1.Kind; } });
|
|
7
8
|
Object.defineProperty(exports, "Hint", { enumerable: true, get: function () { return index_1.Hint; } });
|
|
@@ -73,6 +74,7 @@ var index_25 = require("./type/integer/index");
|
|
|
73
74
|
Object.defineProperty(exports, "Integer", { enumerable: true, get: function () { return index_25.Integer; } });
|
|
74
75
|
var index_26 = require("./type/intersect/index");
|
|
75
76
|
Object.defineProperty(exports, "Intersect", { enumerable: true, get: function () { return index_26.Intersect; } });
|
|
77
|
+
Object.defineProperty(exports, "IntersectEvaluated", { enumerable: true, get: function () { return index_26.IntersectEvaluated; } });
|
|
76
78
|
var index_27 = require("./type/iterator/index");
|
|
77
79
|
Object.defineProperty(exports, "Iterator", { enumerable: true, get: function () { return index_27.Iterator; } });
|
|
78
80
|
var index_28 = require("./type/intrinsic/index");
|
|
@@ -157,6 +159,7 @@ var index_59 = require("./type/undefined/index");
|
|
|
157
159
|
Object.defineProperty(exports, "Undefined", { enumerable: true, get: function () { return index_59.Undefined; } });
|
|
158
160
|
var index_60 = require("./type/union/index");
|
|
159
161
|
Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return index_60.Union; } });
|
|
162
|
+
Object.defineProperty(exports, "UnionEvaluated", { enumerable: true, get: function () { return index_60.UnionEvaluated; } });
|
|
160
163
|
var index_61 = require("./type/unknown/index");
|
|
161
164
|
Object.defineProperty(exports, "Unknown", { enumerable: true, get: function () { return index_61.Unknown; } });
|
|
162
165
|
var index_62 = require("./type/unsafe/index");
|
|
@@ -11,7 +11,7 @@ export interface ArrayOptions extends SchemaOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
13
13
|
[Kind]: 'Array';
|
|
14
|
-
static: Static<T, this['params']
|
|
14
|
+
static: Array<Static<T, this['params']>>;
|
|
15
15
|
type: 'array';
|
|
16
16
|
items: T;
|
|
17
17
|
}
|
|
@@ -2,12 +2,12 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import type { Ensure } from '../helpers/index';
|
|
4
4
|
import { Kind } from '../symbols/index';
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
export type
|
|
5
|
+
type TConstructorStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
6
|
+
type TConstructorStaticParameters<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...TConstructorStaticParameters<R, P>] : [];
|
|
7
|
+
export type TConstructorStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<new (...param: TConstructorStaticParameters<T, P>) => TConstructorStaticReturnType<U, P>>);
|
|
8
8
|
export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
9
9
|
[Kind]: 'Constructor';
|
|
10
|
-
static:
|
|
10
|
+
static: TConstructorStatic<T, U, this['params']>;
|
|
11
11
|
type: 'Constructor';
|
|
12
12
|
parameters: T;
|
|
13
13
|
returns: U;
|
|
@@ -6,15 +6,15 @@ import { type TUnion } from '../union/index';
|
|
|
6
6
|
import { type TNever } from '../never/index';
|
|
7
7
|
import { type TLiteral } from '../literal/index';
|
|
8
8
|
import { type Static } from '../static/index';
|
|
9
|
-
import {
|
|
9
|
+
import { UnionEvaluated } from '../union/index';
|
|
10
10
|
import { type TExcludeFromMappedResult } from './exclude-from-mapped-result';
|
|
11
|
-
type ExcludeTemplateLiteralResult<T extends string> =
|
|
11
|
+
type ExcludeTemplateLiteralResult<T extends string> = UnionEvaluated<AssertRest<UnionToTuple<{
|
|
12
12
|
[K in T]: TLiteral<K>;
|
|
13
13
|
}[T]>>>;
|
|
14
14
|
type ExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (Exclude<Static<T>, Static<U>> extends infer S ? ExcludeTemplateLiteralResult<Assert<S, string>> : never);
|
|
15
15
|
type ExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
|
|
16
16
|
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K];
|
|
17
|
-
}[number]>> extends infer R extends TSchema[] ?
|
|
17
|
+
}[number]>> extends infer R extends TSchema[] ? UnionEvaluated<R> : never;
|
|
18
18
|
type ExcludeResolve<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? ExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? ExcludeArray<S, U> : T extends U ? TNever : T;
|
|
19
19
|
declare function ExcludeResolve<L extends TSchema, R extends TSchema>(L: L, R: R): ExcludeResolve<L, R>;
|
|
20
20
|
export type TExclude<T extends TSchema, U extends TSchema> = ExcludeResolve<T, U>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Extends = void 0;
|
|
4
|
-
const type_1 = require("../guard/type");
|
|
5
4
|
const index_1 = require("../union/index");
|
|
6
5
|
const extends_check_1 = require("./extends-check");
|
|
7
|
-
const
|
|
6
|
+
const type_1 = require("../clone/type");
|
|
8
7
|
const extends_from_mapped_key_1 = require("./extends-from-mapped-key");
|
|
9
8
|
const extends_from_mapped_result_1 = require("./extends-from-mapped-result");
|
|
9
|
+
const type_2 = require("../guard/type");
|
|
10
10
|
function ExtendsResolve(left, right, trueType, falseType) {
|
|
11
11
|
const R = (0, extends_check_1.ExtendsCheck)(left, right);
|
|
12
12
|
return (R === extends_check_1.ExtendsResult.Union ? (0, index_1.Union)([trueType, falseType]) :
|
|
@@ -14,8 +14,8 @@ function ExtendsResolve(left, right, trueType, falseType) {
|
|
|
14
14
|
falseType);
|
|
15
15
|
}
|
|
16
16
|
function Extends(L, R, T, F, options = {}) {
|
|
17
|
-
return ((0,
|
|
18
|
-
(0,
|
|
19
|
-
(0,
|
|
17
|
+
return ((0, type_2.TMappedResult)(L) ? (0, extends_from_mapped_result_1.ExtendsFromMappedResult)(L, R, T, F, options) :
|
|
18
|
+
(0, type_2.TMappedKey)(L) ? (0, type_1.CloneType)((0, extends_from_mapped_key_1.ExtendsFromMappedKey)(L, R, T, F, options)) :
|
|
19
|
+
(0, type_1.CloneType)(ExtendsResolve(L, R, T, F), options));
|
|
20
20
|
}
|
|
21
21
|
exports.Extends = Extends;
|
|
@@ -5,15 +5,15 @@ import { type TTemplateLiteral } from '../template-literal/index';
|
|
|
5
5
|
import { type TLiteral } from '../literal/index';
|
|
6
6
|
import { type TUnion } from '../union/index';
|
|
7
7
|
import { type Static } from '../static/index';
|
|
8
|
-
import {
|
|
8
|
+
import { UnionEvaluated } from '../union/index';
|
|
9
9
|
import { type TExtractFromMappedResult } from './extract-from-mapped-result';
|
|
10
|
-
type FromTemplateLiteralResult<T extends string> =
|
|
10
|
+
type FromTemplateLiteralResult<T extends string> = UnionEvaluated<AssertRest<UnionToTuple<{
|
|
11
11
|
[K in T]: TLiteral<K>;
|
|
12
12
|
}[T]>>>;
|
|
13
13
|
type FromTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extract<Static<T>, Static<U>> extends infer S ? FromTemplateLiteralResult<Assert<S, string>> : never;
|
|
14
14
|
type FromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
|
|
15
15
|
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? T[K] : never;
|
|
16
|
-
}[number]>> extends infer R extends TSchema[] ?
|
|
16
|
+
}[number]>> extends infer R extends TSchema[] ? UnionEvaluated<R> : never;
|
|
17
17
|
export type ExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? FromTemplateLiteral<T, U> : T extends TUnion<infer S> ? FromArray<S, U> : T extends U ? T : T);
|
|
18
18
|
export declare function ExtractResolve<L extends TSchema, R extends TSchema>(L: L, R: R): ExtractResolve<L, R>;
|
|
19
19
|
export type TExtract<T extends TSchema, U extends TSchema> = ExtractResolve<T, U>;
|
|
@@ -2,12 +2,12 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import type { Ensure } from '../helpers/index';
|
|
4
4
|
import { Kind } from '../symbols/index';
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
5
|
+
type FunctionStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
6
|
+
type FunctionStaticParameters<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...FunctionStaticParameters<R, P>] : [];
|
|
7
|
+
type FunctionStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<(...param: FunctionStaticParameters<T, P>) => FunctionStaticReturnType<U, P>>);
|
|
8
8
|
export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
9
9
|
[Kind]: 'Function';
|
|
10
|
-
static:
|
|
10
|
+
static: FunctionStatic<T, U, this['params']>;
|
|
11
11
|
type: 'Function';
|
|
12
12
|
parameters: T;
|
|
13
13
|
returns: U;
|
|
@@ -6,19 +6,19 @@ import { type TIntersect } from '../intersect/index';
|
|
|
6
6
|
import { type TUnion } from '../union/index';
|
|
7
7
|
import { type TTuple } from '../tuple/index';
|
|
8
8
|
import { type TArray } from '../array/index';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { IntersectEvaluated } from '../intersect/index';
|
|
10
|
+
import { UnionEvaluated } from '../union/index';
|
|
11
11
|
type FromRest<T extends TSchema[], K extends PropertyKey> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromKey<L, K>, ...FromRest<R, K>] : []);
|
|
12
12
|
declare function FromRest<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromRest<T, K>;
|
|
13
13
|
type FromIntersectRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [...FromIntersectRest<R>] : [L, ...FromIntersectRest<R>] : []);
|
|
14
14
|
declare function FromIntersectRest<T extends TSchema[]>(T: [...T]): FromIntersectRest<T>;
|
|
15
|
-
type FromIntersect<T extends TSchema[], K extends PropertyKey> = (
|
|
15
|
+
type FromIntersect<T extends TSchema[], K extends PropertyKey> = (IntersectEvaluated<FromIntersectRest<FromRest<T, K>>>);
|
|
16
16
|
declare function FromIntersect<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromIntersect<T, K>;
|
|
17
17
|
type FromUnionRest<T extends TSchema[], S = T> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [] : FromUnionRest<R, S> : S);
|
|
18
18
|
declare function FromUnionRest<T extends TSchema[]>(T: [...T], S?: [...T]): FromUnionRest<T>;
|
|
19
|
-
type FromUnion<T extends TSchema[], K extends PropertyKey> = (
|
|
19
|
+
type FromUnion<T extends TSchema[], K extends PropertyKey> = (UnionEvaluated<FromUnionRest<FromRest<T, K>>>);
|
|
20
20
|
declare function FromUnion<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromUnion<T, K>;
|
|
21
|
-
type FromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ?
|
|
21
|
+
type FromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? UnionEvaluated<T> : TNever);
|
|
22
22
|
declare function FromTuple<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromTuple<T, K>;
|
|
23
23
|
type FromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
|
|
24
24
|
declare function FromArray<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromArray<T, K>;
|
|
@@ -28,6 +28,6 @@ type FromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<i
|
|
|
28
28
|
declare function FromKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromKey<T, K>;
|
|
29
29
|
type FromKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? [FromKey<T, L>, ...FromKeys<T, R>] : []);
|
|
30
30
|
declare function FromKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromKeys<T, K>;
|
|
31
|
-
export type TIndexResult<T extends TSchema, K extends PropertyKey[]> = (
|
|
31
|
+
export type TIndexResult<T extends TSchema, K extends PropertyKey[]> = (UnionEvaluated<FromKeys<T, K>>);
|
|
32
32
|
export declare function IndexResult<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): TIndexResult<T, K>;
|
|
33
33
|
export {};
|
|
@@ -21,7 +21,7 @@ function FromIntersectRest(T) {
|
|
|
21
21
|
: []);
|
|
22
22
|
}
|
|
23
23
|
function FromIntersect(T, K) {
|
|
24
|
-
return ((0, index_2.
|
|
24
|
+
return ((0, index_2.IntersectEvaluated)(FromIntersectRest(FromRest(T, K))));
|
|
25
25
|
}
|
|
26
26
|
function FromUnionRest(T, S = T) {
|
|
27
27
|
const [L, ...R] = T;
|
|
@@ -32,11 +32,11 @@ function FromUnionRest(T, S = T) {
|
|
|
32
32
|
: S);
|
|
33
33
|
}
|
|
34
34
|
function FromUnion(T, K) {
|
|
35
|
-
return ((0, index_3.
|
|
35
|
+
return ((0, index_3.UnionEvaluated)(FromUnionRest(FromRest(T, K))));
|
|
36
36
|
}
|
|
37
37
|
function FromTuple(T, K) {
|
|
38
38
|
return (K in T ? T[K] :
|
|
39
|
-
K === '[number]' ? (0, index_3.
|
|
39
|
+
K === '[number]' ? (0, index_3.UnionEvaluated)(T) :
|
|
40
40
|
(0, index_1.Never)());
|
|
41
41
|
}
|
|
42
42
|
function FromArray(T, K) {
|
|
@@ -64,6 +64,6 @@ function FromKeys(T, K) {
|
|
|
64
64
|
: []);
|
|
65
65
|
}
|
|
66
66
|
function IndexResult(T, K, options) {
|
|
67
|
-
return ((0, type_1.CloneType)((0, index_3.
|
|
67
|
+
return ((0, type_1.CloneType)((0, index_3.UnionEvaluated)(FromKeys(T, K)), options));
|
|
68
68
|
}
|
|
69
69
|
exports.IndexResult = IndexResult;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Index = void 0;
|
|
4
|
-
const type_1 = require("../guard/type");
|
|
5
4
|
const indexed_result_1 = require("./indexed-result");
|
|
6
5
|
const indexed_property_keys_1 = require("./indexed-property-keys");
|
|
7
6
|
const indexed_from_mapped_key_1 = require("./indexed-from-mapped-key");
|
|
8
|
-
const
|
|
7
|
+
const type_1 = require("../clone/type");
|
|
8
|
+
const type_2 = require("../guard/type");
|
|
9
9
|
function Index(T, K, options = {}) {
|
|
10
|
-
return ((0,
|
|
11
|
-
(0,
|
|
10
|
+
return ((0, type_2.TMappedKey)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
|
|
11
|
+
(0, type_2.TSchema)(K) ? (0, indexed_result_1.IndexResult)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K), options) :
|
|
12
12
|
(0, indexed_result_1.IndexResult)(T, K, options));
|
|
13
13
|
}
|
|
14
14
|
exports.Index = Index;
|
|
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./intersect-evaluated"), exports);
|
|
18
|
+
__exportStar(require("./intersect-type"), exports);
|
|
17
19
|
__exportStar(require("./intersect"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectCreate = void 0;
|
|
4
|
+
const index_1 = require("../symbols/index");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
const type_2 = require("../guard/type");
|
|
7
|
+
function IntersectCreate(T, options) {
|
|
8
|
+
const allObjects = T.every((schema) => (0, type_2.TObject)(schema));
|
|
9
|
+
const clonedUnevaluatedProperties = (0, type_2.TSchema)(options.unevaluatedProperties)
|
|
10
|
+
? { unevaluatedProperties: (0, type_1.CloneType)(options.unevaluatedProperties) }
|
|
11
|
+
: {};
|
|
12
|
+
return ((options.unevaluatedProperties === false || (0, type_2.TSchema)(options.unevaluatedProperties) || allObjects
|
|
13
|
+
? { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', type: 'object', allOf: (0, type_1.CloneRest)(T) }
|
|
14
|
+
: { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', allOf: (0, type_1.CloneRest)(T) }));
|
|
15
|
+
}
|
|
16
|
+
exports.IntersectCreate = IntersectCreate;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaOptions, TSchema } from '../schema/index';
|
|
2
|
+
import { type TNever } from '../never/index';
|
|
3
|
+
import { type TOptional } from '../optional/index';
|
|
4
|
+
import type { TReadonly } from '../readonly/index';
|
|
5
|
+
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
6
|
+
type IsIntersectOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? IsIntersectOptional<R> : false : true);
|
|
7
|
+
declare function IsIntersectOptional<T extends TSchema[]>(T: T): IsIntersectOptional<T>;
|
|
8
|
+
type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromType<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
|
|
9
|
+
declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
|
|
10
|
+
type RemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromType<S> : T);
|
|
11
|
+
declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
|
|
12
|
+
type ResolveIntersect<T extends TSchema[]> = (IsIntersectOptional<T> extends true ? TOptional<TIntersect<RemoveOptionalFromRest<T>>> : TIntersect<RemoveOptionalFromRest<T>>);
|
|
13
|
+
declare function ResolveIntersect<T extends TSchema[]>(T: [...T], options: SchemaOptions): ResolveIntersect<T>;
|
|
14
|
+
export type IntersectEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveIntersect<T>);
|
|
15
|
+
export declare function IntersectEvaluated<T extends TSchema[], R = IntersectEvaluated<T>>(T: [...T], options?: IntersectOptions): R;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectEvaluated = void 0;
|
|
4
|
+
const index_1 = require("../symbols/index");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
const index_2 = require("../discard/index");
|
|
7
|
+
const index_3 = require("../never/index");
|
|
8
|
+
const index_4 = require("../optional/index");
|
|
9
|
+
const intersect_create_1 = require("./intersect-create");
|
|
10
|
+
const type_2 = require("../guard/type");
|
|
11
|
+
function IsIntersectOptional(T) {
|
|
12
|
+
const [L, ...R] = T;
|
|
13
|
+
return (T.length > 0
|
|
14
|
+
? (0, type_2.TOptional)(L)
|
|
15
|
+
? IsIntersectOptional(R)
|
|
16
|
+
: false
|
|
17
|
+
: true);
|
|
18
|
+
}
|
|
19
|
+
function RemoveOptionalFromRest(T) {
|
|
20
|
+
return (T.map(T => RemoveOptionalFromType(T)));
|
|
21
|
+
}
|
|
22
|
+
function RemoveOptionalFromType(T) {
|
|
23
|
+
return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
|
|
24
|
+
}
|
|
25
|
+
function ResolveIntersect(T, options) {
|
|
26
|
+
return (IsIntersectOptional(T)
|
|
27
|
+
? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(T), options))
|
|
28
|
+
: (0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(T), options));
|
|
29
|
+
}
|
|
30
|
+
function IntersectEvaluated(T, options = {}) {
|
|
31
|
+
if (T.length === 0)
|
|
32
|
+
return (0, index_3.Never)(options);
|
|
33
|
+
if (T.length === 1)
|
|
34
|
+
return (0, type_1.CloneType)(T[0], options);
|
|
35
|
+
if (T.some((schema) => (0, type_2.TTransform)(schema)))
|
|
36
|
+
throw new Error('Cannot intersect transform types');
|
|
37
|
+
return ResolveIntersect(T, options);
|
|
38
|
+
}
|
|
39
|
+
exports.IntersectEvaluated = IntersectEvaluated;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { Static } from '../static/index';
|
|
3
|
+
import { Kind } from '../symbols/index';
|
|
4
|
+
type IntersectStatic<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? Static<L, P> & IntersectStatic<R, P> : unknown;
|
|
5
|
+
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
6
|
+
export interface IntersectOptions extends SchemaOptions {
|
|
7
|
+
unevaluatedProperties?: TUnevaluatedProperties;
|
|
8
|
+
}
|
|
9
|
+
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
10
|
+
[Kind]: 'Intersect';
|
|
11
|
+
static: IntersectStatic<T, this['params']>;
|
|
12
|
+
type?: 'object';
|
|
13
|
+
allOf: [...T];
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
3
|
-
import type { Static } from '../static/index';
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
4
2
|
import { type TNever } from '../never/index';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export declare function IntersectResolve<T extends TSchema[]>(T: T): IntersectResolve<T>;
|
|
9
|
-
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
10
|
-
export interface IntersectOptions extends SchemaOptions {
|
|
11
|
-
unevaluatedProperties?: TUnevaluatedProperties;
|
|
12
|
-
}
|
|
13
|
-
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
14
|
-
[Kind]: 'Intersect';
|
|
15
|
-
static: TupleToIntersect<{
|
|
16
|
-
[K in keyof T]: Static<AssertType<T[K]>, this['params']>;
|
|
17
|
-
}>;
|
|
18
|
-
type?: 'object';
|
|
19
|
-
allOf: [...T];
|
|
20
|
-
}
|
|
21
|
-
export declare function Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): IntersectResolve<T>;
|
|
3
|
+
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
4
|
+
export type Intersect<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TIntersect<T>);
|
|
5
|
+
export declare function Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): Intersect<T>;
|