@sinclair/typebox 0.22.0 → 0.22.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.
- package/package.json +1 -1
- package/typebox.d.ts +28 -28
package/package.json
CHANGED
package/typebox.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export declare type TNamespace<T extends TDefinitions> = {
|
|
|
71
71
|
$defs: T;
|
|
72
72
|
} & CustomOptions;
|
|
73
73
|
export interface TSchema {
|
|
74
|
-
|
|
74
|
+
$static: unknown;
|
|
75
75
|
}
|
|
76
76
|
export declare type TEnumType = Record<string, string | number>;
|
|
77
77
|
export declare type TKey = string | number | symbol;
|
|
@@ -85,7 +85,7 @@ export interface TProperties {
|
|
|
85
85
|
[key: string]: TSchema;
|
|
86
86
|
}
|
|
87
87
|
export interface TRecord<K extends TRecordKey, T extends TSchema> extends TSchema, ObjectOptions {
|
|
88
|
-
|
|
88
|
+
$static: StaticRecord<K, T>;
|
|
89
89
|
kind: typeof RecordKind;
|
|
90
90
|
type: 'object';
|
|
91
91
|
patternProperties: {
|
|
@@ -93,7 +93,7 @@ export interface TRecord<K extends TRecordKey, T extends TSchema> extends TSchem
|
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
export interface TTuple<T extends TSchema[]> extends TSchema, CustomOptions {
|
|
96
|
-
|
|
96
|
+
$static: StaticTuple<T>;
|
|
97
97
|
kind: typeof TupleKind;
|
|
98
98
|
type: 'array';
|
|
99
99
|
items?: T;
|
|
@@ -102,76 +102,76 @@ export interface TTuple<T extends TSchema[]> extends TSchema, CustomOptions {
|
|
|
102
102
|
maxItems: number;
|
|
103
103
|
}
|
|
104
104
|
export interface TObject<T extends TProperties> extends TSchema, ObjectOptions {
|
|
105
|
-
|
|
105
|
+
$static: StaticObject<T>;
|
|
106
106
|
kind: typeof ObjectKind;
|
|
107
107
|
type: 'object';
|
|
108
108
|
properties: T;
|
|
109
109
|
required?: string[];
|
|
110
110
|
}
|
|
111
111
|
export interface TUnion<T extends TSchema[]> extends TSchema, CustomOptions {
|
|
112
|
-
|
|
112
|
+
$static: StaticUnion<T>;
|
|
113
113
|
kind: typeof UnionKind;
|
|
114
114
|
anyOf: T;
|
|
115
115
|
}
|
|
116
116
|
export interface TIntersect<T extends TSchema[]> extends TSchema, IntersectOptions {
|
|
117
|
-
|
|
117
|
+
$static: StaticIntersect<T>;
|
|
118
118
|
kind: typeof IntersectKind;
|
|
119
119
|
type: 'object';
|
|
120
120
|
allOf: T;
|
|
121
121
|
}
|
|
122
122
|
export interface TKeyOf<T extends TKey[]> extends TSchema, CustomOptions {
|
|
123
|
-
|
|
123
|
+
$static: StaticKeyOf<T>;
|
|
124
124
|
kind: typeof KeyOfKind;
|
|
125
125
|
type: 'string';
|
|
126
126
|
enum: T;
|
|
127
127
|
}
|
|
128
128
|
export interface TArray<T extends TSchema> extends TSchema, ArrayOptions {
|
|
129
|
-
|
|
129
|
+
$static: StaticArray<T>;
|
|
130
130
|
kind: typeof ArrayKind;
|
|
131
131
|
type: 'array';
|
|
132
132
|
items: T;
|
|
133
133
|
}
|
|
134
134
|
export interface TLiteral<T extends TValue> extends TSchema, CustomOptions {
|
|
135
|
-
|
|
135
|
+
$static: StaticLiteral<T>;
|
|
136
136
|
kind: typeof LiteralKind;
|
|
137
137
|
const: T;
|
|
138
138
|
}
|
|
139
139
|
export interface TEnum<T extends TEnumKey[]> extends TSchema, CustomOptions {
|
|
140
|
-
|
|
140
|
+
$static: StaticEnum<T>;
|
|
141
141
|
kind: typeof EnumKind;
|
|
142
142
|
anyOf: T;
|
|
143
143
|
}
|
|
144
144
|
export interface TString extends TSchema, StringOptions<string> {
|
|
145
|
-
|
|
145
|
+
$static: string;
|
|
146
146
|
kind: typeof StringKind;
|
|
147
147
|
type: 'string';
|
|
148
148
|
}
|
|
149
149
|
export interface TNumber extends TSchema, NumberOptions {
|
|
150
|
-
|
|
150
|
+
$static: number;
|
|
151
151
|
kind: typeof NumberKind;
|
|
152
152
|
type: 'number';
|
|
153
153
|
}
|
|
154
154
|
export interface TInteger extends TSchema, NumberOptions {
|
|
155
|
-
|
|
155
|
+
$static: number;
|
|
156
156
|
kind: typeof IntegerKind;
|
|
157
157
|
type: 'integer';
|
|
158
158
|
}
|
|
159
159
|
export interface TBoolean extends TSchema, CustomOptions {
|
|
160
|
-
|
|
160
|
+
$static: boolean;
|
|
161
161
|
kind: typeof BooleanKind;
|
|
162
162
|
type: 'boolean';
|
|
163
163
|
}
|
|
164
164
|
export interface TNull extends TSchema, CustomOptions {
|
|
165
|
-
|
|
165
|
+
$static: null;
|
|
166
166
|
kind: typeof NullKind;
|
|
167
167
|
type: 'null';
|
|
168
168
|
}
|
|
169
169
|
export interface TUnknown extends TSchema, CustomOptions {
|
|
170
|
-
|
|
170
|
+
$static: unknown;
|
|
171
171
|
kind: typeof UnknownKind;
|
|
172
172
|
}
|
|
173
173
|
export interface TAny extends TSchema, CustomOptions {
|
|
174
|
-
|
|
174
|
+
$static: any;
|
|
175
175
|
kind: typeof AnyKind;
|
|
176
176
|
}
|
|
177
177
|
export declare const ConstructorKind: unique symbol;
|
|
@@ -180,32 +180,32 @@ export declare const PromiseKind: unique symbol;
|
|
|
180
180
|
export declare const UndefinedKind: unique symbol;
|
|
181
181
|
export declare const VoidKind: unique symbol;
|
|
182
182
|
export interface TConstructor<T extends TSchema[], U extends TSchema> extends TSchema, CustomOptions {
|
|
183
|
-
|
|
183
|
+
$static: StaticConstructor<T, U>;
|
|
184
184
|
kind: typeof ConstructorKind;
|
|
185
185
|
type: 'constructor';
|
|
186
186
|
arguments: TSchema[];
|
|
187
187
|
returns: TSchema;
|
|
188
188
|
}
|
|
189
189
|
export interface TFunction<T extends TSchema[], U extends TSchema> extends TSchema, CustomOptions {
|
|
190
|
-
|
|
190
|
+
$static: StaticFunction<T, U>;
|
|
191
191
|
kind: typeof FunctionKind;
|
|
192
192
|
type: 'function';
|
|
193
193
|
arguments: TSchema[];
|
|
194
194
|
returns: TSchema;
|
|
195
195
|
}
|
|
196
196
|
export interface TPromise<T extends TSchema> extends TSchema, CustomOptions {
|
|
197
|
-
|
|
197
|
+
$static: StaticPromise<T>;
|
|
198
198
|
kind: typeof PromiseKind;
|
|
199
199
|
type: 'promise';
|
|
200
200
|
item: TSchema;
|
|
201
201
|
}
|
|
202
202
|
export interface TUndefined extends TSchema, CustomOptions {
|
|
203
|
-
|
|
203
|
+
$static: undefined;
|
|
204
204
|
kind: typeof UndefinedKind;
|
|
205
205
|
type: 'undefined';
|
|
206
206
|
}
|
|
207
207
|
export interface TVoid extends TSchema, CustomOptions {
|
|
208
|
-
|
|
208
|
+
$static: void;
|
|
209
209
|
kind: typeof VoidKind;
|
|
210
210
|
type: 'void';
|
|
211
211
|
}
|
|
@@ -221,7 +221,7 @@ export declare type StaticOptionalPropertyKeys<T extends TProperties> = {
|
|
|
221
221
|
}[keyof T];
|
|
222
222
|
export declare type StaticRequiredPropertyKeys<T extends TProperties> = keyof Omit<T, StaticReadonlyOptionalPropertyKeys<T> | StaticReadonlyPropertyKeys<T> | StaticOptionalPropertyKeys<T>>;
|
|
223
223
|
export declare type StaticIntersectEvaluate<T extends readonly TSchema[]> = {
|
|
224
|
-
[K in keyof T]: Static<T[K]
|
|
224
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K]> : never;
|
|
225
225
|
};
|
|
226
226
|
export declare type StaticIntersectReduce<I extends unknown, T extends readonly any[]> = T extends [infer A, ...infer B] ? StaticIntersectReduce<I & A, B> : I;
|
|
227
227
|
export declare type StaticRequired<T extends TProperties> = {
|
|
@@ -239,15 +239,15 @@ export declare type StaticProperties<T extends TProperties> = {
|
|
|
239
239
|
} & {
|
|
240
240
|
[K in StaticRequiredPropertyKeys<T>]: Static<T[K]>;
|
|
241
241
|
};
|
|
242
|
-
export declare type StaticRecord<K extends TRecordKey, T extends TSchema> = K extends TString ? Record<string, Static<T>> : K extends TNumber ? Record<number, Static<T>> : K extends TKeyOf<TKey[]> ? Record<K['
|
|
242
|
+
export declare type StaticRecord<K extends TRecordKey, T extends TSchema> = K extends TString ? Record<string, Static<T>> : K extends TNumber ? Record<number, Static<T>> : K extends TKeyOf<TKey[]> ? Record<K['$static'], Static<T>> : K extends TUnion<TSchema[]> ? Record<K['$static'], Static<T>> : never;
|
|
243
243
|
export declare type StaticEnum<T> = T extends TEnumKey<infer U>[] ? U : never;
|
|
244
244
|
export declare type StaticKeyOf<T extends TKey[]> = T extends Array<infer K> ? K : never;
|
|
245
245
|
export declare type StaticIntersect<T extends readonly TSchema[]> = StaticIntersectReduce<unknown, StaticIntersectEvaluate<T>>;
|
|
246
246
|
export declare type StaticUnion<T extends readonly TSchema[]> = {
|
|
247
|
-
[K in keyof T]: Static<T[K]
|
|
247
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K]> : never;
|
|
248
248
|
}[number];
|
|
249
249
|
export declare type StaticTuple<T extends readonly TSchema[]> = {
|
|
250
|
-
[K in keyof T]: Static<T[K]
|
|
250
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K]> : never;
|
|
251
251
|
};
|
|
252
252
|
export declare type StaticObject<T extends TProperties> = StaticProperties<T> extends infer I ? {
|
|
253
253
|
[K in keyof I]: I[K];
|
|
@@ -255,12 +255,12 @@ export declare type StaticObject<T extends TProperties> = StaticProperties<T> ex
|
|
|
255
255
|
export declare type StaticArray<T extends TSchema> = Array<Static<T>>;
|
|
256
256
|
export declare type StaticLiteral<T extends TValue> = T;
|
|
257
257
|
export declare type StaticParameters<T extends readonly TSchema[]> = {
|
|
258
|
-
[K in keyof T]: Static<T[K]
|
|
258
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K]> : never;
|
|
259
259
|
};
|
|
260
260
|
export declare type StaticConstructor<T extends readonly TSchema[], U extends TSchema> = new (...args: [...StaticParameters<T>]) => Static<U>;
|
|
261
261
|
export declare type StaticFunction<T extends readonly TSchema[], U extends TSchema> = (...args: [...StaticParameters<T>]) => Static<U>;
|
|
262
262
|
export declare type StaticPromise<T extends TSchema> = Promise<Static<T>>;
|
|
263
|
-
export declare type Static<T
|
|
263
|
+
export declare type Static<T extends TSchema> = T['$static'];
|
|
264
264
|
export declare class TypeBuilder {
|
|
265
265
|
/** `Standard` Modifies an object property to be both readonly and optional */
|
|
266
266
|
ReadonlyOptional<T extends TSchema>(item: T): TReadonlyOptional<T>;
|