@sinclair/typebox 0.32.21 → 0.32.23
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/build/import/type/constructor/constructor.d.mts +10 -4
- package/build/import/type/function/function.d.mts +10 -4
- package/build/import/value/clean/clean.mjs +1 -1
- package/build/require/type/constructor/constructor.d.ts +10 -4
- package/build/require/type/function/function.d.ts +10 -4
- package/build/require/value/clean/clean.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
6
|
-
type
|
|
7
|
-
|
|
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 (...param: 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:
|
|
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
|
|
6
|
-
type
|
|
7
|
-
|
|
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<(...param: 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:
|
|
16
|
+
static: StaticFunction<T, U, this['params']>;
|
|
11
17
|
type: 'Function';
|
|
12
18
|
parameters: T;
|
|
13
19
|
returns: U;
|
|
@@ -102,7 +102,7 @@ function FromTuple(schema, references, value) {
|
|
|
102
102
|
}
|
|
103
103
|
function FromUnion(schema, references, value) {
|
|
104
104
|
for (const inner of schema.anyOf) {
|
|
105
|
-
if (IsCheckable(inner) && Check(inner, value)) {
|
|
105
|
+
if (IsCheckable(inner) && Check(inner, references, value)) {
|
|
106
106
|
return Visit(inner, references, value);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -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
|
|
6
|
-
type
|
|
7
|
-
|
|
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 (...param: 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:
|
|
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
|
|
6
|
-
type
|
|
7
|
-
|
|
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<(...param: 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:
|
|
16
|
+
static: StaticFunction<T, U, this['params']>;
|
|
11
17
|
type: 'Function';
|
|
12
18
|
parameters: T;
|
|
13
19
|
returns: U;
|
|
@@ -106,7 +106,7 @@ function FromTuple(schema, references, value) {
|
|
|
106
106
|
}
|
|
107
107
|
function FromUnion(schema, references, value) {
|
|
108
108
|
for (const inner of schema.anyOf) {
|
|
109
|
-
if (IsCheckable(inner) && (0, index_2.Check)(inner, value)) {
|
|
109
|
+
if (IsCheckable(inner) && (0, index_2.Check)(inner, references, value)) {
|
|
110
110
|
return Visit(inner, references, value);
|
|
111
111
|
}
|
|
112
112
|
}
|