@sinclair/typebox 0.32.9 → 0.32.11
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 +3 -3
- package/build/import/index.mjs +1 -1
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +2 -2
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +6 -6
- package/build/import/type/exclude/exclude-from-template-literal.d.mts +5 -0
- package/build/import/type/exclude/exclude-from-template-literal.mjs +5 -0
- package/build/import/type/exclude/exclude.d.mts +8 -8
- package/build/import/type/exclude/exclude.mjs +8 -6
- package/build/import/type/exclude/index.d.mts +1 -0
- package/build/import/type/exclude/index.mjs +1 -0
- package/build/import/type/extract/extract-from-mapped-result.d.mts +2 -2
- package/build/import/type/extract/extract-from-mapped-result.mjs +6 -6
- package/build/import/type/extract/extract-from-template-literal.d.mts +5 -0
- package/build/import/type/extract/extract-from-template-literal.mjs +5 -0
- package/build/import/type/extract/extract.d.mts +9 -9
- package/build/import/type/extract/extract.mjs +8 -6
- package/build/import/type/extract/index.d.mts +1 -0
- package/build/import/type/extract/index.mjs +1 -0
- package/build/import/type/partial/partial.d.mts +2 -4
- package/build/import/type/partial/partial.mjs +3 -0
- package/build/import/type/required/required.d.mts +2 -3
- package/build/import/type/required/required.mjs +3 -0
- package/build/import/type/template-literal/union.d.mts +6 -4
- package/build/import/type/template-literal/union.mjs +2 -5
- package/build/import/type/type/json.d.mts +6 -2
- package/build/require/index.d.ts +3 -3
- package/build/require/index.js +2 -1
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +2 -2
- package/build/require/type/exclude/exclude-from-mapped-result.js +6 -6
- package/build/require/type/exclude/exclude-from-template-literal.d.ts +5 -0
- package/build/require/type/exclude/exclude-from-template-literal.js +10 -0
- package/build/require/type/exclude/exclude.d.ts +8 -8
- package/build/require/type/exclude/exclude.js +13 -11
- package/build/require/type/exclude/index.d.ts +1 -0
- package/build/require/type/exclude/index.js +1 -0
- package/build/require/type/extract/extract-from-mapped-result.d.ts +2 -2
- package/build/require/type/extract/extract-from-mapped-result.js +6 -6
- package/build/require/type/extract/extract-from-template-literal.d.ts +5 -0
- package/build/require/type/extract/extract-from-template-literal.js +10 -0
- package/build/require/type/extract/extract.d.ts +9 -9
- package/build/require/type/extract/extract.js +13 -11
- package/build/require/type/extract/index.d.ts +1 -0
- package/build/require/type/extract/index.js +1 -0
- package/build/require/type/partial/partial.d.ts +2 -4
- package/build/require/type/partial/partial.js +3 -0
- package/build/require/type/required/required.d.ts +2 -3
- package/build/require/type/required/required.js +3 -0
- package/build/require/type/template-literal/union.d.ts +6 -4
- package/build/require/type/template-literal/union.js +1 -4
- package/build/require/type/type/json.d.ts +6 -2
- package/package.json +1 -1
package/build/import/index.d.mts
CHANGED
|
@@ -19,9 +19,9 @@ export { ConstructorParameters, type TConstructorParameters } from './type/const
|
|
|
19
19
|
export { Date, type TDate, type DateOptions } from './type/date/index.mjs';
|
|
20
20
|
export { Deref, type TDeref } from './type/deref/index.mjs';
|
|
21
21
|
export { Enum, type TEnum } from './type/enum/index.mjs';
|
|
22
|
-
export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/exclude/index.mjs';
|
|
22
|
+
export { Exclude, type TExclude, type TExcludeFromMappedResult, type TExcludeFromTemplateLiteral } from './type/exclude/index.mjs';
|
|
23
23
|
export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey } from './type/extends/index.mjs';
|
|
24
|
-
export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index.mjs';
|
|
24
|
+
export { Extract, type TExtract, type TExtractFromMappedResult, type TExtractFromTemplateLiteral } from './type/extract/index.mjs';
|
|
25
25
|
export { Function, type TFunction } from './type/function/index.mjs';
|
|
26
26
|
export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromPropertyKeys, type TIndexFromPropertyKey, type TIndexFromMappedKey, type TIndexFromMappedResult, } from './type/indexed/index.mjs';
|
|
27
27
|
export { InstanceType, type TInstanceType } from './type/instance-type/index.mjs';
|
|
@@ -57,7 +57,7 @@ export { type Static, type StaticDecode, type StaticEncode, type TDecodeType, ty
|
|
|
57
57
|
export { Strict } from './type/strict/index.mjs';
|
|
58
58
|
export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index.mjs';
|
|
59
59
|
export { Symbol, type TSymbol, type TSymbolValue } from './type/symbol/index.mjs';
|
|
60
|
-
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TIsTemplateLiteralFinite, } from './type/template-literal/index.mjs';
|
|
60
|
+
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralToUnion, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TTemplateLiteralToUnion, type TIsTemplateLiteralFinite, } from './type/template-literal/index.mjs';
|
|
61
61
|
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index.mjs';
|
|
62
62
|
export { Tuple, type TTuple } from './type/tuple/index.mjs';
|
|
63
63
|
export { Uint8Array, type TUint8Array, type Uint8ArrayOptions } from './type/uint8array/index.mjs';
|
package/build/import/index.mjs
CHANGED
|
@@ -70,7 +70,7 @@ export { ReturnType } from './type/return-type/index.mjs';
|
|
|
70
70
|
export { Strict } from './type/strict/index.mjs';
|
|
71
71
|
export { String } from './type/string/index.mjs';
|
|
72
72
|
export { Symbol } from './type/symbol/index.mjs';
|
|
73
|
-
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, } from './type/template-literal/index.mjs';
|
|
73
|
+
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralToUnion, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, } from './type/template-literal/index.mjs';
|
|
74
74
|
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder } from './type/transform/index.mjs';
|
|
75
75
|
export { Tuple } from './type/tuple/index.mjs';
|
|
76
76
|
export { Uint8Array } from './type/uint8array/index.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSchema
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
2
|
import type { TProperties } from '../object/index.mjs';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index.mjs';
|
|
4
4
|
import { type TExclude } from './exclude.mjs';
|
|
@@ -7,5 +7,5 @@ type TFromProperties<K extends TProperties, T extends TSchema> = ({
|
|
|
7
7
|
});
|
|
8
8
|
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
9
|
export type TExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
-
export declare function ExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T
|
|
10
|
+
export declare function ExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { MappedResult } from '../mapped/index.mjs';
|
|
2
2
|
import { Exclude } from './exclude.mjs';
|
|
3
3
|
// prettier-ignore
|
|
4
|
-
function FromProperties(P, U
|
|
4
|
+
function FromProperties(P, U) {
|
|
5
5
|
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
6
|
-
return { ...Acc, [K2]: Exclude(P[K2], U
|
|
6
|
+
return { ...Acc, [K2]: Exclude(P[K2], U) };
|
|
7
7
|
}, {});
|
|
8
8
|
}
|
|
9
9
|
// prettier-ignore
|
|
10
|
-
function FromMappedResult(R, T
|
|
11
|
-
return FromProperties(R.properties, T
|
|
10
|
+
function FromMappedResult(R, T) {
|
|
11
|
+
return FromProperties(R.properties, T);
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
export function ExcludeFromMappedResult(R, T
|
|
15
|
-
const P = FromMappedResult(R, T
|
|
14
|
+
export function ExcludeFromMappedResult(R, T) {
|
|
15
|
+
const P = FromMappedResult(R, T);
|
|
16
16
|
return MappedResult(P);
|
|
17
17
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
+
import { TExclude } from './exclude.mjs';
|
|
3
|
+
import { type TTemplateLiteral, type TTemplateLiteralToUnion } from '../template-literal/index.mjs';
|
|
4
|
+
export type TExcludeFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (TExclude<TTemplateLiteralToUnion<L>, R>);
|
|
5
|
+
export declare function ExcludeFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema>(L: L, R: R): TExcludeFromTemplateLiteral<L, R>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
|
-
import type { UnionToTuple, AssertRest, AssertType
|
|
2
|
+
import type { UnionToTuple, AssertRest, AssertType } from '../helpers/index.mjs';
|
|
3
3
|
import type { TMappedResult } from '../mapped/index.mjs';
|
|
4
4
|
import { type TTemplateLiteral } from '../template-literal/index.mjs';
|
|
5
5
|
import { type TUnion } from '../union/index.mjs';
|
|
6
6
|
import { type TNever } from '../never/index.mjs';
|
|
7
|
-
import { type TLiteral } from '../literal/index.mjs';
|
|
8
7
|
import { type Static } from '../static/index.mjs';
|
|
9
8
|
import { type TUnionEvaluated } from '../union/index.mjs';
|
|
10
9
|
import { type TExcludeFromMappedResult } from './exclude-from-mapped-result.mjs';
|
|
11
|
-
type
|
|
12
|
-
[K in T]: TLiteral<K>;
|
|
13
|
-
}[T]>>>;
|
|
14
|
-
type TExcludeTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (Exclude<Static<L>, Static<R>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
|
|
10
|
+
import { type TExcludeFromTemplateLiteral } from './exclude-from-template-literal.mjs';
|
|
15
11
|
type TExcludeRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
|
|
16
12
|
[K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? never : L[K];
|
|
17
13
|
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
|
|
18
|
-
export type TExclude<L extends TSchema, R extends TSchema> = (L extends
|
|
14
|
+
export type TExclude<L extends TSchema, R extends TSchema> = (L extends TUnion<infer S> ? TExcludeRest<S, R> : L extends R ? TNever : L);
|
|
19
15
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
20
|
-
export declare function Exclude<L extends
|
|
16
|
+
export declare function Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
17
|
+
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
18
|
+
export declare function Exclude<L extends TTemplateLiteral, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromTemplateLiteral<L, R>;
|
|
19
|
+
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
20
|
+
export declare function Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
21
21
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TemplateLiteralToUnion } from '../template-literal/index.mjs';
|
|
2
1
|
import { Union } from '../union/index.mjs';
|
|
3
2
|
import { Never } from '../never/index.mjs';
|
|
4
3
|
import { ExtendsCheck, ExtendsResult } from '../extends/index.mjs';
|
|
5
4
|
import { CloneType } from '../clone/type.mjs';
|
|
6
5
|
import { ExcludeFromMappedResult } from './exclude-from-mapped-result.mjs';
|
|
6
|
+
import { ExcludeFromTemplateLiteral } from './exclude-from-template-literal.mjs';
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
@@ -14,10 +14,12 @@ function ExcludeRest(L, R) {
|
|
|
14
14
|
}
|
|
15
15
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
16
16
|
export function Exclude(L, R, options = {}) {
|
|
17
|
+
// overloads
|
|
18
|
+
if (IsTemplateLiteral(L))
|
|
19
|
+
return CloneType(ExcludeFromTemplateLiteral(L, R), options);
|
|
20
|
+
if (IsMappedResult(L))
|
|
21
|
+
return CloneType(ExcludeFromMappedResult(L, R), options);
|
|
17
22
|
// prettier-ignore
|
|
18
|
-
return CloneType((
|
|
19
|
-
|
|
20
|
-
IsTemplateLiteral(R) ? Exclude(L, TemplateLiteralToUnion(R)) :
|
|
21
|
-
IsUnion(L) ? ExcludeRest(L.anyOf, R) :
|
|
22
|
-
ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L), options);
|
|
23
|
+
return CloneType(IsUnion(L) ? ExcludeRest(L.anyOf, R) :
|
|
24
|
+
ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
|
|
23
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSchema
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
2
|
import type { TProperties } from '../object/index.mjs';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index.mjs';
|
|
4
4
|
import { type TExtract } from './extract.mjs';
|
|
@@ -7,5 +7,5 @@ type TFromProperties<P extends TProperties, T extends TSchema> = ({
|
|
|
7
7
|
});
|
|
8
8
|
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
9
|
export type TExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
-
export declare function ExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T
|
|
10
|
+
export declare function ExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { MappedResult } from '../mapped/index.mjs';
|
|
2
2
|
import { Extract } from './extract.mjs';
|
|
3
3
|
// prettier-ignore
|
|
4
|
-
function FromProperties(P, T
|
|
4
|
+
function FromProperties(P, T) {
|
|
5
5
|
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
6
|
-
return { ...Acc, [K2]: Extract(P[K2], T
|
|
6
|
+
return { ...Acc, [K2]: Extract(P[K2], T) };
|
|
7
7
|
}, {});
|
|
8
8
|
}
|
|
9
9
|
// prettier-ignore
|
|
10
|
-
function FromMappedResult(R, T
|
|
11
|
-
return FromProperties(R.properties, T
|
|
10
|
+
function FromMappedResult(R, T) {
|
|
11
|
+
return FromProperties(R.properties, T);
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
export function ExtractFromMappedResult(R, T
|
|
15
|
-
const P = FromMappedResult(R, T
|
|
14
|
+
export function ExtractFromMappedResult(R, T) {
|
|
15
|
+
const P = FromMappedResult(R, T);
|
|
16
16
|
return MappedResult(P);
|
|
17
17
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
+
import { type TExtract } from './extract.mjs';
|
|
3
|
+
import { type TTemplateLiteral, type TTemplateLiteralToUnion } from '../template-literal/index.mjs';
|
|
4
|
+
export type TExtractFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (TExtract<TTemplateLiteralToUnion<L>, R>);
|
|
5
|
+
export declare function ExtractFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema>(L: L, R: R): TExtractFromTemplateLiteral<L, R>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AssertRest, AssertType, UnionToTuple } from '../helpers/index.mjs';
|
|
3
3
|
import type { TMappedResult } from '../mapped/index.mjs';
|
|
4
|
-
import { type TTemplateLiteral } from '../template-literal/index.mjs';
|
|
5
|
-
import { type TLiteral } from '../literal/index.mjs';
|
|
6
4
|
import { type TUnion } from '../union/index.mjs';
|
|
7
5
|
import { type Static } from '../static/index.mjs';
|
|
8
6
|
import { type TNever } from '../never/index.mjs';
|
|
9
7
|
import { type TUnionEvaluated } from '../union/index.mjs';
|
|
8
|
+
import { type TTemplateLiteral } from '../template-literal/index.mjs';
|
|
10
9
|
import { type TExtractFromMappedResult } from './extract-from-mapped-result.mjs';
|
|
11
|
-
type
|
|
12
|
-
[K in T]: TLiteral<K>;
|
|
13
|
-
}[T]>>>;
|
|
14
|
-
type TExtractTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = Extract<Static<L>, Static<R>> extends infer S ? TExtractTemplateLiteralResult<Assert<S, string>> : never;
|
|
10
|
+
import { type TExtractFromTemplateLiteral } from './extract-from-template-literal.mjs';
|
|
15
11
|
type TExtractRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
|
|
16
12
|
[K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? L[K] : never;
|
|
17
13
|
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
|
|
18
|
-
export type TExtract<L extends TSchema, U extends TSchema> = (L extends
|
|
14
|
+
export type TExtract<L extends TSchema, U extends TSchema> = (L extends TUnion<infer S> ? TExtractRest<S, U> : L extends U ? L : TNever);
|
|
15
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
16
|
+
export declare function Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
17
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
18
|
+
export declare function Extract<L extends TTemplateLiteral, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromTemplateLiteral<L, R>;
|
|
19
19
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
20
|
-
export declare function Extract<L extends TSchema, R extends TSchema>(
|
|
20
|
+
export declare function Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
21
21
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TemplateLiteralToUnion } from '../template-literal/index.mjs';
|
|
2
1
|
import { Union } from '../union/index.mjs';
|
|
3
2
|
import { Never } from '../never/index.mjs';
|
|
4
3
|
import { ExtendsCheck, ExtendsResult } from '../extends/index.mjs';
|
|
5
4
|
import { CloneType } from '../clone/type.mjs';
|
|
6
5
|
import { ExtractFromMappedResult } from './extract-from-mapped-result.mjs';
|
|
6
|
+
import { ExtractFromTemplateLiteral } from './extract-from-template-literal.mjs';
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
@@ -14,10 +14,12 @@ function ExtractRest(L, R) {
|
|
|
14
14
|
}
|
|
15
15
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
16
16
|
export function Extract(L, R, options = {}) {
|
|
17
|
+
// overloads
|
|
18
|
+
if (IsTemplateLiteral(L))
|
|
19
|
+
return CloneType(ExtractFromTemplateLiteral(L, R), options);
|
|
20
|
+
if (IsMappedResult(L))
|
|
21
|
+
return CloneType(ExtractFromMappedResult(L, R), options);
|
|
17
22
|
// prettier-ignore
|
|
18
|
-
return CloneType((
|
|
19
|
-
|
|
20
|
-
IsTemplateLiteral(R) ? Extract(L, TemplateLiteralToUnion(R)) :
|
|
21
|
-
IsUnion(L) ? ExtractRest(L.anyOf, R) :
|
|
22
|
-
ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never()), options);
|
|
23
|
+
return CloneType(IsUnion(L) ? ExtractRest(L.anyOf, R) :
|
|
24
|
+
ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
|
|
23
25
|
}
|
|
@@ -9,13 +9,11 @@ import { type TObject, type TProperties } from '../object/index.mjs';
|
|
|
9
9
|
import { type TIntersect } from '../intersect/index.mjs';
|
|
10
10
|
import { type TUnion } from '../union/index.mjs';
|
|
11
11
|
import { type TPartialFromMappedResult } from './partial-from-mapped-result.mjs';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TPartial<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
|
|
18
|
-
export type TPartial<T extends TSchema> = PartialResolve<T>;
|
|
16
|
+
export type TPartial<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TPartial<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
19
17
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
20
18
|
export declare function Partial<T extends TMappedResult>(T: T, options?: SchemaOptions): TPartialFromMappedResult<T>;
|
|
21
19
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
@@ -20,6 +20,9 @@ function FromProperties(T) {
|
|
|
20
20
|
return { ...Acc, [K]: Optional(T[K]) };
|
|
21
21
|
}, {});
|
|
22
22
|
}
|
|
23
|
+
// ------------------------------------------------------------------
|
|
24
|
+
// PartialResolve
|
|
25
|
+
// ------------------------------------------------------------------
|
|
23
26
|
// prettier-ignore
|
|
24
27
|
function PartialResolve(T) {
|
|
25
28
|
return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
|
|
@@ -9,12 +9,11 @@ import { type TIntersect } from '../intersect/index.mjs';
|
|
|
9
9
|
import { type TUnion } from '../union/index.mjs';
|
|
10
10
|
import { type TObject, type TProperties } from '../object/index.mjs';
|
|
11
11
|
import { type TRequiredFromMappedResult } from './required-from-mapped-result.mjs';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TRequired<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
export type TRequired<T extends TSchema> = TRequiredResolve<T>;
|
|
16
|
+
export type TRequired<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequired<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
18
17
|
/** `[Json]` Constructs a type where all properties are required */
|
|
19
18
|
export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
|
|
20
19
|
/** `[Json]` Constructs a type where all properties are required */
|
|
@@ -19,6 +19,9 @@ function FromProperties(T) {
|
|
|
19
19
|
return { ...Acc, [K]: Discard(T[K], [OptionalKind]) };
|
|
20
20
|
}, {});
|
|
21
21
|
}
|
|
22
|
+
// ------------------------------------------------------------------
|
|
23
|
+
// RequiredResolve
|
|
24
|
+
// ------------------------------------------------------------------
|
|
22
25
|
// prettier-ignore
|
|
23
26
|
function RequiredResolve(T) {
|
|
24
27
|
return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Static } from '../static/index.mjs';
|
|
1
2
|
import type { TTemplateLiteral } from './template-literal.mjs';
|
|
2
|
-
import {
|
|
3
|
+
import type { UnionToTuple } from '../helpers/index.mjs';
|
|
4
|
+
import { type TUnionEvaluated } from '../union/index.mjs';
|
|
3
5
|
import { type TLiteral } from '../literal/index.mjs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
export type TTemplateLiteralToUnionLiteralArray<T extends string[], Acc extends TLiteral[] = []> = (T extends [infer L extends string, ...infer R extends string[]] ? TTemplateLiteralToUnionLiteralArray<R, [...Acc, TLiteral<L>]> : Acc);
|
|
7
|
+
export type TTemplateLiteralToUnion<T extends TTemplateLiteral, U extends string[] = UnionToTuple<Static<T>>> = TUnionEvaluated<TTemplateLiteralToUnionLiteralArray<U>>;
|
|
6
8
|
/** Returns a Union from the given TemplateLiteral */
|
|
7
|
-
export declare function TemplateLiteralToUnion(schema: TTemplateLiteral):
|
|
9
|
+
export declare function TemplateLiteralToUnion<T extends TTemplateLiteral>(schema: TTemplateLiteral): TTemplateLiteralToUnion<T>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnionEvaluated } from '../union/index.mjs';
|
|
2
2
|
import { Literal } from '../literal/index.mjs';
|
|
3
3
|
import { TemplateLiteralGenerate } from './generate.mjs';
|
|
4
|
-
// ------------------------------------------------------------------
|
|
5
|
-
// TemplateLiteralToUnion
|
|
6
|
-
// ------------------------------------------------------------------
|
|
7
4
|
/** Returns a Union from the given TemplateLiteral */
|
|
8
5
|
export function TemplateLiteralToUnion(schema) {
|
|
9
6
|
const R = TemplateLiteralGenerate(schema);
|
|
10
7
|
const L = R.map((S) => Literal(S));
|
|
11
|
-
return
|
|
8
|
+
return UnionEvaluated(L);
|
|
12
9
|
}
|
|
@@ -5,9 +5,9 @@ import { type TComposite } from '../composite/index.mjs';
|
|
|
5
5
|
import { type TConst } from '../const/index.mjs';
|
|
6
6
|
import { type TDeref } from '../deref/index.mjs';
|
|
7
7
|
import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index.mjs';
|
|
8
|
-
import { type TExclude, type TExcludeFromMappedResult } from '../exclude/index.mjs';
|
|
8
|
+
import { type TExclude, type TExcludeFromMappedResult, type TExcludeFromTemplateLiteral } from '../exclude/index.mjs';
|
|
9
9
|
import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResult } from '../extends/index.mjs';
|
|
10
|
-
import { type TExtract, type TExtractFromMappedResult } from '../extract/index.mjs';
|
|
10
|
+
import { type TExtract, type TExtractFromMappedResult, type TExtractFromTemplateLiteral } from '../extract/index.mjs';
|
|
11
11
|
import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey, type TIndexFromMappedResult } from '../indexed/index.mjs';
|
|
12
12
|
import { type IntegerOptions, type TInteger } from '../integer/index.mjs';
|
|
13
13
|
import { Intersect, type IntersectOptions } from '../intersect/index.mjs';
|
|
@@ -81,6 +81,8 @@ export declare class JsonTypeBuilder {
|
|
|
81
81
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
82
82
|
Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
83
83
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
84
|
+
Exclude<L extends TTemplateLiteral, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromTemplateLiteral<L, R>;
|
|
85
|
+
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
84
86
|
Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
85
87
|
/** `[Json]` Creates a Conditional type */
|
|
86
88
|
Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
|
|
@@ -91,6 +93,8 @@ export declare class JsonTypeBuilder {
|
|
|
91
93
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
92
94
|
Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
93
95
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
96
|
+
Extract<L extends TTemplateLiteral, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromTemplateLiteral<L, R>;
|
|
97
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
94
98
|
Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
95
99
|
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
96
100
|
Index<T extends TSchema, K extends TMappedResult>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedResult<T, K>;
|
package/build/require/index.d.ts
CHANGED
|
@@ -19,9 +19,9 @@ export { ConstructorParameters, type TConstructorParameters } from './type/const
|
|
|
19
19
|
export { Date, type TDate, type DateOptions } from './type/date/index';
|
|
20
20
|
export { Deref, type TDeref } from './type/deref/index';
|
|
21
21
|
export { Enum, type TEnum } from './type/enum/index';
|
|
22
|
-
export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/exclude/index';
|
|
22
|
+
export { Exclude, type TExclude, type TExcludeFromMappedResult, type TExcludeFromTemplateLiteral } from './type/exclude/index';
|
|
23
23
|
export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey } from './type/extends/index';
|
|
24
|
-
export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index';
|
|
24
|
+
export { Extract, type TExtract, type TExtractFromMappedResult, type TExtractFromTemplateLiteral } from './type/extract/index';
|
|
25
25
|
export { Function, type TFunction } from './type/function/index';
|
|
26
26
|
export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromPropertyKeys, type TIndexFromPropertyKey, type TIndexFromMappedKey, type TIndexFromMappedResult, } from './type/indexed/index';
|
|
27
27
|
export { InstanceType, type TInstanceType } from './type/instance-type/index';
|
|
@@ -57,7 +57,7 @@ export { type Static, type StaticDecode, type StaticEncode, type TDecodeType, ty
|
|
|
57
57
|
export { Strict } from './type/strict/index';
|
|
58
58
|
export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index';
|
|
59
59
|
export { Symbol, type TSymbol, type TSymbolValue } from './type/symbol/index';
|
|
60
|
-
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TIsTemplateLiteralFinite, } from './type/template-literal/index';
|
|
60
|
+
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralToUnion, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TTemplateLiteralToUnion, type TIsTemplateLiteralFinite, } from './type/template-literal/index';
|
|
61
61
|
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index';
|
|
62
62
|
export { Tuple, type TTuple } from './type/tuple/index';
|
|
63
63
|
export { Uint8Array, type TUint8Array, type Uint8ArrayOptions } from './type/uint8array/index';
|
package/build/require/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.IndexFromPropertyKeys = exports.IndexPropertyKeys = exports.Index = 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.Increment = exports.SetUnionMany = exports.SetUnion = exports.SetIsSubset = exports.SetIntersectMany = exports.SetIntersect = exports.SetIncludes = exports.SetDistinct = exports.SetComplement = exports.TypeBoxError = 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;
|
|
5
5
|
exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.ReadonlyFromMappedResult = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.OptionalFromMappedResult = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedFunctionReturnType = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfFromMappedResult = exports.KeyOfPropertyKeysToRest = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedResult = exports.IndexFromMappedKey = exports.IndexFromPropertyKey = void 0;
|
|
6
|
-
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = 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.IsTemplateLiteralExpressionFinite = exports.TemplateLiteralExpressionGenerate = exports.IsTemplateLiteralFinite = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.TemplateLiteralGenerate = exports.TemplateLiteralSyntax = exports.TemplateLiteral = void 0;
|
|
6
|
+
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = 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.IsTemplateLiteralExpressionFinite = exports.TemplateLiteralExpressionGenerate = exports.IsTemplateLiteralFinite = exports.TemplateLiteralToUnion = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.TemplateLiteralGenerate = exports.TemplateLiteralSyntax = exports.TemplateLiteral = void 0;
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// Infrastructure
|
|
9
9
|
// ------------------------------------------------------------------
|
|
@@ -182,6 +182,7 @@ Object.defineProperty(exports, "TemplateLiteralSyntax", { enumerable: true, get:
|
|
|
182
182
|
Object.defineProperty(exports, "TemplateLiteralGenerate", { enumerable: true, get: function () { return index_57.TemplateLiteralGenerate; } });
|
|
183
183
|
Object.defineProperty(exports, "TemplateLiteralParse", { enumerable: true, get: function () { return index_57.TemplateLiteralParse; } });
|
|
184
184
|
Object.defineProperty(exports, "TemplateLiteralParseExact", { enumerable: true, get: function () { return index_57.TemplateLiteralParseExact; } });
|
|
185
|
+
Object.defineProperty(exports, "TemplateLiteralToUnion", { enumerable: true, get: function () { return index_57.TemplateLiteralToUnion; } });
|
|
185
186
|
Object.defineProperty(exports, "IsTemplateLiteralFinite", { enumerable: true, get: function () { return index_57.IsTemplateLiteralFinite; } });
|
|
186
187
|
Object.defineProperty(exports, "TemplateLiteralExpressionGenerate", { enumerable: true, get: function () { return index_57.TemplateLiteralExpressionGenerate; } });
|
|
187
188
|
Object.defineProperty(exports, "IsTemplateLiteralExpressionFinite", { enumerable: true, get: function () { return index_57.IsTemplateLiteralExpressionFinite; } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSchema
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExclude } from './exclude';
|
|
@@ -7,5 +7,5 @@ type TFromProperties<K extends TProperties, T extends TSchema> = ({
|
|
|
7
7
|
});
|
|
8
8
|
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
9
|
export type TExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
-
export declare function ExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T
|
|
10
|
+
export declare function ExcludeFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -5,18 +5,18 @@ exports.ExcludeFromMappedResult = void 0;
|
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const exclude_1 = require("./exclude");
|
|
7
7
|
// prettier-ignore
|
|
8
|
-
function FromProperties(P, U
|
|
8
|
+
function FromProperties(P, U) {
|
|
9
9
|
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
10
|
-
return { ...Acc, [K2]: (0, exclude_1.Exclude)(P[K2], U
|
|
10
|
+
return { ...Acc, [K2]: (0, exclude_1.Exclude)(P[K2], U) };
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromMappedResult(R, T
|
|
15
|
-
return FromProperties(R.properties, T
|
|
14
|
+
function FromMappedResult(R, T) {
|
|
15
|
+
return FromProperties(R.properties, T);
|
|
16
16
|
}
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
function ExcludeFromMappedResult(R, T
|
|
19
|
-
const P = FromMappedResult(R, T
|
|
18
|
+
function ExcludeFromMappedResult(R, T) {
|
|
19
|
+
const P = FromMappedResult(R, T);
|
|
20
20
|
return (0, index_1.MappedResult)(P);
|
|
21
21
|
}
|
|
22
22
|
exports.ExcludeFromMappedResult = ExcludeFromMappedResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
|
+
import { TExclude } from './exclude';
|
|
3
|
+
import { type TTemplateLiteral, type TTemplateLiteralToUnion } from '../template-literal/index';
|
|
4
|
+
export type TExcludeFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (TExclude<TTemplateLiteralToUnion<L>, R>);
|
|
5
|
+
export declare function ExcludeFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema>(L: L, R: R): TExcludeFromTemplateLiteral<L, R>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ExcludeFromTemplateLiteral = void 0;
|
|
5
|
+
const exclude_1 = require("./exclude");
|
|
6
|
+
const index_1 = require("../template-literal/index");
|
|
7
|
+
function ExcludeFromTemplateLiteral(L, R) {
|
|
8
|
+
return (0, exclude_1.Exclude)((0, index_1.TemplateLiteralToUnion)(L), R);
|
|
9
|
+
}
|
|
10
|
+
exports.ExcludeFromTemplateLiteral = ExcludeFromTemplateLiteral;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import type { UnionToTuple, AssertRest, AssertType
|
|
2
|
+
import type { UnionToTuple, AssertRest, AssertType } from '../helpers/index';
|
|
3
3
|
import type { TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TTemplateLiteral } from '../template-literal/index';
|
|
5
5
|
import { type TUnion } from '../union/index';
|
|
6
6
|
import { type TNever } from '../never/index';
|
|
7
|
-
import { type TLiteral } from '../literal/index';
|
|
8
7
|
import { type Static } from '../static/index';
|
|
9
8
|
import { type TUnionEvaluated } from '../union/index';
|
|
10
9
|
import { type TExcludeFromMappedResult } from './exclude-from-mapped-result';
|
|
11
|
-
type
|
|
12
|
-
[K in T]: TLiteral<K>;
|
|
13
|
-
}[T]>>>;
|
|
14
|
-
type TExcludeTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (Exclude<Static<L>, Static<R>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
|
|
10
|
+
import { type TExcludeFromTemplateLiteral } from './exclude-from-template-literal';
|
|
15
11
|
type TExcludeRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
|
|
16
12
|
[K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? never : L[K];
|
|
17
13
|
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
|
|
18
|
-
export type TExclude<L extends TSchema, R extends TSchema> = (L extends
|
|
14
|
+
export type TExclude<L extends TSchema, R extends TSchema> = (L extends TUnion<infer S> ? TExcludeRest<S, R> : L extends R ? TNever : L);
|
|
19
15
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
20
|
-
export declare function Exclude<L extends
|
|
16
|
+
export declare function Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
17
|
+
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
18
|
+
export declare function Exclude<L extends TTemplateLiteral, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromTemplateLiteral<L, R>;
|
|
19
|
+
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
20
|
+
export declare function Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
21
21
|
export {};
|
|
@@ -2,27 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Exclude = void 0;
|
|
5
|
-
const index_1 = require("../
|
|
6
|
-
const index_2 = require("../
|
|
7
|
-
const index_3 = require("../
|
|
8
|
-
const index_4 = require("../extends/index");
|
|
5
|
+
const index_1 = require("../union/index");
|
|
6
|
+
const index_2 = require("../never/index");
|
|
7
|
+
const index_3 = require("../extends/index");
|
|
9
8
|
const type_1 = require("../clone/type");
|
|
10
9
|
const exclude_from_mapped_result_1 = require("./exclude-from-mapped-result");
|
|
10
|
+
const exclude_from_template_literal_1 = require("./exclude-from-template-literal");
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// TypeGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
14
|
const type_2 = require("../guard/type");
|
|
15
15
|
function ExcludeRest(L, R) {
|
|
16
|
-
const excluded = L.filter((inner) => (0,
|
|
17
|
-
return excluded.length === 1 ? excluded[0] : (0,
|
|
16
|
+
const excluded = L.filter((inner) => (0, index_3.ExtendsCheck)(inner, R) === index_3.ExtendsResult.False);
|
|
17
|
+
return excluded.length === 1 ? excluded[0] : (0, index_1.Union)(excluded);
|
|
18
18
|
}
|
|
19
19
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
20
20
|
function Exclude(L, R, options = {}) {
|
|
21
|
+
// overloads
|
|
22
|
+
if ((0, type_2.IsTemplateLiteral)(L))
|
|
23
|
+
return (0, type_1.CloneType)((0, exclude_from_template_literal_1.ExcludeFromTemplateLiteral)(L, R), options);
|
|
24
|
+
if ((0, type_2.IsMappedResult)(L))
|
|
25
|
+
return (0, type_1.CloneType)((0, exclude_from_mapped_result_1.ExcludeFromMappedResult)(L, R), options);
|
|
21
26
|
// prettier-ignore
|
|
22
|
-
return (0, type_1.CloneType)((
|
|
23
|
-
(0,
|
|
24
|
-
(0, type_2.IsTemplateLiteral)(R) ? Exclude(L, (0, index_1.TemplateLiteralToUnion)(R)) :
|
|
25
|
-
(0, type_2.IsUnion)(L) ? ExcludeRest(L.anyOf, R) :
|
|
26
|
-
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? (0, index_3.Never)() : L), options);
|
|
27
|
+
return (0, type_1.CloneType)((0, type_2.IsUnion)(L) ? ExcludeRest(L.anyOf, R) :
|
|
28
|
+
(0, index_3.ExtendsCheck)(L, R) !== index_3.ExtendsResult.False ? (0, index_2.Never)() : L, options);
|
|
27
29
|
}
|
|
28
30
|
exports.Exclude = Exclude;
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
__exportStar(require("./exclude-from-mapped-result"), exports);
|
|
19
|
+
__exportStar(require("./exclude-from-template-literal"), exports);
|
|
19
20
|
__exportStar(require("./exclude"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSchema
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExtract } from './extract';
|
|
@@ -7,5 +7,5 @@ type TFromProperties<P extends TProperties, T extends TSchema> = ({
|
|
|
7
7
|
});
|
|
8
8
|
type TFromMappedResult<R extends TMappedResult, T extends TSchema> = (TFromProperties<R['properties'], T>);
|
|
9
9
|
export type TExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>> = (TMappedResult<P>);
|
|
10
|
-
export declare function ExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T
|
|
10
|
+
export declare function ExtractFromMappedResult<R extends TMappedResult, T extends TSchema, P extends TProperties = TFromMappedResult<R, T>>(R: R, T: T): TMappedResult<P>;
|
|
11
11
|
export {};
|
|
@@ -5,18 +5,18 @@ exports.ExtractFromMappedResult = void 0;
|
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const extract_1 = require("./extract");
|
|
7
7
|
// prettier-ignore
|
|
8
|
-
function FromProperties(P, T
|
|
8
|
+
function FromProperties(P, T) {
|
|
9
9
|
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
|
|
10
|
-
return { ...Acc, [K2]: (0, extract_1.Extract)(P[K2], T
|
|
10
|
+
return { ...Acc, [K2]: (0, extract_1.Extract)(P[K2], T) };
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromMappedResult(R, T
|
|
15
|
-
return FromProperties(R.properties, T
|
|
14
|
+
function FromMappedResult(R, T) {
|
|
15
|
+
return FromProperties(R.properties, T);
|
|
16
16
|
}
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
function ExtractFromMappedResult(R, T
|
|
19
|
-
const P = FromMappedResult(R, T
|
|
18
|
+
function ExtractFromMappedResult(R, T) {
|
|
19
|
+
const P = FromMappedResult(R, T);
|
|
20
20
|
return (0, index_1.MappedResult)(P);
|
|
21
21
|
}
|
|
22
22
|
exports.ExtractFromMappedResult = ExtractFromMappedResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
|
+
import { type TExtract } from './extract';
|
|
3
|
+
import { type TTemplateLiteral, type TTemplateLiteralToUnion } from '../template-literal/index';
|
|
4
|
+
export type TExtractFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (TExtract<TTemplateLiteralToUnion<L>, R>);
|
|
5
|
+
export declare function ExtractFromTemplateLiteral<L extends TTemplateLiteral, R extends TSchema>(L: L, R: R): TExtractFromTemplateLiteral<L, R>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ExtractFromTemplateLiteral = void 0;
|
|
5
|
+
const extract_1 = require("./extract");
|
|
6
|
+
const index_1 = require("../template-literal/index");
|
|
7
|
+
function ExtractFromTemplateLiteral(L, R) {
|
|
8
|
+
return (0, extract_1.Extract)((0, index_1.TemplateLiteralToUnion)(L), R);
|
|
9
|
+
}
|
|
10
|
+
exports.ExtractFromTemplateLiteral = ExtractFromTemplateLiteral;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AssertRest, AssertType, UnionToTuple } from '../helpers/index';
|
|
3
3
|
import type { TMappedResult } from '../mapped/index';
|
|
4
|
-
import { type TTemplateLiteral } from '../template-literal/index';
|
|
5
|
-
import { type TLiteral } from '../literal/index';
|
|
6
4
|
import { type TUnion } from '../union/index';
|
|
7
5
|
import { type Static } from '../static/index';
|
|
8
6
|
import { type TNever } from '../never/index';
|
|
9
7
|
import { type TUnionEvaluated } from '../union/index';
|
|
8
|
+
import { type TTemplateLiteral } from '../template-literal/index';
|
|
10
9
|
import { type TExtractFromMappedResult } from './extract-from-mapped-result';
|
|
11
|
-
type
|
|
12
|
-
[K in T]: TLiteral<K>;
|
|
13
|
-
}[T]>>>;
|
|
14
|
-
type TExtractTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = Extract<Static<L>, Static<R>> extends infer S ? TExtractTemplateLiteralResult<Assert<S, string>> : never;
|
|
10
|
+
import { type TExtractFromTemplateLiteral } from './extract-from-template-literal';
|
|
15
11
|
type TExtractRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
|
|
16
12
|
[K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? L[K] : never;
|
|
17
13
|
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
|
|
18
|
-
export type TExtract<L extends TSchema, U extends TSchema> = (L extends
|
|
14
|
+
export type TExtract<L extends TSchema, U extends TSchema> = (L extends TUnion<infer S> ? TExtractRest<S, U> : L extends U ? L : TNever);
|
|
15
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
16
|
+
export declare function Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
17
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
18
|
+
export declare function Extract<L extends TTemplateLiteral, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromTemplateLiteral<L, R>;
|
|
19
19
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
20
|
-
export declare function Extract<L extends TSchema, R extends TSchema>(
|
|
20
|
+
export declare function Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
21
21
|
export {};
|
|
@@ -2,27 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Extract = void 0;
|
|
5
|
-
const index_1 = require("../
|
|
6
|
-
const index_2 = require("../
|
|
7
|
-
const index_3 = require("../
|
|
8
|
-
const index_4 = require("../extends/index");
|
|
5
|
+
const index_1 = require("../union/index");
|
|
6
|
+
const index_2 = require("../never/index");
|
|
7
|
+
const index_3 = require("../extends/index");
|
|
9
8
|
const type_1 = require("../clone/type");
|
|
10
9
|
const extract_from_mapped_result_1 = require("./extract-from-mapped-result");
|
|
10
|
+
const extract_from_template_literal_1 = require("./extract-from-template-literal");
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// TypeGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
14
|
const type_2 = require("../guard/type");
|
|
15
15
|
function ExtractRest(L, R) {
|
|
16
|
-
const extracted = L.filter((inner) => (0,
|
|
17
|
-
return extracted.length === 1 ? extracted[0] : (0,
|
|
16
|
+
const extracted = L.filter((inner) => (0, index_3.ExtendsCheck)(inner, R) !== index_3.ExtendsResult.False);
|
|
17
|
+
return extracted.length === 1 ? extracted[0] : (0, index_1.Union)(extracted);
|
|
18
18
|
}
|
|
19
19
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
20
20
|
function Extract(L, R, options = {}) {
|
|
21
|
+
// overloads
|
|
22
|
+
if ((0, type_2.IsTemplateLiteral)(L))
|
|
23
|
+
return (0, type_1.CloneType)((0, extract_from_template_literal_1.ExtractFromTemplateLiteral)(L, R), options);
|
|
24
|
+
if ((0, type_2.IsMappedResult)(L))
|
|
25
|
+
return (0, type_1.CloneType)((0, extract_from_mapped_result_1.ExtractFromMappedResult)(L, R), options);
|
|
21
26
|
// prettier-ignore
|
|
22
|
-
return (0, type_1.CloneType)((
|
|
23
|
-
(0,
|
|
24
|
-
(0, type_2.IsTemplateLiteral)(R) ? Extract(L, (0, index_1.TemplateLiteralToUnion)(R)) :
|
|
25
|
-
(0, type_2.IsUnion)(L) ? ExtractRest(L.anyOf, R) :
|
|
26
|
-
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? L : (0, index_3.Never)()), options);
|
|
27
|
+
return (0, type_1.CloneType)((0, type_2.IsUnion)(L) ? ExtractRest(L.anyOf, R) :
|
|
28
|
+
(0, index_3.ExtendsCheck)(L, R) !== index_3.ExtendsResult.False ? L : (0, index_2.Never)(), options);
|
|
27
29
|
}
|
|
28
30
|
exports.Extract = Extract;
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
__exportStar(require("./extract-from-mapped-result"), exports);
|
|
19
|
+
__exportStar(require("./extract-from-template-literal"), exports);
|
|
19
20
|
__exportStar(require("./extract"), exports);
|
|
@@ -9,13 +9,11 @@ import { type TObject, type TProperties } from '../object/index';
|
|
|
9
9
|
import { type TIntersect } from '../intersect/index';
|
|
10
10
|
import { type TUnion } from '../union/index';
|
|
11
11
|
import { type TPartialFromMappedResult } from './partial-from-mapped-result';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TPartial<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
|
|
18
|
-
export type TPartial<T extends TSchema> = PartialResolve<T>;
|
|
16
|
+
export type TPartial<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TPartial<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
19
17
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
20
18
|
export declare function Partial<T extends TMappedResult>(T: T, options?: SchemaOptions): TPartialFromMappedResult<T>;
|
|
21
19
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
@@ -24,6 +24,9 @@ function FromProperties(T) {
|
|
|
24
24
|
return { ...Acc, [K]: (0, index_1.Optional)(T[K]) };
|
|
25
25
|
}, {});
|
|
26
26
|
}
|
|
27
|
+
// ------------------------------------------------------------------
|
|
28
|
+
// PartialResolve
|
|
29
|
+
// ------------------------------------------------------------------
|
|
27
30
|
// prettier-ignore
|
|
28
31
|
function PartialResolve(T) {
|
|
29
32
|
return ((0, type_2.IsIntersect)(T) ? (0, index_3.Intersect)(FromRest(T.allOf)) :
|
|
@@ -9,12 +9,11 @@ import { type TIntersect } from '../intersect/index';
|
|
|
9
9
|
import { type TUnion } from '../union/index';
|
|
10
10
|
import { type TObject, type TProperties } from '../object/index';
|
|
11
11
|
import { type TRequiredFromMappedResult } from './required-from-mapped-result';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TRequired<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
export type TRequired<T extends TSchema> = TRequiredResolve<T>;
|
|
16
|
+
export type TRequired<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequired<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
18
17
|
/** `[Json]` Constructs a type where all properties are required */
|
|
19
18
|
export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
|
|
20
19
|
/** `[Json]` Constructs a type where all properties are required */
|
|
@@ -23,6 +23,9 @@ function FromProperties(T) {
|
|
|
23
23
|
return { ...Acc, [K]: (0, index_5.Discard)(T[K], [index_4.OptionalKind]) };
|
|
24
24
|
}, {});
|
|
25
25
|
}
|
|
26
|
+
// ------------------------------------------------------------------
|
|
27
|
+
// RequiredResolve
|
|
28
|
+
// ------------------------------------------------------------------
|
|
26
29
|
// prettier-ignore
|
|
27
30
|
function RequiredResolve(T) {
|
|
28
31
|
return ((0, type_2.IsIntersect)(T) ? (0, index_1.Intersect)(FromRest(T.allOf)) :
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Static } from '../static/index';
|
|
1
2
|
import type { TTemplateLiteral } from './template-literal';
|
|
2
|
-
import {
|
|
3
|
+
import type { UnionToTuple } from '../helpers/index';
|
|
4
|
+
import { type TUnionEvaluated } from '../union/index';
|
|
3
5
|
import { type TLiteral } from '../literal/index';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
export type TTemplateLiteralToUnionLiteralArray<T extends string[], Acc extends TLiteral[] = []> = (T extends [infer L extends string, ...infer R extends string[]] ? TTemplateLiteralToUnionLiteralArray<R, [...Acc, TLiteral<L>]> : Acc);
|
|
7
|
+
export type TTemplateLiteralToUnion<T extends TTemplateLiteral, U extends string[] = UnionToTuple<Static<T>>> = TUnionEvaluated<TTemplateLiteralToUnionLiteralArray<U>>;
|
|
6
8
|
/** Returns a Union from the given TemplateLiteral */
|
|
7
|
-
export declare function TemplateLiteralToUnion(schema: TTemplateLiteral):
|
|
9
|
+
export declare function TemplateLiteralToUnion<T extends TTemplateLiteral>(schema: TTemplateLiteral): TTemplateLiteralToUnion<T>;
|
|
@@ -5,13 +5,10 @@ exports.TemplateLiteralToUnion = void 0;
|
|
|
5
5
|
const index_1 = require("../union/index");
|
|
6
6
|
const index_2 = require("../literal/index");
|
|
7
7
|
const generate_1 = require("./generate");
|
|
8
|
-
// ------------------------------------------------------------------
|
|
9
|
-
// TemplateLiteralToUnion
|
|
10
|
-
// ------------------------------------------------------------------
|
|
11
8
|
/** Returns a Union from the given TemplateLiteral */
|
|
12
9
|
function TemplateLiteralToUnion(schema) {
|
|
13
10
|
const R = (0, generate_1.TemplateLiteralGenerate)(schema);
|
|
14
11
|
const L = R.map((S) => (0, index_2.Literal)(S));
|
|
15
|
-
return (0, index_1.
|
|
12
|
+
return (0, index_1.UnionEvaluated)(L);
|
|
16
13
|
}
|
|
17
14
|
exports.TemplateLiteralToUnion = TemplateLiteralToUnion;
|
|
@@ -5,9 +5,9 @@ import { type TComposite } from '../composite/index';
|
|
|
5
5
|
import { type TConst } from '../const/index';
|
|
6
6
|
import { type TDeref } from '../deref/index';
|
|
7
7
|
import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index';
|
|
8
|
-
import { type TExclude, type TExcludeFromMappedResult } from '../exclude/index';
|
|
8
|
+
import { type TExclude, type TExcludeFromMappedResult, type TExcludeFromTemplateLiteral } from '../exclude/index';
|
|
9
9
|
import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResult } from '../extends/index';
|
|
10
|
-
import { type TExtract, type TExtractFromMappedResult } from '../extract/index';
|
|
10
|
+
import { type TExtract, type TExtractFromMappedResult, type TExtractFromTemplateLiteral } from '../extract/index';
|
|
11
11
|
import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey, type TIndexFromMappedResult } from '../indexed/index';
|
|
12
12
|
import { type IntegerOptions, type TInteger } from '../integer/index';
|
|
13
13
|
import { Intersect, type IntersectOptions } from '../intersect/index';
|
|
@@ -81,6 +81,8 @@ export declare class JsonTypeBuilder {
|
|
|
81
81
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
82
82
|
Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
83
83
|
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
84
|
+
Exclude<L extends TTemplateLiteral, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromTemplateLiteral<L, R>;
|
|
85
|
+
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
|
|
84
86
|
Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
85
87
|
/** `[Json]` Creates a Conditional type */
|
|
86
88
|
Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
|
|
@@ -91,6 +93,8 @@ export declare class JsonTypeBuilder {
|
|
|
91
93
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
92
94
|
Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
93
95
|
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
96
|
+
Extract<L extends TTemplateLiteral, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromTemplateLiteral<L, R>;
|
|
97
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
94
98
|
Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
95
99
|
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
96
100
|
Index<T extends TSchema, K extends TMappedResult>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedResult<T, K>;
|