@sinclair/typebox 0.32.5 → 0.32.6

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.
Files changed (60) hide show
  1. package/build/import/index.d.mts +7 -7
  2. package/build/import/index.mjs +4 -4
  3. package/build/import/type/awaited/awaited.d.mts +3 -4
  4. package/build/import/type/awaited/awaited.mjs +7 -4
  5. package/build/import/type/composite/composite.d.mts +2 -3
  6. package/build/import/type/composite/composite.mjs +3 -7
  7. package/build/import/type/deref/deref.d.mts +3 -5
  8. package/build/import/type/deref/deref.mjs +4 -1
  9. package/build/import/type/exclude/exclude.d.mts +5 -8
  10. package/build/import/type/exclude/exclude.mjs +10 -18
  11. package/build/import/type/extract/extract.d.mts +7 -9
  12. package/build/import/type/extract/extract.mjs +10 -18
  13. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
  14. package/build/import/type/indexed/indexed.d.mts +6 -4
  15. package/build/import/type/indexed/indexed.mjs +5 -5
  16. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -2
  17. package/build/import/type/keyof/keyof.d.mts +3 -3
  18. package/build/import/type/keyof/keyof.mjs +2 -2
  19. package/build/import/type/mapped/mapped.d.mts +3 -3
  20. package/build/import/type/mapped/mapped.mjs +2 -2
  21. package/build/import/type/omit/omit-from-mapped-result.d.mts +3 -2
  22. package/build/import/type/omit/omit.d.mts +3 -5
  23. package/build/import/type/omit/omit.mjs +4 -1
  24. package/build/import/type/partial/partial-from-mapped-result.d.mts +3 -2
  25. package/build/import/type/pick/pick-from-mapped-result.d.mts +3 -2
  26. package/build/import/type/pick/pick.d.mts +3 -5
  27. package/build/import/type/pick/pick.mjs +4 -1
  28. package/build/import/type/required/required-from-mapped-result.d.mts +3 -2
  29. package/build/import/type/static/static.d.mts +5 -5
  30. package/build/require/index.d.ts +7 -7
  31. package/build/require/index.js +12 -6
  32. package/build/require/type/awaited/awaited.d.ts +3 -4
  33. package/build/require/type/awaited/awaited.js +7 -4
  34. package/build/require/type/composite/composite.d.ts +2 -3
  35. package/build/require/type/composite/composite.js +3 -7
  36. package/build/require/type/deref/deref.d.ts +3 -5
  37. package/build/require/type/deref/deref.js +4 -2
  38. package/build/require/type/exclude/exclude.d.ts +5 -8
  39. package/build/require/type/exclude/exclude.js +10 -18
  40. package/build/require/type/extract/extract.d.ts +7 -9
  41. package/build/require/type/extract/extract.js +10 -18
  42. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
  43. package/build/require/type/indexed/indexed.d.ts +6 -4
  44. package/build/require/type/indexed/indexed.js +8 -6
  45. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -2
  46. package/build/require/type/keyof/keyof.d.ts +3 -3
  47. package/build/require/type/keyof/keyof.js +4 -3
  48. package/build/require/type/mapped/mapped.d.ts +3 -3
  49. package/build/require/type/mapped/mapped.js +4 -3
  50. package/build/require/type/omit/omit-from-mapped-result.d.ts +3 -2
  51. package/build/require/type/omit/omit.d.ts +3 -5
  52. package/build/require/type/omit/omit.js +4 -2
  53. package/build/require/type/partial/partial-from-mapped-result.d.ts +3 -2
  54. package/build/require/type/pick/pick-from-mapped-result.d.ts +3 -2
  55. package/build/require/type/pick/pick.d.ts +3 -5
  56. package/build/require/type/pick/pick.js +4 -2
  57. package/build/require/type/required/required-from-mapped-result.d.ts +3 -2
  58. package/build/require/type/static/static.d.ts +5 -5
  59. package/package.json +1 -1
  60. package/readme.md +11 -11
@@ -18,19 +18,19 @@ export { Date, type TDate, type DateOptions } from './type/date/index.mjs';
18
18
  export { Deref, type TDeref } from './type/deref/index.mjs';
19
19
  export { Enum, type TEnum } from './type/enum/index.mjs';
20
20
  export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/exclude/index.mjs';
21
- export { Extends, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck } from './type/extends/index.mjs';
21
+ export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey } from './type/extends/index.mjs';
22
22
  export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index.mjs';
23
23
  export { Function, type TFunction } from './type/function/index.mjs';
24
24
  export { Increment, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index.mjs';
25
- export { Index, IndexPropertyKeys, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey, type TIndexFromMappedResult } from './type/indexed/index.mjs';
25
+ export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromPropertyKeys, type TIndexFromPropertyKey, type TIndexFromMappedKey, type TIndexFromMappedResult, } from './type/indexed/index.mjs';
26
26
  export { InstanceType, type TInstanceType } from './type/instance-type/index.mjs';
27
27
  export { Integer, type TInteger, type IntegerOptions } from './type/integer/index.mjs';
28
28
  export { Intersect, IntersectEvaluated, type TIntersect, type TIntersectEvaluated, type IntersectOptions } from './type/intersect/index.mjs';
29
29
  export { Iterator, type TIterator } from './type/iterator/index.mjs';
30
30
  export { Intrinsic, IntrinsicFromMappedKey, type TIntrinsic, Capitalize, type TCapitalize, Lowercase, type TLowercase, Uncapitalize, type TUncapitalize, Uppercase, type TUppercase } from './type/intrinsic/index.mjs';
31
- export { KeyOf, type TKeyOf, type KeyOfFromMappedResult, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index.mjs';
31
+ export { KeyOf, KeyOfPropertyKeys, KeyOfPropertyKeysToRest, KeyOfFromMappedResult, KeyOfPattern, type TKeyOf, type TKeyOfPropertyKeys, type TKeyOfPropertyKeysToRest, type TKeyOfFromMappedResult } from './type/keyof/index.mjs';
32
32
  export { Literal, type TLiteral, type TLiteralValue } from './type/literal/index.mjs';
33
- export { Mapped, MappedKey, MappedResult, type TMapped, type TMappedKey, type TMappedResult, type TMappedFunction } from './type/mapped/index.mjs';
33
+ export { Mapped, MappedKey, MappedResult, MappedFunctionReturnType, type TMapped, type TMappedKey, type TMappedResult, type TMappedFunction, type TMappedFunctionReturnType } from './type/mapped/index.mjs';
34
34
  export { Never, type TNever } from './type/never/index.mjs';
35
35
  export { Not, type TNot } from './type/not/index.mjs';
36
36
  export { Null, type TNull } from './type/null/index.mjs';
@@ -44,7 +44,7 @@ export { Pick, type TPick, type TPickFromMappedKey, type TPickFromMappedResult }
44
44
  export { Promise, type TPromise } from './type/promise/index.mjs';
45
45
  export { Readonly, ReadonlyFromMappedResult, type TReadonly, type TReadonlyWithFlag, type TReadonlyFromMappedResult } from './type/readonly/index.mjs';
46
46
  export { ReadonlyOptional, type TReadonlyOptional } from './type/readonly-optional/index.mjs';
47
- export { Record, type TRecord } from './type/record/index.mjs';
47
+ export { Record, type TRecord, type TRecordOrObject } from './type/record/index.mjs';
48
48
  export { Recursive, type TRecursive, type TThis } from './type/recursive/index.mjs';
49
49
  export { Ref, type TRef } from './type/ref/index.mjs';
50
50
  export { RegExp, type TRegExp } from './type/regexp/index.mjs';
@@ -52,11 +52,11 @@ export { Required, type TRequired, type TRequiredFromMappedResult } from './type
52
52
  export { Rest, type TRest } from './type/rest/index.mjs';
53
53
  export { ReturnType, type TReturnType } from './type/return-type/index.mjs';
54
54
  export { type TSchema, type TKind, type SchemaOptions, type TAnySchema } from './type/schema/index.mjs';
55
- export { type Static, type StaticDecode, type StaticEncode } from './type/static/index.mjs';
55
+ export { type Static, type StaticDecode, type StaticEncode, type TDecodeType, type TDecodeRest, type TDecodeProperties } from './type/static/index.mjs';
56
56
  export { Strict } from './type/strict/index.mjs';
57
57
  export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index.mjs';
58
58
  export { Symbol, type TSymbol, type TSymbolValue as SymbolValue } from './type/symbol/index.mjs';
59
- export { TemplateLiteral, IsTemplateLiteralFinite, IsTemplateLiteralExpressionFinite, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralGenerate, TemplateLiteralExpressionGenerate, type TTemplateLiteral, type TIsTemplateLiteralFinite, type TTemplateLiteralGenerate, type TTemplateLiteralKind, } from './type/template-literal/index.mjs';
59
+ 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
60
  export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index.mjs';
61
61
  export { Tuple, type TTuple } from './type/tuple/index.mjs';
62
62
  export { Uint8Array, type TUint8Array, type Uint8ArrayOptions } from './type/uint8array/index.mjs';
@@ -28,15 +28,15 @@ export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck } from './t
28
28
  export { Extract } from './type/extract/index.mjs';
29
29
  export { Function } from './type/function/index.mjs';
30
30
  export { Increment } from './type/helpers/index.mjs';
31
- export { Index, IndexPropertyKeys, IndexFromMappedKey, IndexFromMappedResult } from './type/indexed/index.mjs';
31
+ export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, } from './type/indexed/index.mjs';
32
32
  export { InstanceType } from './type/instance-type/index.mjs';
33
33
  export { Integer } from './type/integer/index.mjs';
34
34
  export { Intersect, IntersectEvaluated } from './type/intersect/index.mjs';
35
35
  export { Iterator } from './type/iterator/index.mjs';
36
36
  export { Intrinsic, IntrinsicFromMappedKey, Capitalize, Lowercase, Uncapitalize, Uppercase } from './type/intrinsic/index.mjs';
37
- export { KeyOf, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index.mjs';
37
+ export { KeyOf, KeyOfPropertyKeys, KeyOfPropertyKeysToRest, KeyOfFromMappedResult, KeyOfPattern } from './type/keyof/index.mjs';
38
38
  export { Literal } from './type/literal/index.mjs';
39
- export { Mapped, MappedKey, MappedResult } from './type/mapped/index.mjs';
39
+ export { Mapped, MappedKey, MappedResult, MappedFunctionReturnType } from './type/mapped/index.mjs';
40
40
  export { Never } from './type/never/index.mjs';
41
41
  export { Not } from './type/not/index.mjs';
42
42
  export { Null } from './type/null/index.mjs';
@@ -60,7 +60,7 @@ export { ReturnType } from './type/return-type/index.mjs';
60
60
  export { Strict } from './type/strict/index.mjs';
61
61
  export { String } from './type/string/index.mjs';
62
62
  export { Symbol } from './type/symbol/index.mjs';
63
- export { TemplateLiteral, IsTemplateLiteralFinite, IsTemplateLiteralExpressionFinite, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralGenerate, TemplateLiteralExpressionGenerate, } from './type/template-literal/index.mjs';
63
+ export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, } from './type/template-literal/index.mjs';
64
64
  export { Transform, TransformDecodeBuilder, TransformEncodeBuilder } from './type/transform/index.mjs';
65
65
  export { Tuple } from './type/tuple/index.mjs';
66
66
  export { Uint8Array } from './type/uint8array/index.mjs';
@@ -2,9 +2,8 @@ import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import { type TIntersect } from '../intersect/index.mjs';
3
3
  import { type TUnion } from '../union/index.mjs';
4
4
  import { type TPromise } from '../promise/index.mjs';
5
- type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TFromSchema<L>]> : Acc;
6
- type TFromSchema<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TPromise<infer S> ? TFromSchema<S> : T;
7
- export type TAwaited<T extends TSchema> = (TFromSchema<T>);
5
+ type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TAwaited<L>]> : Acc;
6
+ export type TAwaited<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TPromise<infer S> ? TAwaited<S> : T;
8
7
  /** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
9
- export declare function Awaited<T extends TSchema>(T: T, options?: SchemaOptions): TFromSchema<T>;
8
+ export declare function Awaited<T extends TSchema>(T: T, options?: SchemaOptions): TAwaited<T>;
10
9
  export {};
@@ -7,7 +7,7 @@ import { CloneType } from '../clone/type.mjs';
7
7
  import { IsIntersect, IsUnion, IsPromise } from '../guard/type.mjs';
8
8
  // prettier-ignore
9
9
  function FromRest(T) {
10
- return T.map(L => FromSchema(L));
10
+ return T.map(L => AwaitedResolve(L));
11
11
  }
12
12
  // prettier-ignore
13
13
  function FromIntersect(T) {
@@ -19,10 +19,13 @@ function FromUnion(T) {
19
19
  }
20
20
  // prettier-ignore
21
21
  function FromPromise(T) {
22
- return FromSchema(T);
22
+ return AwaitedResolve(T);
23
23
  }
24
+ // ----------------------------------------------------------------
25
+ // AwaitedResolve
26
+ // ----------------------------------------------------------------
24
27
  // prettier-ignore
25
- function FromSchema(T) {
28
+ function AwaitedResolve(T) {
26
29
  return (IsIntersect(T) ? FromIntersect(T.allOf) :
27
30
  IsUnion(T) ? FromUnion(T.anyOf) :
28
31
  IsPromise(T) ? FromPromise(T.item) :
@@ -30,5 +33,5 @@ function FromSchema(T) {
30
33
  }
31
34
  /** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
32
35
  export function Awaited(T, options = {}) {
33
- return CloneType(FromSchema(T), options);
36
+ return CloneType(AwaitedResolve(T), options);
34
37
  }
@@ -1,4 +1,4 @@
1
- import type { UnionToTuple, Assert, Evaluate } from '../helpers/index.mjs';
1
+ import type { UnionToTuple, Assert, Ensure, Evaluate } from '../helpers/index.mjs';
2
2
  import { type TObject, type TProperties, type ObjectOptions } from '../object/index.mjs';
3
3
  import { type TIntersect } from '../intersect/index.mjs';
4
4
  import { type TIndex } from '../indexed/index.mjs';
@@ -7,8 +7,7 @@ type TCompositeIndex<T extends TIntersect<TObject[]>, K extends string[], Acc ex
7
7
  [_ in L]: TIndex<T, [L]>;
8
8
  }> : Acc;
9
9
  type TCompositeReduce<T extends TObject[]> = UnionToTuple<TCompositeKeys<T>> extends infer K ? Evaluate<TCompositeIndex<TIntersect<T>, Assert<K, string[]>>> : {};
10
- type TCompositeResolve<T extends TObject[]> = TIntersect<T> extends TIntersect ? TObject<TCompositeReduce<T>> : TObject<{}>;
11
- export type TComposite<T extends TObject[]> = TCompositeResolve<T>;
10
+ export type TComposite<T extends TObject[]> = TIntersect<T> extends TIntersect ? Ensure<TObject<TCompositeReduce<T>>> : Ensure<TObject<{}>>;
12
11
  /** `[Json]` Creates a Composite object type */
13
12
  export declare function Composite<T extends TObject[]>(T: [...T], options?: ObjectOptions): TComposite<T>;
14
13
  export {};
@@ -2,14 +2,10 @@ import { Object } from '../object/index.mjs';
2
2
  import { Intersect } from '../intersect/index.mjs';
3
3
  import { Index } from '../indexed/index.mjs';
4
4
  import { KeyOfPropertyKeys } from '../keyof/index.mjs';
5
- import { CloneType } from '../clone/type.mjs';
6
- function CompositeResolve(T) {
5
+ /** `[Json]` Creates a Composite object type */
6
+ export function Composite(T, options) {
7
7
  const intersect = Intersect(T, {});
8
8
  const keys = KeyOfPropertyKeys(intersect);
9
9
  const properties = keys.reduce((acc, key) => ({ ...acc, [key]: Index(intersect, [key]) }), {});
10
- return Object(properties);
11
- }
12
- /** `[Json]` Creates a Composite object type */
13
- export function Composite(T, options) {
14
- return CloneType(CompositeResolve(T), options);
10
+ return Object(properties, options);
15
11
  }
@@ -11,14 +11,12 @@ import type { TConstructor } from '../constructor/index.mjs';
11
11
  import type { TFunction } from '../function/index.mjs';
12
12
  import type { TRef } from '../ref/index.mjs';
13
13
  import type { TObject, TProperties } from '../object/index.mjs';
14
- export type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, DerefResolve<L>]> : Acc);
14
+ export type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TDeref<L>]> : Acc);
15
15
  type FromProperties<T extends TProperties> = Evaluate<{
16
- [K in keyof T]: DerefResolve<T[K]>;
16
+ [K in keyof T]: TDeref<T[K]>;
17
17
  }>;
18
18
  declare function FromProperties(properties: TProperties, references: TSchema[]): TProperties;
19
- export type DerefResolve<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<S>, DerefResolve<R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<S>, DerefResolve<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TFromRest<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TFromRest<S>> : T extends TObject<infer S extends TProperties> ? TObject<FromProperties<S>> : T extends TArray<infer S extends TSchema> ? TArray<DerefResolve<S>> : T extends TPromise<infer S extends TSchema> ? TPromise<DerefResolve<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DerefResolve<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DerefResolve<S>> : T extends TRef<infer S extends TSchema> ? DerefResolve<S> : T;
20
- export declare function DerefResolve<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
21
- export type TDeref<T extends TSchema> = DerefResolve<T>;
19
+ export type TDeref<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<S>, TDeref<R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<S>, TDeref<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TFromRest<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TFromRest<S>> : T extends TObject<infer S extends TProperties> ? TObject<FromProperties<S>> : T extends TArray<infer S extends TSchema> ? TArray<TDeref<S>> : T extends TPromise<infer S extends TSchema> ? TPromise<TDeref<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<TDeref<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<TDeref<S>> : T extends TRef<infer S extends TSchema> ? TDeref<S> : T;
22
20
  /** `[Json]` Creates a dereferenced type */
23
21
  export declare function Deref<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
24
22
  export {};
@@ -77,7 +77,7 @@ function FromRef(schema, references) {
77
77
  return Deref(discard, references);
78
78
  }
79
79
  // prettier-ignore
80
- export function DerefResolve(schema, references) {
80
+ function DerefResolve(schema, references) {
81
81
  return (IsConstructor(schema) ? FromConstructor(schema, references) :
82
82
  IsFunction(schema) ? FromFunction(schema, references) :
83
83
  IsIntersect(schema) ? FromIntersect(schema, references) :
@@ -91,6 +91,9 @@ export function DerefResolve(schema, references) {
91
91
  IsRef(schema) ? FromRef(schema, references) :
92
92
  schema);
93
93
  }
94
+ // ------------------------------------------------------------------
95
+ // TDeref
96
+ // ------------------------------------------------------------------
94
97
  /** `[Json]` Creates a dereferenced type */
95
98
  export function Deref(schema, references) {
96
99
  return DerefResolve(CloneType(schema), CloneRest(references));
@@ -11,14 +11,11 @@ import { type TExcludeFromMappedResult } from './exclude-from-mapped-result.mjs'
11
11
  type TExcludeTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
12
12
  [K in T]: TLiteral<K>;
13
13
  }[T]>>>;
14
- type TExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (Exclude<Static<T>, Static<U>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
15
- type TExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
16
- [K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K];
14
+ type TExcludeTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (Exclude<Static<L>, Static<R>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
15
+ type TExcludeRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
16
+ [K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? never : L[K];
17
17
  }[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
18
- type TExcludeResolve<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? TExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? TExcludeArray<S, U> : T extends U ? TNever : T;
19
- export type TExclude<T extends TSchema, U extends TSchema> = TExcludeResolve<T, U>;
18
+ export type TExclude<L extends TSchema, R extends TSchema> = (L extends TMappedResult<L> ? TExcludeFromMappedResult<L, R> : L extends TTemplateLiteral ? TExcludeTemplateLiteral<L, R> : L extends TUnion<infer S> ? TExcludeRest<S, R> : L extends R ? TNever : L);
20
19
  /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
21
- export declare function Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
22
- /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
23
- export declare function Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
20
+ export declare function Exclude<L extends TSchema, R extends TSchema>(L: L, R: R, options?: SchemaOptions): TExclude<L, R>;
24
21
  export {};
@@ -8,24 +8,16 @@ import { ExcludeFromMappedResult } from './exclude-from-mapped-result.mjs';
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
10
  import { IsMappedResult, IsTemplateLiteral, IsUnion } from '../guard/type.mjs';
11
- // prettier-ignore
12
- function ExcludeResolve(L, R) {
13
- return (IsTemplateLiteral(L) ? ExcludeResolve(TemplateLiteralToUnion(L), R) :
14
- IsTemplateLiteral(R) ? ExcludeResolve(L, TemplateLiteralToUnion(R)) :
15
- IsUnion(L) ? (() => {
16
- const narrowed = L.anyOf.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
17
- return (narrowed.length === 1 ? narrowed[0] : Union(narrowed));
18
- })() :
19
- ExtendsCheck(L, R) !== ExtendsResult.False ? Never() :
20
- L);
11
+ function ExcludeRest(L, R) {
12
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
13
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
21
14
  }
22
15
  /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
23
- export function Exclude(unionType, excludedMembers, options = {}) {
24
- if (IsMappedResult(unionType)) {
25
- return ExcludeFromMappedResult(unionType, excludedMembers, options);
26
- }
27
- else {
28
- const E = ExcludeResolve(unionType, excludedMembers);
29
- return CloneType(E, options);
30
- }
16
+ export function Exclude(L, R, options = {}) {
17
+ // prettier-ignore
18
+ return CloneType((IsMappedResult(L) ? ExcludeFromMappedResult(L, R, options) :
19
+ IsTemplateLiteral(L) ? Exclude(TemplateLiteralToUnion(L), R) :
20
+ IsTemplateLiteral(R) ? Exclude(L, TemplateLiteralToUnion(R)) :
21
+ IsUnion(L) ? ExcludeRest(L.anyOf, R) :
22
+ ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L), options);
31
23
  }
@@ -5,19 +5,17 @@ import { type TTemplateLiteral } from '../template-literal/index.mjs';
5
5
  import { type TLiteral } from '../literal/index.mjs';
6
6
  import { type TUnion } from '../union/index.mjs';
7
7
  import { type Static } from '../static/index.mjs';
8
+ import { type TNever } from '../never/index.mjs';
8
9
  import { type TUnionEvaluated } from '../union/index.mjs';
9
10
  import { type TExtractFromMappedResult } from './extract-from-mapped-result.mjs';
10
- type TFromTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
11
+ type TExtractTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
11
12
  [K in T]: TLiteral<K>;
12
13
  }[T]>>>;
13
- type TFromTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extract<Static<T>, Static<U>> extends infer S ? TFromTemplateLiteralResult<Assert<S, string>> : never;
14
- type TFromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
15
- [K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? T[K] : never;
14
+ type TExtractTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = Extract<Static<L>, Static<R>> extends infer S ? TExtractTemplateLiteralResult<Assert<S, string>> : never;
15
+ type TExtractRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
16
+ [K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? L[K] : never;
16
17
  }[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
17
- type TExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? TFromTemplateLiteral<T, U> : T extends TUnion<infer S> ? TFromArray<S, U> : T);
18
- export type TExtract<T extends TSchema, U extends TSchema> = TExtractResolve<T, U>;
18
+ export type TExtract<L extends TSchema, U extends TSchema> = (L extends TMappedResult ? TExtractFromMappedResult<L, U> : L extends TTemplateLiteral ? TExtractTemplateLiteral<L, U> : L extends TUnion<infer S> ? TExtractRest<S, U> : L extends U ? L : TNever);
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 TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
21
- /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
22
- export declare function Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
20
+ export declare function Extract<L extends TSchema, R extends TSchema>(L: L, R: R, options?: SchemaOptions): TExtract<L, R>;
23
21
  export {};
@@ -8,24 +8,16 @@ import { ExtractFromMappedResult } from './extract-from-mapped-result.mjs';
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
10
10
  import { IsMappedResult, IsTemplateLiteral, IsUnion } from '../guard/type.mjs';
11
- // prettier-ignore
12
- function ExtractResolve(L, R) {
13
- return (IsTemplateLiteral(L) ? ExtractResolve(TemplateLiteralToUnion(L), R) :
14
- IsTemplateLiteral(R) ? ExtractResolve(L, TemplateLiteralToUnion(R)) :
15
- IsUnion(L) ? (() => {
16
- const narrowed = L.anyOf.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
17
- return (narrowed.length === 1 ? narrowed[0] : Union(narrowed));
18
- })() :
19
- ExtendsCheck(L, R) !== ExtendsResult.False ? L :
20
- Never());
11
+ function ExtractRest(L, R) {
12
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
13
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
21
14
  }
22
15
  /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
23
- export function Extract(type, union, options = {}) {
24
- if (IsMappedResult(type)) {
25
- return ExtractFromMappedResult(type, union, options);
26
- }
27
- else {
28
- const E = ExtractResolve(type, union);
29
- return CloneType(E, options);
30
- }
16
+ export function Extract(L, R, options = {}) {
17
+ // prettier-ignore
18
+ return CloneType((IsMappedResult(L) ? ExtractFromMappedResult(L, R, options) :
19
+ IsTemplateLiteral(L) ? Extract(TemplateLiteralToUnion(L), R) :
20
+ IsTemplateLiteral(R) ? Extract(L, TemplateLiteralToUnion(R)) :
21
+ IsUnion(L) ? ExtractRest(L.anyOf, R) :
22
+ ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never()), options);
31
23
  }
@@ -1,5 +1,5 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
- import type { Evaluate } from '../helpers/index.mjs';
2
+ import type { Ensure, Evaluate } from '../helpers/index.mjs';
3
3
  import type { TProperties } from '../object/index.mjs';
4
4
  import { type TIndex } from './indexed.mjs';
5
5
  import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
@@ -8,6 +8,6 @@ type TMappedIndexPropertyKey<T extends TSchema, K extends PropertyKey> = {
8
8
  };
9
9
  type TMappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedIndexPropertyKeys<T, R, Acc & TMappedIndexPropertyKey<T, L>> : Acc);
10
10
  type TMappedIndexProperties<T extends TSchema, K extends TMappedKey> = Evaluate<TMappedIndexPropertyKeys<T, K['keys']>>;
11
- export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>> = (TMappedResult<P>);
11
+ export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>> = (Ensure<TMappedResult<P>>);
12
12
  export declare function IndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
13
13
  export {};
@@ -13,7 +13,7 @@ import { type TUnionEvaluated } from '../union/index.mjs';
13
13
  import { type TIndexPropertyKeys } from './indexed-property-keys.mjs';
14
14
  import { type TIndexFromMappedKey } from './indexed-from-mapped-key.mjs';
15
15
  import { type TIndexFromMappedResult } from './indexed-from-mapped-result.mjs';
16
- type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TFromKey<L, K>, TSchema>]> : Acc);
16
+ type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TIndexFromPropertyKey<L, K>, TSchema>]> : Acc);
17
17
  type TFromIntersectRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? TFromIntersectRest<R, [...Acc]> : TFromIntersectRest<R, [...Acc, L]> : Acc);
18
18
  type TFromIntersect<T extends TSchema[], K extends PropertyKey> = (TIntersectEvaluated<TFromIntersectRest<TFromRest<T, K>>>);
19
19
  type TFromUnionRest<T extends TSchema[]> = T;
@@ -22,9 +22,11 @@ type TFromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T
22
22
  type TFromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
23
23
  type AssertPropertyKey<T> = Assert<T, string | number>;
24
24
  type TFromProperty<T extends TProperties, K extends PropertyKey> = (K extends keyof T ? T[K] : `${AssertPropertyKey<K>}` extends `${AssertPropertyKey<keyof T>}` ? T[AssertPropertyKey<K>] : TNever);
25
- type TFromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? TFromKey<S, K> : T extends TIntersect<infer S> ? TFromIntersect<S, K> : T extends TUnion<infer S> ? TFromUnion<S, K> : T extends TTuple<infer S> ? TFromTuple<S, K> : T extends TArray<infer S> ? TFromArray<S, K> : T extends TObject<infer S> ? TFromProperty<S, K> : TNever);
26
- type TFromKeys<T extends TSchema, K extends PropertyKey[], Acc extends TSchema[] = []> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TFromKeys<T, R, [...Acc, Assert<TFromKey<T, L>, TSchema>]> : Acc);
27
- type FromSchema<T extends TSchema, K extends PropertyKey[]> = (TUnionEvaluated<TFromKeys<T, K>>);
25
+ export type TIndexFromPropertyKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? TIndexFromPropertyKey<S, K> : T extends TIntersect<infer S> ? TFromIntersect<S, K> : T extends TUnion<infer S> ? TFromUnion<S, K> : T extends TTuple<infer S> ? TFromTuple<S, K> : T extends TArray<infer S> ? TFromArray<S, K> : T extends TObject<infer S> ? TFromProperty<S, K> : TNever);
26
+ export declare function IndexFromPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): TIndexFromPropertyKey<T, K>;
27
+ export type TIndexFromPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TSchema[] = []> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TIndexFromPropertyKeys<T, R, [...Acc, Assert<TIndexFromPropertyKey<T, L>, TSchema>]> : Acc);
28
+ export declare function IndexFromPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TIndexFromPropertyKeys<T, K>;
29
+ type FromSchema<T extends TSchema, K extends PropertyKey[]> = (TUnionEvaluated<TIndexFromPropertyKeys<T, K>>);
28
30
  declare function FromSchema<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromSchema<T, K>;
29
31
  export type TIndex<T extends TSchema, K extends PropertyKey[]> = (FromSchema<T, K>);
30
32
  /** `[Json]` Returns an Indexed property type for the given keys */
@@ -11,7 +11,7 @@ import { IndexFromMappedResult } from './indexed-from-mapped-result.mjs';
11
11
  import { IsArray, IsIntersect, IsObject, IsMappedKey, IsMappedResult, IsNever, IsSchema, IsTuple, IsUnion } from '../guard/type.mjs';
12
12
  // prettier-ignore
13
13
  function FromRest(T, K) {
14
- return T.map(L => FromKey(L, K));
14
+ return T.map(L => IndexFromPropertyKey(L, K));
15
15
  }
16
16
  // prettier-ignore
17
17
  function FromIntersectRest(T) {
@@ -46,7 +46,7 @@ function FromProperty(T, K) {
46
46
  return (K in T ? T[K] : Never());
47
47
  }
48
48
  // prettier-ignore
49
- function FromKey(T, K) {
49
+ export function IndexFromPropertyKey(T, K) {
50
50
  return (IsIntersect(T) ? FromIntersect(T.allOf, K) :
51
51
  IsUnion(T) ? FromUnion(T.anyOf, K) :
52
52
  IsTuple(T) ? FromTuple(T.items ?? [], K) :
@@ -55,12 +55,12 @@ function FromKey(T, K) {
55
55
  Never());
56
56
  }
57
57
  // prettier-ignore
58
- function FromKeys(T, K) {
59
- return K.map(L => FromKey(T, L));
58
+ export function IndexFromPropertyKeys(T, K) {
59
+ return K.map(L => IndexFromPropertyKey(T, L));
60
60
  }
61
61
  // prettier-ignore
62
62
  function FromSchema(T, K) {
63
- return (UnionEvaluated(FromKeys(T, K)));
63
+ return (UnionEvaluated(IndexFromPropertyKeys(T, K)));
64
64
  }
65
65
  /** `[Json]` Returns an Indexed property type for the given keys */
66
66
  export function Index(T, K, options = {}) {
@@ -1,11 +1,12 @@
1
1
  import type { SchemaOptions } from '../schema/index.mjs';
2
+ import type { Ensure, Evaluate } from '../helpers/index.mjs';
2
3
  import type { TProperties } from '../object/index.mjs';
3
4
  import { type TMappedResult } from '../mapped/index.mjs';
4
5
  import { type TKeyOf } from './keyof.mjs';
5
6
  type TFromProperties<K extends TProperties> = ({
6
7
  [K2 in keyof K]: TKeyOf<K[K2]>;
7
8
  });
8
- type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
9
- export type TKeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
9
+ type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
10
+ export type TKeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
10
11
  export declare function KeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
11
12
  export {};
@@ -7,10 +7,10 @@ import { type TNumber } from '../number/index.mjs';
7
7
  import { type TKeyOfPropertyKeys } from './keyof-property-keys.mjs';
8
8
  import { type TUnionEvaluated } from '../union/index.mjs';
9
9
  import { type TKeyOfFromMappedResult } from './keyof-from-mapped-result.mjs';
10
- type TFromPropertyKeys<T extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TFromPropertyKeys<R, [...Acc, TNumber]> : TFromPropertyKeys<R, [...Acc, TLiteral<Assert<L, TLiteralValue>>]> : Acc);
11
- export type TKeyOf<T extends TSchema, K extends PropertyKey[] = TKeyOfPropertyKeys<T>, S extends TSchema[] = TFromPropertyKeys<K>, U = TUnionEvaluated<S>> = (Ensure<U>);
10
+ export type TKeyOfPropertyKeysToRest<T extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TKeyOfPropertyKeysToRest<R, [...Acc, TNumber]> : TKeyOfPropertyKeysToRest<R, [...Acc, TLiteral<Assert<L, TLiteralValue>>]> : Acc);
11
+ export declare function KeyOfPropertyKeysToRest<T extends PropertyKey[]>(T: [...T]): TKeyOfPropertyKeysToRest<T>;
12
+ export type TKeyOf<T extends TSchema, K extends PropertyKey[] = TKeyOfPropertyKeys<T>, S extends TSchema[] = TKeyOfPropertyKeysToRest<K>, U = TUnionEvaluated<S>> = (Ensure<U>);
12
13
  /** `[Json]` Creates a KeyOf type */
13
14
  export declare function KeyOf<T extends TMappedResult>(T: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
14
15
  /** `[Json]` Creates a KeyOf type */
15
16
  export declare function KeyOf<T extends TSchema>(T: T, options?: SchemaOptions): TKeyOf<T>;
16
- export {};
@@ -9,7 +9,7 @@ import { KeyOfFromMappedResult } from './keyof-from-mapped-result.mjs';
9
9
  // ------------------------------------------------------------------
10
10
  import { IsMappedResult } from '../guard/type.mjs';
11
11
  // prettier-ignore
12
- function FromPropertyKeys(T) {
12
+ export function KeyOfPropertyKeysToRest(T) {
13
13
  return T.map(L => L === '[number]' ? Number() : Literal(L));
14
14
  }
15
15
  /** `[Json]` Creates a KeyOf type */
@@ -19,7 +19,7 @@ export function KeyOf(T, options = {}) {
19
19
  }
20
20
  else {
21
21
  const K = KeyOfPropertyKeys(T);
22
- const S = FromPropertyKeys(K);
22
+ const S = KeyOfPropertyKeysToRest(K);
23
23
  const U = UnionEvaluated(S);
24
24
  return CloneType(U, options);
25
25
  }
@@ -33,12 +33,12 @@ type FromProperties<K extends PropertyKey, T extends TProperties, R extends TPro
33
33
  declare function FromProperties<K extends PropertyKey, T extends TProperties>(K: K, T: T): FromProperties<K, T>;
34
34
  type FromSchemaType<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S> ? TReadonly<FromSchemaType<K, S>> : T extends TOptional<infer S> ? TOptional<FromSchemaType<K, S>> : T extends TMappedResult<infer P> ? TFromMappedResult<K, P> : T extends TMappedKey<infer P> ? TFromMappedKey<K, P> : T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<K, S>, FromSchemaType<K, R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<K, S>, FromSchemaType<K, R>> : T extends TAsyncIterator<infer S> ? TAsyncIterator<FromSchemaType<K, S>> : T extends TIterator<infer S> ? TIterator<FromSchemaType<K, S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<K, S>> : T extends TUnion<infer S> ? TUnion<TFromRest<K, S>> : T extends TTuple<infer S> ? TTuple<TFromRest<K, S>> : T extends TObject<infer S> ? TObject<FromProperties<K, S>> : T extends TArray<infer S> ? TArray<FromSchemaType<K, S>> : T extends TPromise<infer S> ? TPromise<FromSchemaType<K, S>> : T);
35
35
  declare function FromSchemaType<K extends PropertyKey, T extends TSchema>(K: K, T: T): FromSchemaType<K, T>;
36
- type FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? FromMappedFunctionReturnType<R, T, Acc & {
36
+ export type TMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedFunctionReturnType<R, T, Acc & {
37
37
  [_ in L]: FromSchemaType<L, T>;
38
38
  }> : Acc);
39
- declare function FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): FromMappedFunctionReturnType<K, T>;
39
+ export declare function MappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): TMappedFunctionReturnType<K, T>;
40
40
  export type TMappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;
41
- export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<FromMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
41
+ export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<TMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
42
42
  /** `[Json]` Creates a Mapped object type */
43
43
  export declare function Mapped<K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>, F extends TMappedFunction<I> = TMappedFunction<I>, R extends TMapped<I, F> = TMapped<I, F>>(key: K, map: F, options?: ObjectOptions): R;
44
44
  /** `[Json]` Creates a Mapped object type */
@@ -85,7 +85,7 @@ function FromSchemaType(K, T) {
85
85
  T);
86
86
  }
87
87
  // prettier-ignore
88
- function FromMappedFunctionReturnType(K, T, Acc = {}) {
88
+ export function MappedFunctionReturnType(K, T, Acc = {}) {
89
89
  return K.reduce((Acc, L) => {
90
90
  return { ...Acc, [L]: FromSchemaType(L, T) };
91
91
  }, {});
@@ -94,6 +94,6 @@ function FromMappedFunctionReturnType(K, T, Acc = {}) {
94
94
  export function Mapped(key, map, options = {}) {
95
95
  const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
96
96
  const RT = map({ [Kind]: 'MappedKey', keys: K });
97
- const R = FromMappedFunctionReturnType(K, RT);
97
+ const R = MappedFunctionReturnType(K, RT);
98
98
  return CloneType(Object(R), options);
99
99
  }
@@ -1,11 +1,12 @@
1
1
  import type { SchemaOptions } from '../schema/index.mjs';
2
+ import type { Ensure, Evaluate } from '../helpers/index.mjs';
2
3
  import type { TProperties } from '../object/index.mjs';
3
4
  import { type TMappedResult } from '../mapped/index.mjs';
4
5
  import { type TOmit } from './omit.mjs';
5
6
  type TFromProperties<P extends TProperties, K extends PropertyKey[]> = ({
6
7
  [K2 in keyof P]: TOmit<P[K2], K>;
7
8
  });
8
- type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (TFromProperties<R['properties'], K>);
9
- export type TOmitFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (TMappedResult<P>);
9
+ type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (Evaluate<TFromProperties<R['properties'], K>>);
10
+ export type TOmitFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (Ensure<TMappedResult<P>>);
10
11
  export declare function OmitFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options: SchemaOptions): TMappedResult<P>;
11
12
  export {};
@@ -8,12 +8,10 @@ import { type TObject, type TProperties } from '../object/index.mjs';
8
8
  import { type TIndexPropertyKeys } from '../indexed/index.mjs';
9
9
  import { type TOmitFromMappedKey } from './omit-from-mapped-key.mjs';
10
10
  import { type TOmitFromMappedResult } from './omit-from-mapped-result.mjs';
11
- type TFromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, K, [...Acc, TOmitResolve<L, K>]> : Acc);
12
- type TFromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, K, [...Acc, TOmitResolve<L, K>]> : Acc);
11
+ type TFromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, K, [...Acc, TOmit<L, K>]> : Acc);
12
+ type TFromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, K, [...Acc, TOmit<L, K>]> : Acc);
13
13
  type TFromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Omit<T, I>>;
14
- export type TOmitResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TOmitResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S, K>> : T extends TObject<infer S> ? TObject<TFromProperties<S, K>> : TObject<{}>;
15
- export declare function OmitResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TOmitResolve<T, K>;
16
- export type TOmit<T extends TSchema, K extends PropertyKey[]> = TOmitResolve<T, K>;
14
+ export type TOmit<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TOmit<S, K>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S, K>> : T extends TObject<infer S> ? TObject<TFromProperties<S, K>> : TObject<{}>;
17
15
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
18
16
  export declare function Omit<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TOmitFromMappedResult<T, K>;
19
17
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
@@ -33,8 +33,11 @@ function FromProperties(T, K) {
33
33
  return FromProperty(T, K2);
34
34
  }, T);
35
35
  }
36
+ // ------------------------------------------------------------------
37
+ // OmitResolve
38
+ // ------------------------------------------------------------------
36
39
  // prettier-ignore
37
- export function OmitResolve(T, K) {
40
+ function OmitResolve(T, K) {
38
41
  return (IsIntersect(T) ? Intersect(FromIntersect(T.allOf, K)) :
39
42
  IsUnion(T) ? Union(FromUnion(T.anyOf, K)) :
40
43
  IsObject(T) ? Object(FromProperties(T.properties, K)) :
@@ -1,11 +1,12 @@
1
1
  import type { SchemaOptions } from '../schema/index.mjs';
2
+ import type { Ensure, Evaluate } from '../helpers/index.mjs';
2
3
  import type { TProperties } from '../object/index.mjs';
3
4
  import { type TMappedResult } from '../mapped/index.mjs';
4
5
  import { type TPartial } from './partial.mjs';
5
6
  type TFromProperties<P extends TProperties> = ({
6
7
  [K2 in keyof P]: TPartial<P[K2]>;
7
8
  });
8
- type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
9
- export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
9
+ type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
10
+ export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
10
11
  export declare function PartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
11
12
  export {};
@@ -1,11 +1,12 @@
1
1
  import type { SchemaOptions } from '../schema/index.mjs';
2
+ import type { Ensure, Evaluate } from '../helpers/index.mjs';
2
3
  import type { TProperties } from '../object/index.mjs';
3
4
  import { type TMappedResult } from '../mapped/index.mjs';
4
5
  import { type TPick } from './pick.mjs';
5
6
  type TFromProperties<P extends TProperties, K extends PropertyKey[]> = ({
6
7
  [K2 in keyof P]: TPick<P[K2], K>;
7
8
  });
8
- type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (TFromProperties<R['properties'], K>);
9
- export type TPickFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (TMappedResult<P>);
9
+ type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (Evaluate<TFromProperties<R['properties'], K>>);
10
+ export type TPickFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (Ensure<TMappedResult<P>>);
10
11
  export declare function PickFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options: SchemaOptions): TMappedResult<P>;
11
12
  export {};