@sinclair/typebox 0.32.0-dev-21 → 0.32.0-dev-23
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/type/awaited/awaited.d.mts +4 -6
- package/build/import/type/awaited/awaited.mjs +3 -3
- package/build/import/type/composite/composite.d.mts +8 -8
- package/build/import/type/const/const.d.mts +4 -7
- package/build/import/type/constructor/constructor.d.mts +4 -4
- package/build/import/type/deref/deref.d.mts +2 -2
- package/build/import/type/deref/deref.mjs +26 -36
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +4 -6
- package/build/import/type/exclude/exclude.d.mts +7 -8
- package/build/import/type/extends/extends-from-mapped-key.d.mts +5 -8
- package/build/import/type/extends/extends-from-mapped-key.mjs +3 -3
- package/build/import/type/extends/extends-from-mapped-result.d.mts +4 -6
- package/build/import/type/extends/extends.d.mts +2 -3
- package/build/import/type/extract/extract-from-mapped-result.d.mts +4 -6
- package/build/import/type/extract/extract.d.mts +8 -8
- package/build/import/type/function/function.d.mts +1 -1
- package/build/import/type/helpers/helpers.d.mts +1 -1
- package/build/import/type/index.d.mts +0 -1
- package/build/import/type/index.mjs +0 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +5 -8
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +3 -6
- package/build/import/type/indexed/indexed-property-keys.d.mts +4 -7
- package/build/import/type/indexed/indexed.d.mts +13 -23
- package/build/import/type/indexed/indexed.mjs +13 -13
- package/build/import/type/intersect/intersect-create.mjs +0 -1
- package/build/import/type/intersect/intersect-evaluated.d.mts +7 -11
- package/build/import/type/intersect/intersect-evaluated.mjs +12 -7
- package/build/import/type/intersect/intersect-type.d.mts +2 -2
- package/build/import/type/intersect/intersect.mjs +1 -2
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +7 -9
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +3 -3
- package/build/import/type/intrinsic/intrinsic.d.mts +6 -8
- package/build/import/type/intrinsic/intrinsic.mjs +5 -3
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +4 -6
- package/build/import/type/keyof/keyof-property-keys.d.mts +9 -13
- package/build/import/type/keyof/keyof-property-keys.mjs +12 -9
- package/build/import/type/keyof/keyof.d.mts +7 -8
- package/build/import/type/keyof/keyof.mjs +8 -6
- package/build/import/type/mapped/mapped.d.mts +9 -13
- package/build/import/type/mapped/mapped.mjs +9 -9
- package/build/import/type/omit/omit-from-mapped-key.d.mts +5 -8
- package/build/import/type/omit/omit-from-mapped-key.mjs +3 -3
- package/build/import/type/omit/omit.d.mts +6 -9
- package/build/import/type/omit/omit.mjs +0 -1
- package/build/import/type/operators/operators.d.mts +16 -16
- package/build/import/type/operators/operators.mjs +21 -25
- package/build/import/type/optional/optional-from-mapped-result.d.mts +4 -6
- package/build/import/type/optional/optional.d.mts +3 -7
- package/build/import/type/partial/partial-from-mapped-result.d.mts +4 -6
- package/build/import/type/partial/partial.d.mts +4 -7
- package/build/import/type/partial/partial.mjs +6 -7
- package/build/import/type/pick/pick-from-mapped-key.d.mts +5 -8
- package/build/import/type/pick/pick-from-mapped-key.mjs +3 -3
- package/build/import/type/pick/pick.d.mts +4 -4
- package/build/import/type/readonly/readonly-from-mapped-result.d.mts +4 -6
- package/build/import/type/readonly/readonly.d.mts +3 -7
- package/build/import/type/record/record.d.mts +13 -19
- package/build/import/type/record/record.mjs +0 -1
- package/build/import/type/ref/ref.mjs +3 -0
- package/build/import/type/required/required-from-mapped-result.d.mts +4 -6
- package/build/import/type/required/required.d.mts +5 -9
- package/build/import/type/required/required.mjs +6 -7
- package/build/import/type/rest/rest.d.mts +3 -3
- package/build/import/type/static/static.d.mts +1 -1
- package/build/import/type/template-literal/finite.d.mts +3 -3
- package/build/import/type/template-literal/generate.d.mts +7 -8
- package/build/import/type/template-literal/syntax.d.mts +2 -2
- package/build/import/type/template-literal/syntax.mjs +2 -2
- package/build/import/type/transform/transform.mjs +0 -1
- package/build/import/type/tuple/tuple.d.mts +1 -2
- package/build/import/type/union/union-evaluated.d.mts +6 -10
- package/build/import/type/union/union-evaluated.mjs +7 -2
- package/build/require/index.d.ts +2 -2
- package/build/require/type/awaited/awaited.d.ts +4 -6
- package/build/require/type/awaited/awaited.js +3 -3
- package/build/require/type/composite/composite.d.ts +8 -8
- package/build/require/type/const/const.d.ts +4 -7
- package/build/require/type/constructor/constructor.d.ts +4 -4
- package/build/require/type/deref/deref.d.ts +2 -2
- package/build/require/type/deref/deref.js +25 -35
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +4 -6
- package/build/require/type/exclude/exclude.d.ts +7 -8
- package/build/require/type/extends/extends-from-mapped-key.d.ts +5 -8
- package/build/require/type/extends/extends-from-mapped-key.js +3 -3
- package/build/require/type/extends/extends-from-mapped-result.d.ts +4 -6
- package/build/require/type/extends/extends.d.ts +2 -3
- package/build/require/type/extract/extract-from-mapped-result.d.ts +4 -6
- package/build/require/type/extract/extract.d.ts +8 -8
- package/build/require/type/function/function.d.ts +1 -1
- package/build/require/type/helpers/helpers.d.ts +1 -1
- package/build/require/type/index.d.ts +0 -1
- package/build/require/type/index.js +0 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +5 -8
- package/build/require/type/indexed/indexed-from-mapped-key.js +3 -6
- package/build/require/type/indexed/indexed-property-keys.d.ts +4 -7
- package/build/require/type/indexed/indexed.d.ts +13 -23
- package/build/require/type/indexed/indexed.js +13 -13
- package/build/require/type/intersect/intersect-create.js +0 -1
- package/build/require/type/intersect/intersect-evaluated.d.ts +7 -11
- package/build/require/type/intersect/intersect-evaluated.js +9 -4
- package/build/require/type/intersect/intersect-type.d.ts +2 -2
- package/build/require/type/intersect/intersect.js +0 -1
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +7 -9
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +3 -3
- package/build/require/type/intrinsic/intrinsic.d.ts +6 -8
- package/build/require/type/intrinsic/intrinsic.js +5 -3
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +4 -6
- package/build/require/type/keyof/keyof-property-keys.d.ts +9 -13
- package/build/require/type/keyof/keyof-property-keys.js +12 -9
- package/build/require/type/keyof/keyof.d.ts +7 -8
- package/build/require/type/keyof/keyof.js +8 -6
- package/build/require/type/mapped/mapped.d.ts +9 -13
- package/build/require/type/mapped/mapped.js +9 -9
- package/build/require/type/omit/omit-from-mapped-key.d.ts +5 -8
- package/build/require/type/omit/omit-from-mapped-key.js +3 -3
- package/build/require/type/omit/omit.d.ts +6 -9
- package/build/require/type/omit/omit.js +0 -1
- package/build/require/type/operators/operators.d.ts +16 -16
- package/build/require/type/operators/operators.js +21 -25
- package/build/require/type/optional/optional-from-mapped-result.d.ts +4 -6
- package/build/require/type/optional/optional.d.ts +3 -7
- package/build/require/type/partial/partial-from-mapped-result.d.ts +4 -6
- package/build/require/type/partial/partial.d.ts +4 -7
- package/build/require/type/partial/partial.js +6 -7
- package/build/require/type/pick/pick-from-mapped-key.d.ts +5 -8
- package/build/require/type/pick/pick-from-mapped-key.js +3 -3
- package/build/require/type/pick/pick.d.ts +4 -4
- package/build/require/type/readonly/readonly-from-mapped-result.d.ts +4 -6
- package/build/require/type/readonly/readonly.d.ts +3 -7
- package/build/require/type/record/record.d.ts +13 -19
- package/build/require/type/record/record.js +0 -1
- package/build/require/type/ref/ref.js +3 -0
- package/build/require/type/required/required-from-mapped-result.d.ts +4 -6
- package/build/require/type/required/required.d.ts +5 -9
- package/build/require/type/required/required.js +6 -7
- package/build/require/type/rest/rest.d.ts +3 -3
- package/build/require/type/static/static.d.ts +1 -1
- package/build/require/type/template-literal/finite.d.ts +3 -3
- package/build/require/type/template-literal/generate.d.ts +7 -8
- package/build/require/type/template-literal/syntax.d.ts +2 -2
- package/build/require/type/template-literal/syntax.js +1 -1
- package/build/require/type/transform/transform.js +0 -1
- package/build/require/type/tuple/tuple.d.ts +1 -2
- package/build/require/type/union/union-evaluated.d.ts +6 -10
- package/build/require/type/union/union-evaluated.js +7 -2
- package/package.json +1 -1
- package/build/import/type/modifiers/index.d.mts +0 -1
- package/build/import/type/modifiers/index.mjs +0 -1
- package/build/import/type/modifiers/modifiers.d.mts +0 -18
- package/build/import/type/modifiers/modifiers.mjs +0 -50
- package/build/require/type/modifiers/index.d.ts +0 -1
- package/build/require/type/modifiers/index.js +0 -18
- package/build/require/type/modifiers/modifiers.d.ts +0 -18
- package/build/require/type/modifiers/modifiers.js +0 -56
|
@@ -9,10 +9,10 @@ import type { TLiteral } from '../literal/index';
|
|
|
9
9
|
import type { Expression } from './parse';
|
|
10
10
|
export declare class TemplateLiteralFiniteError extends Error {
|
|
11
11
|
}
|
|
12
|
-
type
|
|
13
|
-
type
|
|
12
|
+
type TFromTemplateLiteralKind<T> = T extends TTemplateLiteral<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TUnion<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TString ? false : T extends TNumber ? false : T extends TInteger ? false : T extends TBigInt ? false : T extends TBoolean ? true : T extends TLiteral ? true : false;
|
|
13
|
+
type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? TFromTemplateLiteralKind<L> extends false ? false : TFromTemplateLiteralKinds<R> : true;
|
|
14
14
|
export declare function IsTemplateLiteralExpressionFinite(expression: Expression): boolean;
|
|
15
|
-
export type TIsTemplateLiteralFinite<T> = T extends TTemplateLiteral<infer U> ?
|
|
15
|
+
export type TIsTemplateLiteralFinite<T> = T extends TTemplateLiteral<infer U> ? TFromTemplateLiteralKinds<U> : false;
|
|
16
16
|
/** Returns true if this TemplateLiteral resolves to a finite set of values */
|
|
17
17
|
export declare function IsTemplateLiteralFinite<T extends TTemplateLiteral>(schema: T): boolean;
|
|
18
18
|
export {};
|
|
@@ -7,15 +7,14 @@ import type { Expression } from './parse';
|
|
|
7
7
|
import type { TUnion } from '../union/index';
|
|
8
8
|
export declare class TemplateLiteralGenerateError extends Error {
|
|
9
9
|
}
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
type
|
|
13
|
-
type
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
]) : [];
|
|
10
|
+
type TStringReduceUnary<L extends string, R extends string[], Acc extends string[] = []> = R extends [infer A extends string, ...infer B extends string[]] ? TStringReduceUnary<L, B, [...Acc, `${L}${A}`]> : Acc;
|
|
11
|
+
type TStringReduceBinary<L extends string[], R extends string[], Acc extends string[] = []> = L extends [infer A extends string, ...infer B extends string[]] ? TStringReduceBinary<B, R, [...Acc, ...TStringReduceUnary<A, R>]> : Acc;
|
|
12
|
+
type TStringReduceMany<T extends string[][]> = T extends [infer L extends string[], infer R extends string[], ...infer Rest extends string[][]] ? TStringReduceMany<[TStringReduceBinary<L, R>, ...Rest]> : T;
|
|
13
|
+
type TStringReduce<T extends string[][], O = TStringReduceMany<T>> = 0 extends keyof O ? Assert<O[0], string[]> : [];
|
|
14
|
+
type TFromTemplateLiteralUnionKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TLiteral, ...infer R extends TLiteral[]] ? [`${L['const']}`, ...TFromTemplateLiteralUnionKinds<R>] : [];
|
|
15
|
+
type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[], Acc extends TLiteralValue[][] = []> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? (L extends TLiteral<infer S extends TLiteralValue> ? TFromTemplateLiteralKinds<R, [...Acc, [S]]> : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<R, [...Acc, TFromTemplateLiteralUnionKinds<S>]> : L extends TBoolean ? TFromTemplateLiteralKinds<R, [...Acc, ['true', 'false']]> : Acc) : Acc;
|
|
17
16
|
export declare function TemplateLiteralExpressionGenerate(expression: Expression): IterableIterator<string>;
|
|
18
|
-
export type TTemplateLiteralGenerate<T extends TTemplateLiteral, F = TIsTemplateLiteralFinite<T>> = F extends true ? (T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ?
|
|
17
|
+
export type TTemplateLiteralGenerate<T extends TTemplateLiteral, F = TIsTemplateLiteralFinite<T>> = F extends true ? (T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<S> extends infer R extends string[][] ? TStringReduce<R> : [] : []) : [];
|
|
19
18
|
/** Generates a tuple of strings from the given TemplateLiteral. Returns an empty tuple if infinite. */
|
|
20
19
|
export declare function TemplateLiteralGenerate<T extends TTemplateLiteral>(schema: T): TTemplateLiteralGenerate<T>;
|
|
21
20
|
export {};
|
|
@@ -5,12 +5,12 @@ import { type TBoolean } from '../boolean/index';
|
|
|
5
5
|
import { type TBigInt } from '../bigint/index';
|
|
6
6
|
import { type TNumber } from '../number/index';
|
|
7
7
|
import { type TString } from '../string/index';
|
|
8
|
-
import {
|
|
8
|
+
import { type TUnionEvaluated } from '../union/index';
|
|
9
9
|
declare function FromUnion(syntax: string): IterableIterator<TTemplateLiteralKind>;
|
|
10
10
|
declare function FromTerminal(syntax: string): IterableIterator<TTemplateLiteralKind>;
|
|
11
11
|
type FromUnionLiteral<T extends string> = T extends `${infer L}|${infer R}` ? [TLiteral<Trim<L>>, ...FromUnionLiteral<R>] : T extends `${infer L}` ? [TLiteral<Trim<L>>] : [
|
|
12
12
|
];
|
|
13
|
-
type FromUnion<T extends string> =
|
|
13
|
+
type FromUnion<T extends string> = TUnionEvaluated<FromUnionLiteral<T>>;
|
|
14
14
|
type FromTerminal<T extends string> = T extends 'boolean' ? TBoolean : T extends 'bigint' ? TBigInt : T extends 'number' ? TNumber : T extends 'string' ? TString : FromUnion<T>;
|
|
15
15
|
type FromString<T extends string> = T extends `{${infer L}}${infer R}` ? [FromTerminal<L>, ...FromString<R>] : T extends `${infer L}$${infer R}` ? [TLiteral<L>, ...FromString<R>] : T extends `${infer L}` ? [TLiteral<L>] : [
|
|
16
16
|
];
|
|
@@ -23,7 +23,7 @@ function* FromUnion(syntax) {
|
|
|
23
23
|
const literals = trim.split('|').map((literal) => (0, index_1.Literal)(literal.trim()));
|
|
24
24
|
return (literals.length === 0 ? (0, index_7.Never)() :
|
|
25
25
|
literals.length === 1 ? literals[0] :
|
|
26
|
-
(0, index_6.
|
|
26
|
+
(0, index_6.UnionEvaluated)(literals));
|
|
27
27
|
})());
|
|
28
28
|
}
|
|
29
29
|
// prettier-ignore
|
|
@@ -7,7 +7,6 @@ const index_1 = require("../symbols/index");
|
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
|
-
// prettier-ignore
|
|
11
10
|
const type_2 = require("../guard/type");
|
|
12
11
|
// ------------------------------------------------------------------
|
|
13
12
|
// TransformBuilders
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import { Kind } from '../symbols/index';
|
|
4
|
-
type
|
|
5
|
-
type TupleStatic<T extends TSchema[], P extends unknown[], R extends unknown[] = TupleStaticRest<T, P>> = R;
|
|
4
|
+
type TupleStatic<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TupleStatic<R, P, [...Acc, Static<L, P>]> : Acc;
|
|
6
5
|
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
7
6
|
[Kind]: 'Tuple';
|
|
8
7
|
static: TupleStatic<T, this['params']>;
|
|
@@ -3,15 +3,11 @@ import { type TNever } from '../never/index';
|
|
|
3
3
|
import { type TOptional } from '../optional/index';
|
|
4
4
|
import type { TReadonly } from '../readonly/index';
|
|
5
5
|
import type { TUnion } from './union-type';
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
type
|
|
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>);
|
|
6
|
+
type TIsUnionOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : TIsUnionOptional<R> : false);
|
|
7
|
+
type TRemoveOptionalFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromRest<R, [...Acc, TRemoveOptionalFromType<S>]> : TRemoveOptionalFromRest<R, [...Acc, L]> : Acc);
|
|
8
|
+
type TRemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<TRemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromType<S> : T);
|
|
9
|
+
type TResolveUnion<T extends TSchema[], R extends TSchema[] = TRemoveOptionalFromRest<T>> = (TIsUnionOptional<T> extends true ? TOptional<TUnion<R>> : TUnion<R>);
|
|
10
|
+
export type TUnionEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TResolveUnion<T>);
|
|
15
11
|
/** `[Json]` Creates an evaluated Union type */
|
|
16
|
-
export declare function UnionEvaluated<T extends TSchema[], R =
|
|
12
|
+
export declare function UnionEvaluated<T extends TSchema[], R = TUnionEvaluated<T>>(T: [...T], options?: SchemaOptions): R;
|
|
17
13
|
export {};
|
|
@@ -23,8 +23,13 @@ function IsUnionOptional(T) {
|
|
|
23
23
|
: false);
|
|
24
24
|
}
|
|
25
25
|
// prettier-ignore
|
|
26
|
-
function RemoveOptionalFromRest(T) {
|
|
27
|
-
|
|
26
|
+
function RemoveOptionalFromRest(T, Acc = []) {
|
|
27
|
+
const [L, ...R] = T;
|
|
28
|
+
return (T.length > 0
|
|
29
|
+
? (0, type_2.IsOptional)(L)
|
|
30
|
+
? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
|
|
31
|
+
: RemoveOptionalFromRest(R, [...Acc, L])
|
|
32
|
+
: Acc);
|
|
28
33
|
}
|
|
29
34
|
// prettier-ignore
|
|
30
35
|
function RemoveOptionalFromType(T) {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './modifiers.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './modifiers.mjs';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
-
import type { TReadonly } from '../readonly/index.mjs';
|
|
3
|
-
import { type TIntersect } from '../intersect/index.mjs';
|
|
4
|
-
import { type TUnion } from '../union/index.mjs';
|
|
5
|
-
import { type TOptional } from '../optional/index.mjs';
|
|
6
|
-
type IsOptionalFromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? IsOptionalFromIntersect<R> : false : true);
|
|
7
|
-
declare function IsOptionalFromIntersect<T extends TSchema[]>(T: T): IsOptionalFromIntersect<T>;
|
|
8
|
-
type IsOptionalFromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : IsOptionalFromUnion<R> : false);
|
|
9
|
-
declare function IsOptionalFromUnion<T extends TSchema[]>(T: T): IsOptionalFromUnion<T>;
|
|
10
|
-
type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromSchema<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
|
|
11
|
-
declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
|
|
12
|
-
type RemoveOptionalFromSchema<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromSchema<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromSchema<S> : T);
|
|
13
|
-
declare function RemoveOptionalFromSchema<T extends TSchema>(T: T): RemoveOptionalFromSchema<T>;
|
|
14
|
-
export type OptionalFromIntersect<T extends TSchema[], D extends TSchema[] = RemoveOptionalFromRest<T>> = (IsOptionalFromIntersect<T> extends true ? TOptional<TIntersect<D>> : TIntersect<T>);
|
|
15
|
-
export declare function OptionalFromIntersect<T extends TSchema[]>(T: T): OptionalFromIntersect<T>;
|
|
16
|
-
export type OptionalFromUnion<T extends TSchema[], D extends TSchema[] = RemoveOptionalFromRest<T>> = (IsOptionalFromUnion<T> extends true ? TOptional<TUnion<D>> : TUnion<T>);
|
|
17
|
-
export declare function OptionalFromUnion<T extends TSchema[]>(T: T): OptionalFromUnion<T>;
|
|
18
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Intersect } from '../intersect/index.mjs';
|
|
2
|
-
import { Union } from '../union/index.mjs';
|
|
3
|
-
import { Optional } from '../optional/index.mjs';
|
|
4
|
-
import { Discard } from '../discard/index.mjs';
|
|
5
|
-
import { OptionalKind } from '../symbols/index.mjs';
|
|
6
|
-
// ------------------------------------------------------------------
|
|
7
|
-
// TypeGuard
|
|
8
|
-
// ------------------------------------------------------------------
|
|
9
|
-
// prettier-ignore
|
|
10
|
-
import { IsOptional } from '../guard/type.mjs';
|
|
11
|
-
// prettier-ignore
|
|
12
|
-
function IsOptionalFromIntersect(T) {
|
|
13
|
-
const [L, ...R] = T;
|
|
14
|
-
return (T.length > 0
|
|
15
|
-
? IsOptional(L)
|
|
16
|
-
? IsOptionalFromIntersect(R)
|
|
17
|
-
: false
|
|
18
|
-
: true);
|
|
19
|
-
}
|
|
20
|
-
// prettier-ignore
|
|
21
|
-
function IsOptionalFromUnion(T) {
|
|
22
|
-
const [L, ...R] = T;
|
|
23
|
-
return (T.length > 0
|
|
24
|
-
? IsOptional(L)
|
|
25
|
-
? true
|
|
26
|
-
: IsOptionalFromUnion(R)
|
|
27
|
-
: false);
|
|
28
|
-
}
|
|
29
|
-
// prettier-ignore
|
|
30
|
-
function RemoveOptionalFromRest(T) {
|
|
31
|
-
return (T.map(T => RemoveOptionalFromSchema(T)));
|
|
32
|
-
}
|
|
33
|
-
// prettier-ignore
|
|
34
|
-
function RemoveOptionalFromSchema(T) {
|
|
35
|
-
return (Discard(T, [OptionalKind]));
|
|
36
|
-
}
|
|
37
|
-
// prettier-ignore
|
|
38
|
-
export function OptionalFromIntersect(T) {
|
|
39
|
-
const D = RemoveOptionalFromRest(T);
|
|
40
|
-
return (IsOptionalFromIntersect(T)
|
|
41
|
-
? Optional(Intersect(D))
|
|
42
|
-
: Intersect(T));
|
|
43
|
-
}
|
|
44
|
-
// prettier-ignore
|
|
45
|
-
export function OptionalFromUnion(T) {
|
|
46
|
-
const D = RemoveOptionalFromRest(T);
|
|
47
|
-
return (IsOptionalFromUnion(T)
|
|
48
|
-
? Optional(Union(D))
|
|
49
|
-
: Union(T));
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './modifiers';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./modifiers"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { TSchema } from '../schema/index';
|
|
2
|
-
import type { TReadonly } from '../readonly/index';
|
|
3
|
-
import { type TIntersect } from '../intersect/index';
|
|
4
|
-
import { type TUnion } from '../union/index';
|
|
5
|
-
import { type TOptional } from '../optional/index';
|
|
6
|
-
type IsOptionalFromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? IsOptionalFromIntersect<R> : false : true);
|
|
7
|
-
declare function IsOptionalFromIntersect<T extends TSchema[]>(T: T): IsOptionalFromIntersect<T>;
|
|
8
|
-
type IsOptionalFromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : IsOptionalFromUnion<R> : false);
|
|
9
|
-
declare function IsOptionalFromUnion<T extends TSchema[]>(T: T): IsOptionalFromUnion<T>;
|
|
10
|
-
type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromSchema<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
|
|
11
|
-
declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
|
|
12
|
-
type RemoveOptionalFromSchema<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromSchema<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromSchema<S> : T);
|
|
13
|
-
declare function RemoveOptionalFromSchema<T extends TSchema>(T: T): RemoveOptionalFromSchema<T>;
|
|
14
|
-
export type OptionalFromIntersect<T extends TSchema[], D extends TSchema[] = RemoveOptionalFromRest<T>> = (IsOptionalFromIntersect<T> extends true ? TOptional<TIntersect<D>> : TIntersect<T>);
|
|
15
|
-
export declare function OptionalFromIntersect<T extends TSchema[]>(T: T): OptionalFromIntersect<T>;
|
|
16
|
-
export type OptionalFromUnion<T extends TSchema[], D extends TSchema[] = RemoveOptionalFromRest<T>> = (IsOptionalFromUnion<T> extends true ? TOptional<TUnion<D>> : TUnion<T>);
|
|
17
|
-
export declare function OptionalFromUnion<T extends TSchema[]>(T: T): OptionalFromUnion<T>;
|
|
18
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OptionalFromUnion = exports.OptionalFromIntersect = void 0;
|
|
5
|
-
const index_1 = require("../intersect/index");
|
|
6
|
-
const index_2 = require("../union/index");
|
|
7
|
-
const index_3 = require("../optional/index");
|
|
8
|
-
const index_4 = require("../discard/index");
|
|
9
|
-
const index_5 = require("../symbols/index");
|
|
10
|
-
// ------------------------------------------------------------------
|
|
11
|
-
// TypeGuard
|
|
12
|
-
// ------------------------------------------------------------------
|
|
13
|
-
// prettier-ignore
|
|
14
|
-
const type_1 = require("../guard/type");
|
|
15
|
-
// prettier-ignore
|
|
16
|
-
function IsOptionalFromIntersect(T) {
|
|
17
|
-
const [L, ...R] = T;
|
|
18
|
-
return (T.length > 0
|
|
19
|
-
? (0, type_1.IsOptional)(L)
|
|
20
|
-
? IsOptionalFromIntersect(R)
|
|
21
|
-
: false
|
|
22
|
-
: true);
|
|
23
|
-
}
|
|
24
|
-
// prettier-ignore
|
|
25
|
-
function IsOptionalFromUnion(T) {
|
|
26
|
-
const [L, ...R] = T;
|
|
27
|
-
return (T.length > 0
|
|
28
|
-
? (0, type_1.IsOptional)(L)
|
|
29
|
-
? true
|
|
30
|
-
: IsOptionalFromUnion(R)
|
|
31
|
-
: false);
|
|
32
|
-
}
|
|
33
|
-
// prettier-ignore
|
|
34
|
-
function RemoveOptionalFromRest(T) {
|
|
35
|
-
return (T.map(T => RemoveOptionalFromSchema(T)));
|
|
36
|
-
}
|
|
37
|
-
// prettier-ignore
|
|
38
|
-
function RemoveOptionalFromSchema(T) {
|
|
39
|
-
return ((0, index_4.Discard)(T, [index_5.OptionalKind]));
|
|
40
|
-
}
|
|
41
|
-
// prettier-ignore
|
|
42
|
-
function OptionalFromIntersect(T) {
|
|
43
|
-
const D = RemoveOptionalFromRest(T);
|
|
44
|
-
return (IsOptionalFromIntersect(T)
|
|
45
|
-
? (0, index_3.Optional)((0, index_1.Intersect)(D))
|
|
46
|
-
: (0, index_1.Intersect)(T));
|
|
47
|
-
}
|
|
48
|
-
exports.OptionalFromIntersect = OptionalFromIntersect;
|
|
49
|
-
// prettier-ignore
|
|
50
|
-
function OptionalFromUnion(T) {
|
|
51
|
-
const D = RemoveOptionalFromRest(T);
|
|
52
|
-
return (IsOptionalFromUnion(T)
|
|
53
|
-
? (0, index_3.Optional)((0, index_2.Union)(D))
|
|
54
|
-
: (0, index_2.Union)(T));
|
|
55
|
-
}
|
|
56
|
-
exports.OptionalFromUnion = OptionalFromUnion;
|