@sinclair/typebox 0.25.24 → 0.26.0-dev.1

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 (46) hide show
  1. package/compiler/compiler.d.ts +10 -5
  2. package/compiler/compiler.js +161 -123
  3. package/errors/errors.d.ts +56 -46
  4. package/errors/errors.js +234 -153
  5. package/package.json +1 -6
  6. package/readme.md +294 -207
  7. package/system/system.d.ts +9 -6
  8. package/system/system.js +17 -17
  9. package/typebox.d.ts +388 -162
  10. package/typebox.js +1716 -229
  11. package/value/cast.d.ts +2 -2
  12. package/value/cast.js +121 -188
  13. package/value/check.d.ts +1 -1
  14. package/value/check.js +156 -111
  15. package/value/convert.d.ts +13 -0
  16. package/value/convert.js +345 -0
  17. package/value/create.d.ts +6 -2
  18. package/value/create.js +149 -97
  19. package/{hash → value}/hash.js +39 -14
  20. package/value/index.d.ts +1 -0
  21. package/value/index.js +3 -1
  22. package/value/value.d.ts +2 -8
  23. package/value/value.js +20 -14
  24. package/conditional/conditional.d.ts +0 -17
  25. package/conditional/conditional.js +0 -91
  26. package/conditional/index.d.ts +0 -2
  27. package/conditional/index.js +0 -45
  28. package/conditional/structural.d.ts +0 -11
  29. package/conditional/structural.js +0 -685
  30. package/custom/custom.d.ts +0 -12
  31. package/custom/custom.js +0 -55
  32. package/custom/index.d.ts +0 -1
  33. package/custom/index.js +0 -44
  34. package/format/format.d.ts +0 -12
  35. package/format/format.js +0 -55
  36. package/format/index.d.ts +0 -1
  37. package/format/index.js +0 -44
  38. package/guard/extends.d.ts +0 -10
  39. package/guard/extends.js +0 -50
  40. package/guard/guard.d.ts +0 -60
  41. package/guard/guard.js +0 -440
  42. package/guard/index.d.ts +0 -2
  43. package/guard/index.js +0 -45
  44. package/hash/index.d.ts +0 -1
  45. package/hash/index.js +0 -44
  46. /package/{hash → value}/hash.d.ts +0 -0
package/typebox.d.ts CHANGED
@@ -1,6 +1,18 @@
1
1
  export declare const Kind: unique symbol;
2
2
  export declare const Hint: unique symbol;
3
3
  export declare const Modifier: unique symbol;
4
+ export type TupleToIntersect<T extends any[]> = T extends [infer I] ? I : T extends [infer I, ...infer R] ? I & TupleToIntersect<R> : never;
5
+ export type TupleToUnion<T extends any[]> = {
6
+ [K in keyof T]: T[K];
7
+ }[number];
8
+ export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
9
+ export type UnionLast<U> = UnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
10
+ export type UnionToTuple<U, L = UnionLast<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, L>>, L];
11
+ export type Assert<T, E> = T extends E ? T : never;
12
+ export type Evaluate<T> = T extends infer O ? {
13
+ [K in keyof O]: O[K];
14
+ } : never;
15
+ export type Ensure<T> = T extends infer U ? U : never;
4
16
  export type TModifier = TReadonlyOptional<TSchema> | TOptional<TSchema> | TReadonly<TSchema>;
5
17
  export type TReadonly<T extends TSchema> = T & {
6
18
  [Modifier]: 'Readonly';
@@ -14,33 +26,35 @@ export type TReadonlyOptional<T extends TSchema> = T & {
14
26
  export interface SchemaOptions {
15
27
  $schema?: string;
16
28
  /** Id for this schema */
17
- $id?: string;
29
+ readonly $id?: string;
18
30
  /** Title of this schema */
19
31
  title?: string;
20
32
  /** Description of this schema */
21
33
  description?: string;
22
34
  /** Default value for this schema */
23
35
  default?: any;
24
- /** Example values matching this schema. */
36
+ /** Example values matching this schema */
25
37
  examples?: any;
26
38
  [prop: string]: any;
27
39
  }
28
- export interface TSchema extends SchemaOptions {
40
+ export interface TKind {
29
41
  [Kind]: string;
42
+ }
43
+ export interface TSchema extends SchemaOptions, TKind {
30
44
  [Hint]?: string;
31
45
  [Modifier]?: string;
32
46
  params: unknown[];
33
47
  static: unknown;
34
48
  }
35
- export type TAnySchema = TSchema | TAny | TArray | TBoolean | TConstructor | TDate | TEnum | TFunction | TInteger | TLiteral | TNull | TNumber | TObject | TPromise | TRecord | TSelf | TRef | TString | TTuple | TUndefined | TUnion | TUint8Array | TUnknown | TVoid;
36
- export interface NumericOptions extends SchemaOptions {
37
- exclusiveMaximum?: number;
38
- exclusiveMinimum?: number;
39
- maximum?: number;
40
- minimum?: number;
41
- multipleOf?: number;
42
- }
49
+ export type TAnySchema = TSchema | TAny | TArray | TBigInt | TBoolean | TConstructor | TDate | TEnum | TFunction | TInteger | TIntersect | TLiteral | TNot | TNull | TNumber | TObject | TPromise | TRecord | TRef | TSelf | TString | TSymbol | TTuple | TUndefined | TUnion | TUint8Array | TUnknown | TVoid;
43
50
  export type TNumeric = TInteger | TNumber;
51
+ export interface NumericOptions<N extends number | bigint> extends SchemaOptions {
52
+ exclusiveMaximum?: N;
53
+ exclusiveMinimum?: N;
54
+ maximum?: N;
55
+ minimum?: N;
56
+ multipleOf?: N;
57
+ }
44
58
  export interface TAny extends TSchema {
45
59
  [Kind]: 'Any';
46
60
  static: any;
@@ -52,23 +66,38 @@ export interface ArrayOptions extends SchemaOptions {
52
66
  }
53
67
  export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
54
68
  [Kind]: 'Array';
55
- static: Array<Static<T, this['params']>>;
69
+ static: Static<T, this['params']>[];
56
70
  type: 'array';
57
71
  items: T;
58
72
  }
73
+ export interface TBigInt extends TSchema, NumericOptions<bigint> {
74
+ [Kind]: 'BigInt';
75
+ static: bigint;
76
+ type: 'null';
77
+ typeOf: 'BigInt';
78
+ }
59
79
  export interface TBoolean extends TSchema {
60
80
  [Kind]: 'Boolean';
61
81
  static: boolean;
62
82
  type: 'boolean';
63
83
  }
64
84
  export type TConstructorParameters<T extends TConstructor<TSchema[], TSchema>> = TTuple<T['parameters']>;
85
+ export type TDeref<T> = T extends TRef<infer U> ? TDeref<U> : T;
65
86
  export type TInstanceType<T extends TConstructor<TSchema[], TSchema>> = T['returns'];
66
- export type StaticContructorParameters<T extends readonly TSchema[], P extends unknown[]> = [...{
67
- [K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
87
+ export type TCompositeUnion<Left extends TSchema, Right extends TSchema> = Ensure<TUnion<[Left, Right]>>;
88
+ export type TCompositeMerge<T extends TObject, Output extends Record<any, TSchema>> = Evaluate<{
89
+ [Key in keyof T['properties']]: Key extends keyof Output ? TCompositeUnion<T['properties'][Key], Output[Key]> : T['properties'][Key];
90
+ } & {
91
+ [Key in keyof Output]: Key extends keyof T['properties'] ? TCompositeUnion<T['properties'][Key], Output[Key]> : Output[Key];
92
+ }>;
93
+ export type TCompositeReduce<T extends TObject[], Output extends {}> = T extends [infer L, ...infer R] ? TCompositeReduce<[...Assert<R, TObject[]>], TCompositeMerge<Assert<L, TObject>, Output>> : T extends [] ? Output : never;
94
+ export type TComposite<T extends TObject[]> = Ensure<TObject<TCompositeReduce<T, {}>>>;
95
+ export type TConstructorParameterArray<T extends readonly TSchema[], P extends unknown[]> = [...{
96
+ [K in keyof T]: Static<Assert<T[K], TSchema>, P>;
68
97
  }];
69
98
  export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
70
99
  [Kind]: 'Constructor';
71
- static: new (...param: StaticContructorParameters<T, this['params']>) => Static<U, this['params']>;
100
+ static: new (...param: TConstructorParameterArray<T, this['params']>) => Static<U, this['params']>;
72
101
  type: 'object';
73
102
  instanceOf: 'Constructor';
74
103
  parameters: T;
@@ -90,52 +119,60 @@ export interface TEnumOption<T> {
90
119
  type: 'number' | 'string';
91
120
  const: T;
92
121
  }
122
+ export type TEnumStatic<T extends Record<string, string | number>> = T[keyof T];
93
123
  export interface TEnum<T extends Record<string, string | number> = Record<string, string | number>> extends TSchema {
94
124
  [Kind]: 'Union';
95
- static: T[keyof T];
125
+ static: TEnumStatic<T>;
96
126
  anyOf: TLiteral<string | number>[];
97
127
  }
98
- export type TParameters<T extends TFunction> = TTuple<T['parameters']>;
99
- export type TReturnType<T extends TFunction> = T['returns'];
100
- export type StaticFunctionParameters<T extends readonly TSchema[], P extends unknown[]> = [...{
101
- [K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
128
+ export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = (Static<L> extends Static<R> ? T : U) extends infer O ? UnionToTuple<O> extends [infer X, infer Y] ? TUnion<[Assert<X, TSchema>, Assert<Y, TSchema>]> : Assert<O, TSchema> : never;
129
+ export type TExcludeArray<T extends TSchema[], U extends TSchema> = Assert<UnionToTuple<{
130
+ [K in keyof T]: Static<Assert<T[K], TSchema>> extends Static<U> ? never : T[K];
131
+ }[number]>, TSchema[]> extends infer R ? TExcludeResult<Assert<R, TSchema[]>> : never;
132
+ export type TExcludeResult<T extends TSchema[]> = T extends [] ? TNever : T extends [infer S] ? S : TUnion<T>;
133
+ export type TExclude<T extends TSchema, U extends TSchema> = T extends TUnion<infer S> ? TExcludeArray<S, U> : T extends U ? TNever : T;
134
+ export type TExtractArray<T extends TSchema[], U extends TSchema> = Assert<UnionToTuple<{
135
+ [K in keyof T]: Static<Assert<T[K], TSchema>> extends Static<U> ? T[K] : never;
136
+ }[number]>, TSchema[]> extends infer R ? TExtractResult<Assert<R, TSchema[]>> : never;
137
+ export type TExtractResult<T extends TSchema[]> = T extends [] ? TNever : T extends [infer S] ? S : TUnion<T>;
138
+ export type TExtract<T extends TSchema, U extends TSchema> = T extends TUnion<infer S> ? TExtractArray<S, U> : T extends U ? T : TNever;
139
+ export type TFunctionParameters<T extends readonly TSchema[], P extends unknown[]> = [...{
140
+ [K in keyof T]: Static<Assert<T[K], TSchema>, P>;
102
141
  }];
103
142
  export interface TFunction<T extends readonly TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
104
143
  [Kind]: 'Function';
105
- static: (...param: StaticFunctionParameters<T, this['params']>) => Static<U, this['params']>;
144
+ static: (...param: TFunctionParameters<T, this['params']>) => Static<U, this['params']>;
106
145
  type: 'object';
107
146
  instanceOf: 'Function';
108
147
  parameters: T;
109
148
  returns: U;
110
149
  }
111
- export interface TInteger extends TSchema, NumericOptions {
150
+ export interface TInteger extends TSchema, NumericOptions<number> {
112
151
  [Kind]: 'Integer';
113
152
  static: number;
114
153
  type: 'integer';
115
154
  }
116
- export type IntersectReduce<I extends unknown, T extends readonly any[]> = T extends [infer A, ...infer B] ? IntersectReduce<I & A, B> : I extends object ? I : {};
117
- export type IntersectEvaluate<T extends readonly TSchema[], P extends unknown[]> = {
118
- [K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
119
- };
120
- export type IntersectProperties<T extends readonly TObject[]> = {
121
- [K in keyof T]: T[K] extends TObject<infer P> ? P : {};
122
- };
123
- export interface TIntersect<T extends TObject[] = TObject[]> extends TObject {
124
- static: IntersectReduce<unknown, IntersectEvaluate<T, this['params']>>;
125
- properties: IntersectReduce<unknown, IntersectProperties<T>>;
155
+ export type TUnevaluatedProperties = undefined | TSchema | boolean;
156
+ export interface IntersectOptions extends SchemaOptions {
157
+ unevaluatedProperties?: TUnevaluatedProperties;
126
158
  }
127
- export type UnionToIntersect<U> = (U extends unknown ? (arg: U) => 0 : never) extends (arg: infer I) => 0 ? I : never;
128
- export type UnionLast<U> = UnionToIntersect<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
129
- export type UnionToTuple<U, L = UnionLast<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, L>>, L];
130
- export type UnionStringLiteralToTuple<T> = T extends TUnion<infer L> ? {
131
- [I in keyof L]: L[I] extends TLiteral<infer C> ? C : never;
132
- } : never;
133
- export type UnionLiteralsFromObject<T extends TObject> = {
134
- [K in ObjectPropertyKeys<T>]: TLiteral<K>;
135
- } extends infer R ? UnionToTuple<R[keyof R]> : never;
136
- export interface TKeyOf<T extends TObject> extends TUnion<UnionLiteralsFromObject<T>> {
137
- }
138
- export type TLiteralValue = string | number | boolean;
159
+ export type TIntersectStatic<T extends TSchema[], P extends unknown[]> = TupleToIntersect<{
160
+ [K in keyof T]: Static<Assert<T[K], TSchema>, P>;
161
+ }>;
162
+ export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
163
+ [Kind]: 'Intersect';
164
+ type?: 'object';
165
+ static: TIntersectStatic<T, this['params']>;
166
+ allOf: [...T];
167
+ }
168
+ export type TKeyOfTuple<T extends TSchema> = {
169
+ [K in keyof Static<T>]: TLiteral<Assert<K, TLiteralValue>>;
170
+ } extends infer U ? UnionToTuple<Exclude<{
171
+ [K in keyof U]: U[K];
172
+ }[keyof U], undefined>> : never;
173
+ export type TKeyOf<T extends TSchema = TSchema> = (T extends TIntersect ? TKeyOfTuple<T> : T extends TUnion ? TKeyOfTuple<T> : T extends TObject ? TKeyOfTuple<T> : [
174
+ ]) extends infer R ? R extends [] ? TNever : TUnion<Assert<R, TSchema[]>> : never;
175
+ export type TLiteralValue = string | number | boolean | bigint;
139
176
  export interface TLiteral<T extends TLiteralValue = TLiteralValue> extends TSchema {
140
177
  [Kind]: 'Literal';
141
178
  static: T;
@@ -152,12 +189,20 @@ export interface TNever extends TSchema {
152
189
  const: true;
153
190
  }];
154
191
  }
192
+ export type TNotStatic<_ extends TSchema = TSchema, T extends TSchema = TSchema> = Static<T>;
193
+ export interface TNot<Not extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
194
+ [Kind]: 'Not';
195
+ static: TNotStatic<Not, T>;
196
+ allOf: [{
197
+ not: Not;
198
+ }, T];
199
+ }
155
200
  export interface TNull extends TSchema {
156
201
  [Kind]: 'Null';
157
202
  static: null;
158
203
  type: 'null';
159
204
  }
160
- export interface TNumber extends TSchema, NumericOptions {
205
+ export interface TNumber extends TSchema, NumericOptions<number> {
161
206
  [Kind]: 'Number';
162
207
  static: number;
163
208
  type: 'number';
@@ -172,18 +217,11 @@ export type OptionalPropertyKeys<T extends TProperties> = {
172
217
  [K in keyof T]: T[K] extends TOptional<TSchema> ? K : never;
173
218
  }[keyof T];
174
219
  export type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
175
- export type PropertiesReducer<T extends TProperties, R extends Record<keyof any, unknown>> = (Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>) extends infer O ? {
176
- [K in keyof O]: O[K];
177
- } : never;
220
+ export type PropertiesReducer<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
178
221
  export type PropertiesReduce<T extends TProperties, P extends unknown[]> = PropertiesReducer<T, {
179
222
  [K in keyof T]: Static<T[K], P>;
180
223
  }>;
181
- export type TRecordProperties<K extends TUnion<TLiteral[]>, T extends TSchema> = Static<K> extends string ? {
182
- [X in Static<K>]: T;
183
- } : never;
184
- export interface TProperties {
185
- [key: string]: TSchema;
186
- }
224
+ export type TProperties = Record<keyof any, TSchema>;
187
225
  export type ObjectProperties<T> = T extends TObject<infer U> ? U : never;
188
226
  export type ObjectPropertyKeys<T> = T extends TObject<infer U> ? keyof U : never;
189
227
  export type TAdditionalProperties = undefined | TSchema | boolean;
@@ -200,30 +238,45 @@ export interface TObject<T extends TProperties = TProperties> extends TSchema, O
200
238
  properties: T;
201
239
  required?: string[];
202
240
  }
203
- export interface TOmit<T extends TObject, Properties extends ObjectPropertyKeys<T>[]> extends TObject, ObjectOptions {
204
- static: Omit<Static<T, this['params']>, Properties[number]>;
205
- properties: T extends TObject ? Omit<T['properties'], Properties[number]> : never;
206
- }
207
- export interface TPartial<T extends TObject> extends TObject {
208
- static: Partial<Static<T, this['params']>>;
209
- properties: {
210
- [K in keyof T['properties']]: T['properties'][K] extends TReadonlyOptional<infer U> ? TReadonlyOptional<U> : T['properties'][K] extends TReadonly<infer U> ? TReadonlyOptional<U> : T['properties'][K] extends TOptional<infer U> ? TOptional<U> : TOptional<T['properties'][K]>;
211
- };
212
- }
213
- export type TPick<T extends TObject, Properties extends ObjectPropertyKeys<T>[]> = TObject<{
214
- [K in Properties[number]]: T['properties'][K];
215
- }>;
241
+ export type TOmitArray<T extends TSchema[], K extends keyof any> = Assert<{
242
+ [K2 in keyof T]: TOmit<Assert<T[K2], TSchema>, K>;
243
+ }, TSchema[]>;
244
+ export type TOmitProperties<T extends TProperties, K extends keyof any> = Evaluate<Assert<Omit<T, K>, TProperties>>;
245
+ export type TOmit<T extends TSchema, K extends keyof any> = T extends TIntersect<infer S> ? TIntersect<TOmitArray<S, K>> : T extends TUnion<infer S> ? TUnion<TOmitArray<S, K>> : T extends TObject<infer S> ? TObject<TOmitProperties<S, K>> : T;
246
+ export type TParameters<T extends TFunction> = TTuple<T['parameters']>;
247
+ export type TPartialArray<T extends TSchema[]> = Assert<{
248
+ [K in keyof T]: TPartial<Assert<T[K], TSchema>>;
249
+ }, TSchema[]>;
250
+ export type TPartialProperties<T extends TProperties> = Evaluate<Assert<{
251
+ [K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonlyOptional<U> : T[K] extends TReadonly<infer U> ? TReadonlyOptional<U> : T[K] extends TOptional<infer U> ? TOptional<U> : TOptional<T[K]>;
252
+ }, TProperties>>;
253
+ export type TPartial<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TPartialArray<S>> : T extends TUnion<infer S> ? TUnion<TPartialArray<S>> : T extends TObject<infer S> ? TObject<TPartialProperties<S>> : T;
254
+ export type TPickArray<T extends TSchema[], K extends keyof any> = {
255
+ [K2 in keyof T]: TPick<Assert<T[K2], TSchema>, K>;
256
+ };
257
+ export type TPickProperties<T extends TProperties, K extends keyof any> = Pick<T, Assert<Extract<K, keyof T>, keyof T>> extends infer R ? ({
258
+ [K in keyof R]: Assert<R[K], TSchema> extends TSchema ? R[K] : never;
259
+ }) : never;
260
+ export type TPick<T extends TSchema, K extends keyof any> = T extends TIntersect<infer S> ? TIntersect<TPickArray<S, K>> : T extends TUnion<infer S> ? TUnion<TPickArray<S, K>> : T extends TObject<infer S> ? TObject<TPickProperties<S, K>> : T;
261
+ export type TPromiseStatic<T extends TSchema, P extends unknown[]> = Promise<Static<T, P>>;
216
262
  export interface TPromise<T extends TSchema = TSchema> extends TSchema {
217
263
  [Kind]: 'Promise';
218
- static: Promise<Static<T, this['params']>>;
264
+ static: TPromiseStatic<T, this['params']>;
219
265
  type: 'object';
220
266
  instanceOf: 'Promise';
221
267
  item: TSchema;
222
268
  }
223
269
  export type TRecordKey = TString | TNumeric | TUnion<TLiteral<any>[]>;
270
+ export type TRecordPropertiesFromUnionLiteral<K extends TUnion<TLiteral<string | number>[]>, T extends TSchema> = Static<K> extends string ? {
271
+ [X in Static<K>]: T;
272
+ } : never;
273
+ export type TRecordPropertiesFromLiteral<K extends TLiteral<string | number>, T extends TSchema> = Evaluate<{
274
+ [K2 in K['const']]: T;
275
+ }>;
276
+ export type TRecordStatic<K extends TRecordKey, T extends TSchema, P extends unknown[]> = Record<Static<K>, Static<T, P>>;
224
277
  export interface TRecord<K extends TRecordKey = TRecordKey, T extends TSchema = TSchema> extends TSchema {
225
278
  [Kind]: 'Record';
226
- static: Record<Static<K>, Static<T, this['params']>>;
279
+ static: TRecordStatic<K, T, this['params']>;
227
280
  type: 'object';
228
281
  patternProperties: {
229
282
  [pattern: string]: T;
@@ -239,17 +292,20 @@ export type TRecursiveReduce<T extends TSchema> = Static<T, [TRecursiveReduce<T>
239
292
  export interface TRecursive<T extends TSchema> extends TSchema {
240
293
  static: TRecursiveReduce<T>;
241
294
  }
295
+ export type TRefStatic<T extends TSchema, P extends unknown[]> = Static<T, P>;
242
296
  export interface TRef<T extends TSchema = TSchema> extends TSchema {
243
297
  [Kind]: 'Ref';
244
- static: Static<T, this['params']>;
298
+ static: TRefStatic<T, this['params']>;
245
299
  $ref: string;
246
300
  }
247
- export interface TRequired<T extends TObject | TRef<TObject>> extends TObject {
248
- static: Required<Static<T, this['params']>>;
249
- properties: {
250
- [K in keyof T['properties']]: T['properties'][K] extends TReadonlyOptional<infer U> ? TReadonly<U> : T['properties'][K] extends TReadonly<infer U> ? TReadonly<U> : T['properties'][K] extends TOptional<infer U> ? U : T['properties'][K];
251
- };
252
- }
301
+ export type TReturnType<T extends TFunction> = T['returns'];
302
+ export type TRequiredArray<T extends TSchema[]> = Assert<{
303
+ [K in keyof T]: TRequired<Assert<T[K], TSchema>>;
304
+ }, TSchema[]>;
305
+ export type TRequiredProperties<T extends TProperties> = Evaluate<Assert<{
306
+ [K in keyof T]: T[K] extends TReadonlyOptional<infer U> ? TReadonly<U> : T[K] extends TReadonly<infer U> ? TReadonly<U> : T[K] extends TOptional<infer U> ? U : T[K];
307
+ }, TProperties>>;
308
+ export type TRequired<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TRequiredArray<S>> : T extends TUnion<infer S> ? TUnion<TRequiredArray<S>> : T extends TObject<infer S> ? TObject<TRequiredProperties<S>> : T;
253
309
  export type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex';
254
310
  export interface StringOptions<Format extends string> extends SchemaOptions {
255
311
  minLength?: number;
@@ -264,12 +320,20 @@ export interface TString<Format extends string = string> extends TSchema, String
264
320
  static: string;
265
321
  type: 'string';
266
322
  }
267
- export type TupleToArray<T extends TTuple<TSchema[]>> = T extends TTuple<infer R> ? R : never;
323
+ export type SymbolValue = string | number | undefined;
324
+ export interface TSymbol extends TSchema, SchemaOptions {
325
+ [Kind]: 'Symbol';
326
+ static: symbol;
327
+ type: 'null';
328
+ typeOf: 'Symbol';
329
+ }
330
+ export type TTupleIntoArray<T extends TTuple<TSchema[]>> = T extends TTuple<infer R> ? Assert<R, TSchema[]> : never;
331
+ export type TTupleStatic<T extends TSchema[], P extends unknown[]> = {
332
+ [K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : T[K];
333
+ };
268
334
  export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
269
335
  [Kind]: 'Tuple';
270
- static: {
271
- [K in keyof T]: T[K] extends TSchema ? Static<T[K], this['params']> : T[K];
272
- };
336
+ static: TTupleStatic<T, this['params']>;
273
337
  type: 'array';
274
338
  items?: T;
275
339
  additionalItems?: false;
@@ -282,6 +346,10 @@ export interface TUndefined extends TSchema {
282
346
  type: 'null';
283
347
  typeOf: 'Undefined';
284
348
  }
349
+ export type TUnionOfLiteralArray<T extends TLiteral<string>[]> = {
350
+ [K in keyof T]: Assert<T[K], TLiteral>['const'];
351
+ }[number];
352
+ export type TUnionOfLiteral<T extends TUnion<TLiteral<string>[]>> = TUnionOfLiteralArray<T['anyOf']>;
285
353
  export interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
286
354
  [Kind]: 'Union';
287
355
  static: {
@@ -320,103 +388,261 @@ export interface TVoid extends TSchema {
320
388
  export type Static<T extends TSchema, P extends unknown[] = []> = (T & {
321
389
  params: P;
322
390
  })['static'];
391
+ export type TypeRegistryValidationFunction<TSchema> = (schema: TSchema, value: unknown) => boolean;
392
+ export declare namespace TypeRegistry {
393
+ /** Clears all user defined types */
394
+ function Clear(): void;
395
+ /** Returns true if this registry contains this kind */
396
+ function Has(kind: string): boolean;
397
+ /** Sets a validation function for a user defined type */
398
+ function Set<TSchema = unknown>(kind: string, func: TypeRegistryValidationFunction<TSchema>): void;
399
+ /** Gets a custom validation function for a user defined type */
400
+ function Get(kind: string): TypeRegistryValidationFunction<any> | undefined;
401
+ }
402
+ export declare namespace ReferenceRegistry {
403
+ /** Clears the reference registry */
404
+ function Clear(): void;
405
+ /** Returns true if this registry contains this schema */
406
+ function Has(schema: TSchema): boolean;
407
+ /** Sets this schema on this registry if a $id exists */
408
+ function Set(schema: TSchema): void;
409
+ /** Dereferences the schema one level deep */
410
+ function DerefOne(schema: TSchema): TSchema;
411
+ /** Dereferences the schema recursively */
412
+ function Deref(schema: TSchema): TSchema;
413
+ }
414
+ export type FormatRegistryValidationFunction = (value: string) => boolean;
415
+ /** Provides functions to create user defined string formats */
416
+ export declare namespace FormatRegistry {
417
+ /** Clears all user defined string formats */
418
+ function Clear(): void;
419
+ /** Returns true if the user defined string format exists */
420
+ function Has(format: string): boolean;
421
+ /** Sets a validation function for a user defined string format */
422
+ function Set(format: string, func: FormatRegistryValidationFunction): void;
423
+ /** Gets a validation function for a user defined string format */
424
+ function Get(format: string): FormatRegistryValidationFunction | undefined;
425
+ }
426
+ export declare class TypeGuardUnknownTypeError extends Error {
427
+ readonly schema: unknown;
428
+ constructor(schema: unknown);
429
+ }
430
+ export declare namespace TypeGuard {
431
+ /** Returns true if the given schema is TAny */
432
+ function TAny(schema: unknown): schema is TAny;
433
+ /** Returns true if the given schema is TArray */
434
+ function TArray(schema: unknown): schema is TArray;
435
+ /** Returns true if the given schema is TSymbol */
436
+ function TBigInt(schema: unknown): schema is TBigInt;
437
+ /** Returns true if the given schema is TBoolean */
438
+ function TBoolean(schema: unknown): schema is TBoolean;
439
+ /** Returns true if the given schema is TConstructor */
440
+ function TConstructor(schema: unknown): schema is TConstructor;
441
+ /** Returns true if the given schema is TDate */
442
+ function TDate(schema: unknown): schema is TDate;
443
+ /** Returns true if the given schema is TFunction */
444
+ function TFunction(schema: unknown): schema is TFunction;
445
+ /** Returns true if the given schema is TInteger */
446
+ function TInteger(schema: unknown): schema is TInteger;
447
+ /** Returns true if the given schema is TIntersect */
448
+ function TIntersect(schema: unknown): schema is TIntersect;
449
+ /** Returns true if the given schema is TKind */
450
+ function TKind(schema: unknown): schema is Record<typeof Kind | string, unknown>;
451
+ /** Returns true if the given schema is TLiteral */
452
+ function TLiteral(schema: unknown): schema is TLiteral;
453
+ /** Returns true if the given schema is TNever */
454
+ function TNever(schema: unknown): schema is TNever;
455
+ /** Returns true if the given schema is TNot */
456
+ function TNot(schema: unknown): schema is TNot;
457
+ /** Returns true if the given schema is TNull */
458
+ function TNull(schema: unknown): schema is TNull;
459
+ /** Returns true if the given schema is TNumber */
460
+ function TNumber(schema: unknown): schema is TNumber;
461
+ /** Returns true if the given schema is TObject */
462
+ function TObject(schema: unknown): schema is TObject;
463
+ /** Returns true if the given schema is TPromise */
464
+ function TPromise(schema: unknown): schema is TPromise;
465
+ /** Returns true if the given schema is TRecord */
466
+ function TRecord(schema: unknown): schema is TRecord;
467
+ /** Returns true if the given schema is TSelf */
468
+ function TSelf(schema: unknown): schema is TSelf;
469
+ /** Returns true if the given schema is TRef */
470
+ function TRef(schema: unknown): schema is TRef;
471
+ /** Returns true if the given schema is TString */
472
+ function TString(schema: unknown): schema is TString;
473
+ /** Returns true if the given schema is TSymbol */
474
+ function TSymbol(schema: unknown): schema is TSymbol;
475
+ /** Returns true if the given schema is TTuple */
476
+ function TTuple(schema: unknown): schema is TTuple;
477
+ /** Returns true if the given schema is TUndefined */
478
+ function TUndefined(schema: unknown): schema is TUndefined;
479
+ /** Returns true if the given schema is TUnion */
480
+ function TUnion(schema: unknown): schema is TUnion;
481
+ /** Returns true if the given schema is TUnion<Literal<string>[]> */
482
+ function TUnionLiteral(schema: unknown): schema is TUnion<TLiteral<string>[]>;
483
+ /** Returns true if the given schema is TUint8Array */
484
+ function TUint8Array(schema: unknown): schema is TUint8Array;
485
+ /** Returns true if the given schema is TUnknown */
486
+ function TUnknown(schema: unknown): schema is TUnknown;
487
+ /** Returns true if the given schema is TVoid */
488
+ function TVoid(schema: unknown): schema is TVoid;
489
+ /** Returns true if this schema has the ReadonlyOptional modifier */
490
+ function TReadonlyOptional<T extends TSchema>(schema: T): schema is TReadonlyOptional<T>;
491
+ /** Returns true if this schema has the Readonly modifier */
492
+ function TReadonly<T extends TSchema>(schema: T): schema is TReadonly<T>;
493
+ /** Returns true if this schema has the Optional modifier */
494
+ function TOptional<T extends TSchema>(schema: T): schema is TOptional<T>;
495
+ /** Returns true if the given schema is TSchema */
496
+ function TSchema(schema: unknown): schema is TSchema;
497
+ }
498
+ export declare namespace ExtendsUndefined {
499
+ /** Fast undefined check for properties of type undefined */
500
+ function Check(schema: TSchema): boolean;
501
+ }
502
+ export declare enum TypeExtendsResult {
503
+ Union = 0,
504
+ True = 1,
505
+ False = 2
506
+ }
507
+ export declare namespace TypeExtends {
508
+ function Extends(left: TSchema, right: TSchema): TypeExtendsResult;
509
+ }
510
+ /** Specialized Clone for Types. */
511
+ export declare namespace TypeClone {
512
+ function Clone<T extends TSchema | TProperties>(schema: T, options: SchemaOptions): T;
513
+ }
514
+ export declare namespace ObjectMap {
515
+ function Map<T = TSchema>(schema: TSchema, callback: (object: TObject) => TObject, options: SchemaOptions): T;
516
+ }
517
+ export declare namespace KeyResolver {
518
+ function Resolve<T extends TSchema>(schema: T): string[];
519
+ }
323
520
  export declare class TypeBuilder {
324
- /** Creates a readonly optional property */
325
- ReadonlyOptional<T extends TSchema>(item: T): TReadonlyOptional<T>;
326
- /** Creates a readonly property */
327
- Readonly<T extends TSchema>(item: T): TReadonly<T>;
328
- /** Creates a optional property */
329
- Optional<T extends TSchema>(item: T): TOptional<T>;
330
- /** `Standard` Creates a any type */
521
+ /** `[Utility]` Creates a schema without `static` and `params` types */
522
+ protected Create<T>(schema: Omit<T, 'static' | 'params'>): T;
523
+ /** `[Utility]` Clones a schema or properties object */
524
+ protected Clone<T extends TSchema | TProperties>(schema: T, options?: SchemaOptions): T;
525
+ /** `[Standard]` Omits compositing symbols from this schema */
526
+ Strict<T extends TSchema>(schema: T): T;
527
+ }
528
+ export declare class StandardTypeBuilder extends TypeBuilder {
529
+ /** `[Modifier]` Creates a Optional property */
530
+ Optional<T extends TSchema>(schema: T): TOptional<T>;
531
+ /** `[Modifier]` Creates a ReadonlyOptional property */
532
+ ReadonlyOptional<T extends TSchema>(schema: T): TReadonlyOptional<T>;
533
+ /** `[Modifier]` Creates a Readonly object or property */
534
+ Readonly<T extends TSchema>(schema: T): TReadonly<T>;
535
+ /** `[Standard]` Creates an Any type */
331
536
  Any(options?: SchemaOptions): TAny;
332
- /** `Standard` Creates a array type */
537
+ /** `[Standard]` Creates an Array type */
333
538
  Array<T extends TSchema>(items: T, options?: ArrayOptions): TArray<T>;
334
- /** `Standard` Creates a boolean type */
539
+ /** `[Standard]` Creates a Boolean type */
335
540
  Boolean(options?: SchemaOptions): TBoolean;
336
- /** `Extended` Creates a tuple type from this constructors parameters */
337
- ConstructorParameters<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
338
- /** `Extended` Creates a constructor type */
339
- Constructor<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TConstructor<TupleToArray<T>, U>;
340
- /** `Extended` Creates a constructor type */
341
- Constructor<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TConstructor<T, U>;
342
- /** `Extended` Creates a Date type */
343
- Date(options?: DateOptions): TDate;
344
- /** `Standard` Creates a enum type */
541
+ /** `[Standard]` Creates a Composite object type that will Union any overlapping properties of the given Object array */
542
+ Composite<T extends TObject[]>(schemas: [...T], options?: ObjectOptions): TComposite<T>;
543
+ /** `[Standard]` Dereferences the given TRef to its target type */
544
+ Deref<T extends TRef>(schema: T): TDeref<T>;
545
+ /** `[Standard]` Creates a Enum type */
345
546
  Enum<T extends Record<string, string | number>>(item: T, options?: SchemaOptions): TEnum<T>;
346
- /** `Extended` Creates a function type */
347
- Function<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TFunction<TupleToArray<T>, U>;
348
- /** `Extended` Creates a function type */
349
- Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
350
- /** `Extended` Creates a type from this constructors instance type */
351
- InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
352
- /** `Standard` Creates a integer type */
353
- Integer(options?: NumericOptions): TInteger;
354
- /** `Standard` Creates a intersect type. */
355
- Intersect<T extends TObject[]>(objects: [...T], options?: ObjectOptions): TIntersect<T>;
356
- /** `Standard` Creates a keyof type */
357
- KeyOf<T extends TObject>(object: T, options?: SchemaOptions): TKeyOf<T>;
358
- /** `Standard` Creates a literal type. */
547
+ /** `[Standard]` A conditional type expression that will return the true type if the left type extends the right */
548
+ Extends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(left: L, right: R, trueType: T, falseType: U, options?: SchemaOptions): TExtends<L, R, T, U>;
549
+ /** `[Standard]` Excludes from the left type any type that is not assignable to the right */
550
+ Exclude<L extends TSchema, R extends TSchema>(left: L, right: R, options?: SchemaOptions): TExclude<L, R>;
551
+ /** `[Standard]` Extracts from left left any type that is assignable to the right */
552
+ Extract<L extends TSchema, R extends TSchema>(left: L, right: R, options?: SchemaOptions): TExtract<L, R>;
553
+ /** `[Standard]` Creates an Integer type */
554
+ Integer(options?: NumericOptions<number>): TInteger;
555
+ /** `[Standard]` Creates a Intersect type */
556
+ Intersect(allOf: [], options?: SchemaOptions): TNever;
557
+ /** `[Standard]` Creates a Intersect type */
558
+ Intersect<T extends [TSchema]>(allOf: [...T], options?: SchemaOptions): T[0];
559
+ Intersect<T extends TSchema[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>;
560
+ /** `[Standard]` Creates a KeyOf type */
561
+ KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
562
+ /** `[Standard]` Creates a Literal type */
359
563
  Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
360
- /** `Standard` Creates a never type */
564
+ /** `[Standard]` Creates a Never type */
361
565
  Never(options?: SchemaOptions): TNever;
362
- /** `Standard` Creates a null type */
566
+ /** `[Standard]` Creates a Not type. The first argument is the disallowed type, the second is the allowed. */
567
+ Not<N extends TSchema, T extends TSchema>(not: N, schema: T, options?: SchemaOptions): TNot<N, T>;
568
+ /** `[Standard]` Creates a Null type */
363
569
  Null(options?: SchemaOptions): TNull;
364
- /** `Standard` Creates a number type */
365
- Number(options?: NumericOptions): TNumber;
366
- /** `Standard` Creates an object type */
570
+ /** `[Standard]` Creates a Number type */
571
+ Number(options?: NumericOptions<number>): TNumber;
572
+ /** `[Standard]` Creates an Object type */
367
573
  Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
368
- /** `Standard` Creates a new object type whose keys are omitted from the given source type */
369
- Omit<T extends TObject, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: ObjectOptions): TOmit<T, UnionStringLiteralToTuple<K>>;
370
- /** `Standard` Creates a new object type whose keys are omitted from the given source type */
371
- Omit<T extends TObject, K extends ObjectPropertyKeys<T>[]>(schema: T, keys: readonly [...K], options?: ObjectOptions): TOmit<T, K>;
372
- /** `Extended` Creates a tuple type from this functions parameters */
373
- Parameters<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TParameters<T>;
374
- /** `Standard` Creates an object type whose properties are all optional */
375
- Partial<T extends TObject>(schema: T, options?: ObjectOptions): TPartial<T>;
376
- /** `Standard` Creates a new object type whose keys are picked from the given source type */
377
- Pick<T extends TObject, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: ObjectOptions): TPick<T, UnionStringLiteralToTuple<K>>;
378
- /** `Standard` Creates a new object type whose keys are picked from the given source type */
379
- Pick<T extends TObject, K extends ObjectPropertyKeys<T>[]>(schema: T, keys: readonly [...K], options?: ObjectOptions): TPick<T, K>;
380
- /** `Extended` Creates a Promise type */
381
- Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
382
- /** `Standard` Creates an object whose properties are derived from the given string literal union. */
383
- Record<K extends TUnion<TLiteral[]>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordProperties<K, T>>;
384
- /** `Standard` Creates a record type */
574
+ /** `[Standard]` Creates a mapped type whose keys are omitted from the given type */
575
+ Omit<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TOmit<T, K[number]>;
576
+ /** `[Standard]` Creates a mapped type whose keys are omitted from the given type */
577
+ Omit<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TOmit<T, TUnionOfLiteral<K>>;
578
+ /** `[Standard]` Creates a mapped type where all properties are Optional */
579
+ Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
580
+ /** `[Standard]` Creates a mapped type whose keys are picked from the given type */
581
+ Pick<T extends TSchema, K extends (keyof Static<T>)[]>(schema: T, keys: readonly [...K], options?: SchemaOptions): TPick<T, K[number]>;
582
+ /** `[Standard]` Creates a mapped type whose keys are picked from the given type */
583
+ Pick<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(schema: T, keys: K, options?: SchemaOptions): TPick<T, TUnionOfLiteral<K>>;
584
+ /** `[Standard]` Creates an Object type from the given Literal Union */
585
+ Record<K extends TUnion<TLiteral<string | number>[]>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordPropertiesFromUnionLiteral<K, T>>;
586
+ /** `[Standard]` Creates an Object type from the given Literal Union */
587
+ Record<K extends TLiteral<string | number>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordPropertiesFromLiteral<K, T>>;
588
+ /** `[Standard]` Creates a Record type */
385
589
  Record<K extends TString | TNumeric, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecord<K, T>;
386
- /** `Standard` Creates recursive type */
590
+ /** `[Standard]` Creates a Recursive type */
387
591
  Recursive<T extends TSchema>(callback: (self: TSelf) => T, options?: SchemaOptions): TRecursive<T>;
388
- /** `Standard` Creates a reference type. The referenced type must contain a $id. */
592
+ /** `[Standard]` Creates a Ref type. The referenced type must contain a $id */
389
593
  Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>;
390
- /** `Standard` Creates a string type from a regular expression */
391
- RegEx(regex: RegExp, options?: SchemaOptions): TString;
392
- /** `Standard` Creates an object type whose properties are all required */
393
- Required<T extends TObject>(schema: T, options?: SchemaOptions): TRequired<T>;
394
- /** `Extended` Creates a type from this functions return type */
395
- ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
396
- /** Removes Kind and Modifier symbol property keys from this schema */
397
- Strict<T extends TSchema>(schema: T): T;
398
- /** `Standard` Creates a string type */
594
+ /** `[Standard]` Creates a mapped type where all properties are Required */
595
+ Required<T extends TSchema>(schema: T, options?: SchemaOptions): TRequired<T>;
596
+ /** `[Standard]` Creates a String type */
399
597
  String<Format extends string>(options?: StringOptions<StringFormatOption | Format>): TString<Format>;
400
- /** `Standard` Creates a tuple type */
598
+ /** `[Standard]` Creates a Tuple type */
401
599
  Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
402
- /** `Extended` Creates a undefined type */
403
- Undefined(options?: SchemaOptions): TUndefined;
404
- /** `Standard` Creates a union type */
405
- Union(items: [], options?: SchemaOptions): TNever;
406
- /** `Standard` Creates a union type */
407
- Union<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TUnion<T>;
408
- /** `Extended` Creates a Uint8Array type */
409
- Uint8Array(options?: Uint8ArrayOptions): TUint8Array;
410
- /** `Standard` Creates an unknown type */
600
+ /** `[Standard]` Creates a Union type */
601
+ Union(anyOf: [], options?: SchemaOptions): TNever;
602
+ /** `[Standard]` Creates a Union type */
603
+ Union<T extends [TSchema]>(anyOf: [...T], options?: SchemaOptions): T[0];
604
+ /** `[Standard]` Creates a Union type */
605
+ Union<T extends TSchema[]>(anyOf: [...T], options?: SchemaOptions): TUnion<T>;
606
+ /** `[Standard]` Creates an Unknown type */
411
607
  Unknown(options?: SchemaOptions): TUnknown;
412
- /** `Standard` Creates a user defined schema that infers as type T */
608
+ /** `[Standard]` Creates a Unsafe type that infers for the generic argument */
413
609
  Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>;
414
- /** `Extended` Creates a void type */
610
+ }
611
+ export declare class ExtendedTypeBuilder extends StandardTypeBuilder {
612
+ /** `[Extended]` Creates a BigInt type */
613
+ BigInt(options?: NumericOptions<bigint>): TBigInt;
614
+ /** `[Extended]` Extracts the ConstructorParameters from the given Constructor type */
615
+ ConstructorParameters<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
616
+ /** `[Extended]` Creates a Constructor type */
617
+ Constructor<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TConstructor<TTupleIntoArray<T>, U>;
618
+ /** `[Extended]` Creates a Constructor type */
619
+ Constructor<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TConstructor<T, U>;
620
+ /** `[Extended]` Creates a Date type */
621
+ Date(options?: DateOptions): TDate;
622
+ /** `[Extended]` Creates a Function type */
623
+ Function<T extends TTuple<TSchema[]>, U extends TSchema>(parameters: T, returns: U, options?: SchemaOptions): TFunction<TTupleIntoArray<T>, U>;
624
+ /** `[Extended]` Creates a Function type */
625
+ Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
626
+ /** `[Extended]` Extracts the InstanceType from the given Constructor */
627
+ InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
628
+ /** `[Extended]` Extracts the Parameters from the given Function type */
629
+ Parameters<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TParameters<T>;
630
+ /** `[Extended]` Creates a Promise type */
631
+ Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>;
632
+ /** `[Extended]` Creates a regular expression type */
633
+ RegEx(regex: RegExp, options?: SchemaOptions): TString;
634
+ /** `[Extended]` Extracts the ReturnType from the given Function */
635
+ ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
636
+ /** `[Extended]` Creates a Symbol type */
637
+ Symbol(options?: SchemaOptions): TSymbol;
638
+ /** `[Extended]` Creates a Undefined type */
639
+ Undefined(options?: SchemaOptions): TUndefined;
640
+ /** `[Extended]` Creates a Uint8Array type */
641
+ Uint8Array(options?: Uint8ArrayOptions): TUint8Array;
642
+ /** `[Extended]` Creates a Void type */
415
643
  Void(options?: SchemaOptions): TVoid;
416
- /** Use this function to return TSchema with static and params omitted */
417
- protected Create<T>(schema: Omit<T, 'static' | 'params'>): T;
418
- /** Clones the given value */
419
- protected Clone(value: any): any;
420
644
  }
421
- /** JSON Schema Type Builder with Static Type Resolution for TypeScript */
422
- export declare const Type: TypeBuilder;
645
+ /** JSON Schema TypeBuilder with Static Resolution for TypeScript */
646
+ export declare const StandardType: StandardTypeBuilder;
647
+ /** JSON Schema TypeBuilder with Static Resolution for TypeScript */
648
+ export declare const Type: ExtendedTypeBuilder;