@sinclair/typebox 0.24.50 → 0.24.51

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.24.50",
3
+ "version": "0.24.51",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/typebox.d.ts CHANGED
@@ -210,7 +210,7 @@ export interface TPromise<T extends TSchema = TSchema> extends TSchema {
210
210
  type: 'promise';
211
211
  item: TSchema;
212
212
  }
213
- export declare type TRecordKey = TString | TNumber | TUnion<TLiteral<any>[]>;
213
+ export declare type TRecordKey = TString | TNumeric | TUnion<TLiteral<any>[]>;
214
214
  export interface TRecord<K extends TRecordKey = TRecordKey, T extends TSchema = TSchema> extends TSchema {
215
215
  [Kind]: 'Record';
216
216
  static: Record<Static<K>, Static<T, this['params']>>;
@@ -369,7 +369,7 @@ export declare class TypeBuilder {
369
369
  /** Creates an object whose properties are derived from the given string literal union. */
370
370
  Record<K extends TUnion<TLiteral[]>, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TObject<TRecordProperties<K, T>>;
371
371
  /** Creates a record type */
372
- Record<K extends TString | TNumber, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecord<K, T>;
372
+ Record<K extends TString | TNumeric, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): TRecord<K, T>;
373
373
  /** Creates a recursive object type */
374
374
  Recursive<T extends TSchema>(callback: (self: TSelf) => T, options?: SchemaOptions): TRecursive<T>;
375
375
  /** Creates a reference schema */
package/typebox.js CHANGED
@@ -259,7 +259,7 @@ class TypeBuilder {
259
259
  }, {}), { ...options, [exports.Hint]: 'Record' });
260
260
  }
261
261
  // otherwise return TRecord with patternProperties
262
- const pattern = key[exports.Kind] === 'Number' ? '^(0|[1-9][0-9]*)$' : key[exports.Kind] === 'String' && key.pattern ? key.pattern : '^.*$';
262
+ const pattern = ['Integer', 'Number'].includes(key[exports.Kind]) ? '^(0|[1-9][0-9]*)$' : key[exports.Kind] === 'String' && key.pattern ? key.pattern : '^.*$';
263
263
  return this.Create({
264
264
  ...options,
265
265
  [exports.Kind]: 'Record',