@sinclair/typebox 0.33.14 → 0.33.16

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.
@@ -72,6 +72,7 @@ export interface ValueError {
72
72
  path: string;
73
73
  value: unknown;
74
74
  message: string;
75
+ errors: ValueErrorIterator[];
75
76
  }
76
77
  export declare class ValueErrorsUnknownTypeError extends TypeBoxError {
77
78
  readonly schema: TSchema;
@@ -11,13 +11,14 @@ const function_1 = require("./function");
11
11
  const index_4 = require("../type/error/index");
12
12
  const index_5 = require("../value/deref/index");
13
13
  const index_6 = require("../value/hash/index");
14
- const index_7 = require("../type/symbols/index");
15
- const index_8 = require("../type/never/index");
14
+ const index_7 = require("../value/check/index");
15
+ const index_8 = require("../type/symbols/index");
16
+ const index_9 = require("../type/never/index");
16
17
  // ------------------------------------------------------------------
17
18
  // ValueGuard
18
19
  // ------------------------------------------------------------------
19
20
  // prettier-ignore
20
- const index_9 = require("../value/guard/index");
21
+ const index_10 = require("../value/guard/index");
21
22
  // ------------------------------------------------------------------
22
23
  // ValueErrorType
23
24
  // ------------------------------------------------------------------
@@ -130,15 +131,22 @@ exports.ValueErrorIterator = ValueErrorIterator;
130
131
  // --------------------------------------------------------------------------
131
132
  // Create
132
133
  // --------------------------------------------------------------------------
133
- function Create(errorType, schema, path, value) {
134
- return { type: errorType, schema, path, value, message: (0, function_1.GetErrorFunction)()({ errorType, path, schema, value }) };
134
+ function Create(errorType, schema, path, value, errors = []) {
135
+ return {
136
+ type: errorType,
137
+ schema,
138
+ path,
139
+ value,
140
+ message: (0, function_1.GetErrorFunction)()({ errorType, path, schema, value, errors }),
141
+ errors,
142
+ };
135
143
  }
136
144
  // --------------------------------------------------------------------------
137
145
  // Types
138
146
  // --------------------------------------------------------------------------
139
147
  function* FromAny(schema, references, path, value) { }
140
148
  function* FromArray(schema, references, path, value) {
141
- if (!(0, index_9.IsArray)(value)) {
149
+ if (!(0, index_10.IsArray)(value)) {
142
150
  return yield Create(ValueErrorType.Array, schema, path, value);
143
151
  }
144
152
  if (IsDefined(schema.minItems) && !(value.length >= schema.minItems)) {
@@ -166,24 +174,24 @@ function* FromArray(schema, references, path, value) {
166
174
  if (!(IsDefined(schema.contains) || IsDefined(schema.minContains) || IsDefined(schema.maxContains))) {
167
175
  return;
168
176
  }
169
- const containsSchema = IsDefined(schema.contains) ? schema.contains : (0, index_8.Never)();
177
+ const containsSchema = IsDefined(schema.contains) ? schema.contains : (0, index_9.Never)();
170
178
  const containsCount = value.reduce((acc, value, index) => (Visit(containsSchema, references, `${path}${index}`, value).next().done === true ? acc + 1 : acc), 0);
171
179
  if (containsCount === 0) {
172
180
  yield Create(ValueErrorType.ArrayContains, schema, path, value);
173
181
  }
174
- if ((0, index_9.IsNumber)(schema.minContains) && containsCount < schema.minContains) {
182
+ if ((0, index_10.IsNumber)(schema.minContains) && containsCount < schema.minContains) {
175
183
  yield Create(ValueErrorType.ArrayMinContains, schema, path, value);
176
184
  }
177
- if ((0, index_9.IsNumber)(schema.maxContains) && containsCount > schema.maxContains) {
185
+ if ((0, index_10.IsNumber)(schema.maxContains) && containsCount > schema.maxContains) {
178
186
  yield Create(ValueErrorType.ArrayMaxContains, schema, path, value);
179
187
  }
180
188
  }
181
189
  function* FromAsyncIterator(schema, references, path, value) {
182
- if (!(0, index_9.IsAsyncIterator)(value))
190
+ if (!(0, index_10.IsAsyncIterator)(value))
183
191
  yield Create(ValueErrorType.AsyncIterator, schema, path, value);
184
192
  }
185
193
  function* FromBigInt(schema, references, path, value) {
186
- if (!(0, index_9.IsBigInt)(value))
194
+ if (!(0, index_10.IsBigInt)(value))
187
195
  return yield Create(ValueErrorType.BigInt, schema, path, value);
188
196
  if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
189
197
  yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path, value);
@@ -202,14 +210,14 @@ function* FromBigInt(schema, references, path, value) {
202
210
  }
203
211
  }
204
212
  function* FromBoolean(schema, references, path, value) {
205
- if (!(0, index_9.IsBoolean)(value))
213
+ if (!(0, index_10.IsBoolean)(value))
206
214
  yield Create(ValueErrorType.Boolean, schema, path, value);
207
215
  }
208
216
  function* FromConstructor(schema, references, path, value) {
209
217
  yield* Visit(schema.returns, references, path, value.prototype);
210
218
  }
211
219
  function* FromDate(schema, references, path, value) {
212
- if (!(0, index_9.IsDate)(value))
220
+ if (!(0, index_10.IsDate)(value))
213
221
  return yield Create(ValueErrorType.Date, schema, path, value);
214
222
  if (IsDefined(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
215
223
  yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path, value);
@@ -228,11 +236,11 @@ function* FromDate(schema, references, path, value) {
228
236
  }
229
237
  }
230
238
  function* FromFunction(schema, references, path, value) {
231
- if (!(0, index_9.IsFunction)(value))
239
+ if (!(0, index_10.IsFunction)(value))
232
240
  yield Create(ValueErrorType.Function, schema, path, value);
233
241
  }
234
242
  function* FromInteger(schema, references, path, value) {
235
- if (!(0, index_9.IsInteger)(value))
243
+ if (!(0, index_10.IsInteger)(value))
236
244
  return yield Create(ValueErrorType.Integer, schema, path, value);
237
245
  if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
238
246
  yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path, value);
@@ -281,7 +289,7 @@ function* FromIntersect(schema, references, path, value) {
281
289
  }
282
290
  }
283
291
  function* FromIterator(schema, references, path, value) {
284
- if (!(0, index_9.IsIterator)(value))
292
+ if (!(0, index_10.IsIterator)(value))
285
293
  yield Create(ValueErrorType.Iterator, schema, path, value);
286
294
  }
287
295
  function* FromLiteral(schema, references, path, value) {
@@ -296,7 +304,7 @@ function* FromNot(schema, references, path, value) {
296
304
  yield Create(ValueErrorType.Not, schema, path, value);
297
305
  }
298
306
  function* FromNull(schema, references, path, value) {
299
- if (!(0, index_9.IsNull)(value))
307
+ if (!(0, index_10.IsNull)(value))
300
308
  yield Create(ValueErrorType.Null, schema, path, value);
301
309
  }
302
310
  function* FromNumber(schema, references, path, value) {
@@ -365,7 +373,7 @@ function* FromObject(schema, references, path, value) {
365
373
  }
366
374
  }
367
375
  function* FromPromise(schema, references, path, value) {
368
- if (!(0, index_9.IsPromise)(value))
376
+ if (!(0, index_10.IsPromise)(value))
369
377
  yield Create(ValueErrorType.Promise, schema, path, value);
370
378
  }
371
379
  function* FromRecord(schema, references, path, value) {
@@ -401,7 +409,7 @@ function* FromRef(schema, references, path, value) {
401
409
  yield* Visit((0, index_5.Deref)(schema, references), references, path, value);
402
410
  }
403
411
  function* FromRegExp(schema, references, path, value) {
404
- if (!(0, index_9.IsString)(value))
412
+ if (!(0, index_10.IsString)(value))
405
413
  return yield Create(ValueErrorType.String, schema, path, value);
406
414
  if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) {
407
415
  yield Create(ValueErrorType.StringMinLength, schema, path, value);
@@ -415,7 +423,7 @@ function* FromRegExp(schema, references, path, value) {
415
423
  }
416
424
  }
417
425
  function* FromString(schema, references, path, value) {
418
- if (!(0, index_9.IsString)(value))
426
+ if (!(0, index_10.IsString)(value))
419
427
  return yield Create(ValueErrorType.String, schema, path, value);
420
428
  if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) {
421
429
  yield Create(ValueErrorType.StringMinLength, schema, path, value);
@@ -423,13 +431,13 @@ function* FromString(schema, references, path, value) {
423
431
  if (IsDefined(schema.maxLength) && !(value.length <= schema.maxLength)) {
424
432
  yield Create(ValueErrorType.StringMaxLength, schema, path, value);
425
433
  }
426
- if ((0, index_9.IsString)(schema.pattern)) {
434
+ if ((0, index_10.IsString)(schema.pattern)) {
427
435
  const regex = new RegExp(schema.pattern);
428
436
  if (!regex.test(value)) {
429
437
  yield Create(ValueErrorType.StringPattern, schema, path, value);
430
438
  }
431
439
  }
432
- if ((0, index_9.IsString)(schema.format)) {
440
+ if ((0, index_10.IsString)(schema.format)) {
433
441
  if (!index_3.FormatRegistry.Has(schema.format)) {
434
442
  yield Create(ValueErrorType.StringFormatUnknown, schema, path, value);
435
443
  }
@@ -442,11 +450,11 @@ function* FromString(schema, references, path, value) {
442
450
  }
443
451
  }
444
452
  function* FromSymbol(schema, references, path, value) {
445
- if (!(0, index_9.IsSymbol)(value))
453
+ if (!(0, index_10.IsSymbol)(value))
446
454
  yield Create(ValueErrorType.Symbol, schema, path, value);
447
455
  }
448
456
  function* FromTemplateLiteral(schema, references, path, value) {
449
- if (!(0, index_9.IsString)(value))
457
+ if (!(0, index_10.IsString)(value))
450
458
  return yield Create(ValueErrorType.String, schema, path, value);
451
459
  const regex = new RegExp(schema.pattern);
452
460
  if (!regex.test(value)) {
@@ -457,7 +465,7 @@ function* FromThis(schema, references, path, value) {
457
465
  yield* Visit((0, index_5.Deref)(schema, references), references, path, value);
458
466
  }
459
467
  function* FromTuple(schema, references, path, value) {
460
- if (!(0, index_9.IsArray)(value))
468
+ if (!(0, index_10.IsArray)(value))
461
469
  return yield Create(ValueErrorType.Tuple, schema, path, value);
462
470
  if (schema.items === undefined && !(value.length === 0)) {
463
471
  return yield Create(ValueErrorType.TupleLength, schema, path, value);
@@ -473,23 +481,17 @@ function* FromTuple(schema, references, path, value) {
473
481
  }
474
482
  }
475
483
  function* FromUndefined(schema, references, path, value) {
476
- if (!(0, index_9.IsUndefined)(value))
484
+ if (!(0, index_10.IsUndefined)(value))
477
485
  yield Create(ValueErrorType.Undefined, schema, path, value);
478
486
  }
479
487
  function* FromUnion(schema, references, path, value) {
480
- let count = 0;
481
- for (const subschema of schema.anyOf) {
482
- const errors = [...Visit(subschema, references, path, value)];
483
- if (errors.length === 0)
484
- return; // matched
485
- count += errors.length;
486
- }
487
- if (count > 0) {
488
- yield Create(ValueErrorType.Union, schema, path, value);
489
- }
488
+ if ((0, index_7.Check)(schema, references, value))
489
+ return;
490
+ const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit(variant, references, path, value)));
491
+ yield Create(ValueErrorType.Union, schema, path, value, errors);
490
492
  }
491
493
  function* FromUint8Array(schema, references, path, value) {
492
- if (!(0, index_9.IsUint8Array)(value))
494
+ if (!(0, index_10.IsUint8Array)(value))
493
495
  return yield Create(ValueErrorType.Uint8Array, schema, path, value);
494
496
  if (IsDefined(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
495
497
  yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path, value);
@@ -504,14 +506,14 @@ function* FromVoid(schema, references, path, value) {
504
506
  yield Create(ValueErrorType.Void, schema, path, value);
505
507
  }
506
508
  function* FromKind(schema, references, path, value) {
507
- const check = index_3.TypeRegistry.Get(schema[index_7.Kind]);
509
+ const check = index_3.TypeRegistry.Get(schema[index_8.Kind]);
508
510
  if (!check(schema, value))
509
511
  yield Create(ValueErrorType.Kind, schema, path, value);
510
512
  }
511
513
  function* Visit(schema, references, path, value) {
512
514
  const references_ = IsDefined(schema.$id) ? [...references, schema] : references;
513
515
  const schema_ = schema;
514
- switch (schema_[index_7.Kind]) {
516
+ switch (schema_[index_8.Kind]) {
515
517
  case 'Any':
516
518
  return yield* FromAny(schema_, references_, path, value);
517
519
  case 'Array':
@@ -575,7 +577,7 @@ function* Visit(schema, references, path, value) {
575
577
  case 'Void':
576
578
  return yield* FromVoid(schema_, references_, path, value);
577
579
  default:
578
- if (!index_3.TypeRegistry.Has(schema_[index_7.Kind]))
580
+ if (!index_3.TypeRegistry.Has(schema_[index_8.Kind]))
579
581
  throw new ValueErrorsUnknownTypeError(schema);
580
582
  return yield* FromKind(schema_, references_, path, value);
581
583
  }
@@ -1,5 +1,5 @@
1
1
  import { TSchema } from '../type/schema/index';
2
- import { ValueErrorType } from './errors';
2
+ import { ValueErrorIterator, ValueErrorType } from './errors';
3
3
  /** Creates an error message using en-US as the default locale */
4
4
  export declare function DefaultErrorFunction(error: ErrorFunctionParameter): string;
5
5
  export type ErrorFunctionParameter = {
@@ -11,6 +11,8 @@ export type ErrorFunctionParameter = {
11
11
  schema: TSchema;
12
12
  /** The value associated with the error */
13
13
  value: unknown;
14
+ /** Interior errors for this error */
15
+ errors: ValueErrorIterator[];
14
16
  };
15
17
  export type ErrorFunction = (parameter: ErrorFunctionParameter) => string;
16
18
  /** Sets the error function used to generate error messages. */
@@ -1,3 +1,7 @@
1
+ /** Returns true if this value has this property key */
2
+ export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is Record<PropertyKey, unknown> & {
3
+ [_ in K]: unknown;
4
+ };
1
5
  /** Returns true if this value is an async iterator */
2
6
  export declare function IsAsyncIterator(value: unknown): value is AsyncIterableIterator<unknown>;
3
7
  /** Returns true if this value is an array */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.HasPropertyKey = HasPropertyKey;
4
5
  exports.IsAsyncIterator = IsAsyncIterator;
5
6
  exports.IsArray = IsArray;
6
7
  exports.IsBigInt = IsBigInt;
@@ -17,6 +18,13 @@ exports.IsSymbol = IsSymbol;
17
18
  exports.IsUint8Array = IsUint8Array;
18
19
  exports.IsUndefined = IsUndefined;
19
20
  // --------------------------------------------------------------------------
21
+ // PropertyKey
22
+ // --------------------------------------------------------------------------
23
+ /** Returns true if this value has this property key */
24
+ function HasPropertyKey(value, key) {
25
+ return key in value;
26
+ }
27
+ // --------------------------------------------------------------------------
20
28
  // Object Instances
21
29
  // --------------------------------------------------------------------------
22
30
  /** Returns true if this value is an async iterator */
@@ -40,6 +40,10 @@ function FromArray(schema, references, value) {
40
40
  }
41
41
  return defaulted;
42
42
  }
43
+ function FromDate(schema, references, value) {
44
+ // special case intercept for dates
45
+ return (0, index_5.IsDate)(value) ? value : ValueOrDefault(schema, value);
46
+ }
43
47
  function FromIntersect(schema, references, value) {
44
48
  const defaulted = ValueOrDefault(schema, value);
45
49
  return schema.allOf.reduce((acc, schema) => {
@@ -131,6 +135,8 @@ function Visit(schema, references, value) {
131
135
  switch (schema_[index_4.Kind]) {
132
136
  case 'Array':
133
137
  return FromArray(schema_, references_, value);
138
+ case 'Date':
139
+ return FromDate(schema_, references_, value);
134
140
  case 'Intersect':
135
141
  return FromIntersect(schema_, references_, value);
136
142
  case 'Object':
@@ -45,7 +45,9 @@ export declare function IsBigInt64Array(value: unknown): value is BigInt64Array;
45
45
  /** Returns true if the value is a BigUint64Array */
46
46
  export declare function IsBigUint64Array(value: unknown): value is BigUint64Array;
47
47
  /** Returns true if this value has this property key */
48
- export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is ObjectType & Record<K, unknown>;
48
+ export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is Record<PropertyKey, unknown> & {
49
+ [_ in K]: unknown;
50
+ };
49
51
  /** Returns true of this value is an object type */
50
52
  export declare function IsObject(value: unknown): value is ObjectType;
51
53
  /** Returns true if this value is an array, but not a typed array */
@@ -129,12 +129,15 @@ function IsBigUint64Array(value) {
129
129
  return value instanceof globalThis.BigUint64Array;
130
130
  }
131
131
  // --------------------------------------------------------------------------
132
- // Standard
132
+ // PropertyKey
133
133
  // --------------------------------------------------------------------------
134
134
  /** Returns true if this value has this property key */
135
135
  function HasPropertyKey(value, key) {
136
136
  return key in value;
137
137
  }
138
+ // --------------------------------------------------------------------------
139
+ // Standard
140
+ // --------------------------------------------------------------------------
138
141
  /** Returns true of this value is an object type */
139
142
  function IsObject(value) {
140
143
  return value !== null && typeof value === 'object';
@@ -72,6 +72,7 @@ export interface ValueError {
72
72
  path: string;
73
73
  value: unknown;
74
74
  message: string;
75
+ errors: ValueErrorIterator[];
75
76
  }
76
77
  export declare class ValueErrorsUnknownTypeError extends TypeBoxError {
77
78
  readonly schema: TSchema;
@@ -6,6 +6,7 @@ import { GetErrorFunction } from './function.mjs';
6
6
  import { TypeBoxError } from '../type/error/index.mjs';
7
7
  import { Deref } from '../value/deref/index.mjs';
8
8
  import { Hash } from '../value/hash/index.mjs';
9
+ import { Check } from '../value/check/index.mjs';
9
10
  import { Kind } from '../type/symbols/index.mjs';
10
11
  import { Never } from '../type/never/index.mjs';
11
12
  // ------------------------------------------------------------------
@@ -123,8 +124,15 @@ export class ValueErrorIterator {
123
124
  // --------------------------------------------------------------------------
124
125
  // Create
125
126
  // --------------------------------------------------------------------------
126
- function Create(errorType, schema, path, value) {
127
- return { type: errorType, schema, path, value, message: GetErrorFunction()({ errorType, path, schema, value }) };
127
+ function Create(errorType, schema, path, value, errors = []) {
128
+ return {
129
+ type: errorType,
130
+ schema,
131
+ path,
132
+ value,
133
+ message: GetErrorFunction()({ errorType, path, schema, value, errors }),
134
+ errors,
135
+ };
128
136
  }
129
137
  // --------------------------------------------------------------------------
130
138
  // Types
@@ -470,16 +478,10 @@ function* FromUndefined(schema, references, path, value) {
470
478
  yield Create(ValueErrorType.Undefined, schema, path, value);
471
479
  }
472
480
  function* FromUnion(schema, references, path, value) {
473
- let count = 0;
474
- for (const subschema of schema.anyOf) {
475
- const errors = [...Visit(subschema, references, path, value)];
476
- if (errors.length === 0)
477
- return; // matched
478
- count += errors.length;
479
- }
480
- if (count > 0) {
481
- yield Create(ValueErrorType.Union, schema, path, value);
482
- }
481
+ if (Check(schema, references, value))
482
+ return;
483
+ const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit(variant, references, path, value)));
484
+ yield Create(ValueErrorType.Union, schema, path, value, errors);
483
485
  }
484
486
  function* FromUint8Array(schema, references, path, value) {
485
487
  if (!IsUint8Array(value))
@@ -1,5 +1,5 @@
1
1
  import { TSchema } from '../type/schema/index.mjs';
2
- import { ValueErrorType } from './errors.mjs';
2
+ import { ValueErrorIterator, ValueErrorType } from './errors.mjs';
3
3
  /** Creates an error message using en-US as the default locale */
4
4
  export declare function DefaultErrorFunction(error: ErrorFunctionParameter): string;
5
5
  export type ErrorFunctionParameter = {
@@ -11,6 +11,8 @@ export type ErrorFunctionParameter = {
11
11
  schema: TSchema;
12
12
  /** The value associated with the error */
13
13
  value: unknown;
14
+ /** Interior errors for this error */
15
+ errors: ValueErrorIterator[];
14
16
  };
15
17
  export type ErrorFunction = (parameter: ErrorFunctionParameter) => string;
16
18
  /** Sets the error function used to generate error messages. */
@@ -1,3 +1,7 @@
1
+ /** Returns true if this value has this property key */
2
+ export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is Record<PropertyKey, unknown> & {
3
+ [_ in K]: unknown;
4
+ };
1
5
  /** Returns true if this value is an async iterator */
2
6
  export declare function IsAsyncIterator(value: unknown): value is AsyncIterableIterator<unknown>;
3
7
  /** Returns true if this value is an array */
@@ -1,4 +1,11 @@
1
1
  // --------------------------------------------------------------------------
2
+ // PropertyKey
3
+ // --------------------------------------------------------------------------
4
+ /** Returns true if this value has this property key */
5
+ export function HasPropertyKey(value, key) {
6
+ return key in value;
7
+ }
8
+ // --------------------------------------------------------------------------
2
9
  // Object Instances
3
10
  // --------------------------------------------------------------------------
4
11
  /** Returns true if this value is an async iterator */
@@ -5,7 +5,7 @@ import { Kind } from '../../type/symbols/index.mjs';
5
5
  // ------------------------------------------------------------------
6
6
  // ValueGuard
7
7
  // ------------------------------------------------------------------
8
- import { IsFunction, IsObject, IsArray, IsUndefined, HasPropertyKey } from '../guard/index.mjs';
8
+ import { IsArray, IsDate, IsFunction, IsObject, IsUndefined, HasPropertyKey } from '../guard/index.mjs';
9
9
  // ------------------------------------------------------------------
10
10
  // TypeGuard
11
11
  // ------------------------------------------------------------------
@@ -36,6 +36,10 @@ function FromArray(schema, references, value) {
36
36
  }
37
37
  return defaulted;
38
38
  }
39
+ function FromDate(schema, references, value) {
40
+ // special case intercept for dates
41
+ return IsDate(value) ? value : ValueOrDefault(schema, value);
42
+ }
39
43
  function FromIntersect(schema, references, value) {
40
44
  const defaulted = ValueOrDefault(schema, value);
41
45
  return schema.allOf.reduce((acc, schema) => {
@@ -127,6 +131,8 @@ function Visit(schema, references, value) {
127
131
  switch (schema_[Kind]) {
128
132
  case 'Array':
129
133
  return FromArray(schema_, references_, value);
134
+ case 'Date':
135
+ return FromDate(schema_, references_, value);
130
136
  case 'Intersect':
131
137
  return FromIntersect(schema_, references_, value);
132
138
  case 'Object':
@@ -45,7 +45,9 @@ export declare function IsBigInt64Array(value: unknown): value is BigInt64Array;
45
45
  /** Returns true if the value is a BigUint64Array */
46
46
  export declare function IsBigUint64Array(value: unknown): value is BigUint64Array;
47
47
  /** Returns true if this value has this property key */
48
- export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is ObjectType & Record<K, unknown>;
48
+ export declare function HasPropertyKey<K extends PropertyKey>(value: Record<any, unknown>, key: K): value is Record<PropertyKey, unknown> & {
49
+ [_ in K]: unknown;
50
+ };
49
51
  /** Returns true of this value is an object type */
50
52
  export declare function IsObject(value: unknown): value is ObjectType;
51
53
  /** Returns true if this value is an array, but not a typed array */
@@ -92,12 +92,15 @@ export function IsBigUint64Array(value) {
92
92
  return value instanceof globalThis.BigUint64Array;
93
93
  }
94
94
  // --------------------------------------------------------------------------
95
- // Standard
95
+ // PropertyKey
96
96
  // --------------------------------------------------------------------------
97
97
  /** Returns true if this value has this property key */
98
98
  export function HasPropertyKey(value, key) {
99
99
  return key in value;
100
100
  }
101
+ // --------------------------------------------------------------------------
102
+ // Standard
103
+ // --------------------------------------------------------------------------
101
104
  /** Returns true of this value is an object type */
102
105
  export function IsObject(value) {
103
106
  return value !== null && typeof value === 'object';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.33.14",
3
+ "version": "0.33.16",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",