@sinclair/typebox 0.32.21 → 0.32.22

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.
@@ -1,13 +1,19 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import type { Static } from '../static/index.mjs';
3
3
  import type { Ensure } from '../helpers/index.mjs';
4
+ import type { TReadonlyOptional } from '../readonly-optional/index.mjs';
5
+ import type { TReadonly } from '../readonly/index.mjs';
6
+ import type { TOptional } from '../optional/index.mjs';
4
7
  import { Kind } from '../symbols/index.mjs';
5
- type ConstructorStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
6
- type ConstructorStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? ConstructorStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
7
- type ConstructorStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<new (...param: ConstructorStaticParameters<T, P>) => ConstructorStaticReturnType<U, P>>);
8
+ type StaticReturnType<U extends TSchema, P extends unknown[]> = Static<U, P>;
9
+ type StaticParameter<T extends TSchema, P extends unknown[]> = T extends TReadonlyOptional<T> ? [Readonly<Static<T, P>>?] : T extends TReadonly<T> ? [Readonly<Static<T, P>>] : T extends TOptional<T> ? [Static<T, P>?] : [
10
+ Static<T, P>
11
+ ];
12
+ type StaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? StaticParameters<R, P, [...Acc, ...StaticParameter<L, P>]> : Acc);
13
+ type StaticConstructor<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<new (...params: StaticParameters<T, P>) => StaticReturnType<U, P>>;
8
14
  export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
9
15
  [Kind]: 'Constructor';
10
- static: ConstructorStatic<T, U, this['params']>;
16
+ static: StaticConstructor<T, U, this['params']>;
11
17
  type: 'Constructor';
12
18
  parameters: T;
13
19
  returns: U;
@@ -1,13 +1,19 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import type { Static } from '../static/index.mjs';
3
3
  import type { Ensure } from '../helpers/index.mjs';
4
+ import type { TReadonlyOptional } from '../readonly-optional/index.mjs';
5
+ import type { TReadonly } from '../readonly/index.mjs';
6
+ import type { TOptional } from '../optional/index.mjs';
4
7
  import { Kind } from '../symbols/index.mjs';
5
- type FunctionStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
6
- type FunctionStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FunctionStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
7
- type FunctionStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<(...param: FunctionStaticParameters<T, P>) => FunctionStaticReturnType<U, P>>);
8
+ type StaticReturnType<U extends TSchema, P extends unknown[]> = Static<U, P>;
9
+ type StaticParameter<T extends TSchema, P extends unknown[]> = T extends TReadonlyOptional<T> ? [Readonly<Static<T, P>>?] : T extends TReadonly<T> ? [Readonly<Static<T, P>>] : T extends TOptional<T> ? [Static<T, P>?] : [
10
+ Static<T, P>
11
+ ];
12
+ type StaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? StaticParameters<R, P, [...Acc, ...StaticParameter<L, P>]> : Acc);
13
+ type StaticFunction<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<(...params: StaticParameters<T, P>) => StaticReturnType<U, P>>;
8
14
  export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
9
15
  [Kind]: 'Function';
10
- static: FunctionStatic<T, U, this['params']>;
16
+ static: StaticFunction<T, U, this['params']>;
11
17
  type: 'Function';
12
18
  parameters: T;
13
19
  returns: U;
@@ -1,13 +1,19 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import type { Static } from '../static/index';
3
3
  import type { Ensure } from '../helpers/index';
4
+ import type { TReadonlyOptional } from '../readonly-optional/index';
5
+ import type { TReadonly } from '../readonly/index';
6
+ import type { TOptional } from '../optional/index';
4
7
  import { Kind } from '../symbols/index';
5
- type ConstructorStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
6
- type ConstructorStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? ConstructorStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
7
- type ConstructorStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<new (...param: ConstructorStaticParameters<T, P>) => ConstructorStaticReturnType<U, P>>);
8
+ type StaticReturnType<U extends TSchema, P extends unknown[]> = Static<U, P>;
9
+ type StaticParameter<T extends TSchema, P extends unknown[]> = T extends TReadonlyOptional<T> ? [Readonly<Static<T, P>>?] : T extends TReadonly<T> ? [Readonly<Static<T, P>>] : T extends TOptional<T> ? [Static<T, P>?] : [
10
+ Static<T, P>
11
+ ];
12
+ type StaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? StaticParameters<R, P, [...Acc, ...StaticParameter<L, P>]> : Acc);
13
+ type StaticConstructor<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<new (...params: StaticParameters<T, P>) => StaticReturnType<U, P>>;
8
14
  export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
9
15
  [Kind]: 'Constructor';
10
- static: ConstructorStatic<T, U, this['params']>;
16
+ static: StaticConstructor<T, U, this['params']>;
11
17
  type: 'Constructor';
12
18
  parameters: T;
13
19
  returns: U;
@@ -1,13 +1,19 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index';
2
2
  import type { Static } from '../static/index';
3
3
  import type { Ensure } from '../helpers/index';
4
+ import type { TReadonlyOptional } from '../readonly-optional/index';
5
+ import type { TReadonly } from '../readonly/index';
6
+ import type { TOptional } from '../optional/index';
4
7
  import { Kind } from '../symbols/index';
5
- type FunctionStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
6
- type FunctionStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FunctionStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
7
- type FunctionStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<(...param: FunctionStaticParameters<T, P>) => FunctionStaticReturnType<U, P>>);
8
+ type StaticReturnType<U extends TSchema, P extends unknown[]> = Static<U, P>;
9
+ type StaticParameter<T extends TSchema, P extends unknown[]> = T extends TReadonlyOptional<T> ? [Readonly<Static<T, P>>?] : T extends TReadonly<T> ? [Readonly<Static<T, P>>] : T extends TOptional<T> ? [Static<T, P>?] : [
10
+ Static<T, P>
11
+ ];
12
+ type StaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? StaticParameters<R, P, [...Acc, ...StaticParameter<L, P>]> : Acc);
13
+ type StaticFunction<T extends TSchema[], U extends TSchema, P extends unknown[]> = Ensure<(...params: StaticParameters<T, P>) => StaticReturnType<U, P>>;
8
14
  export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
9
15
  [Kind]: 'Function';
10
- static: FunctionStatic<T, U, this['params']>;
16
+ static: StaticFunction<T, U, this['params']>;
11
17
  type: 'Function';
12
18
  parameters: T;
13
19
  returns: U;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.32.21",
3
+ "version": "0.32.22",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",