typebox 1.1.7 → 1.1.9
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/type/engine/call/distribute-arguments.d.mts +15 -0
- package/build/type/engine/call/distribute-arguments.mjs +52 -0
- package/build/type/engine/call/instantiate.d.mts +10 -7
- package/build/type/engine/call/instantiate.mjs +33 -23
- package/build/type/engine/call/resolve-arguments.mjs +2 -2
- package/build/type/engine/evaluate/broaden.d.mts +1 -1
- package/build/type/engine/evaluate/broaden.mjs +7 -8
- package/package.json +1 -1
- package/readme.md +15 -45
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TUnion } from '../../types/union.mjs';
|
|
3
|
+
import { type TDeferred } from '../../types/deferred.mjs';
|
|
4
|
+
import { type TRef } from '../../types/ref.mjs';
|
|
5
|
+
import { type TParameter } from '../../types/parameter.mjs';
|
|
6
|
+
type TCollectDistributionNames<Expression extends TSchema, Result extends string[] = []> = (Expression extends TDeferred<'Conditional', [infer Left extends TSchema, infer _Right extends TSchema, infer True extends TSchema, infer False extends TSchema]> ? Left extends TRef<infer Name extends string> ? TCollectDistributionNames<True, TCollectDistributionNames<False, [...Result, Name]>> : TCollectDistributionNames<True, TCollectDistributionNames<False, Result>> : Result);
|
|
7
|
+
type TBuildDistributionArray<Parameters extends TParameter[], Names extends string[], Result extends boolean[] = []> = (Parameters extends [infer Left extends TParameter, ...infer Right extends TParameter[]] ? Left['name'] extends Names[number] ? TBuildDistributionArray<Right, Names, [...Result, true]> : TBuildDistributionArray<Right, Names, [...Result, false]> : Result);
|
|
8
|
+
type TZipDistributionArray<Arguments extends TSchema[], DistributionArray extends boolean[], Result extends [boolean, TSchema][] = []> = (Arguments extends [infer ArgumentLeft extends TSchema, ...infer ArgumentRight extends TSchema[]] ? DistributionArray extends [infer BooleanLeft extends boolean, ...infer BooleanRight extends boolean[]] ? TZipDistributionArray<ArgumentRight, BooleanRight, [...Result, [BooleanLeft, ArgumentLeft]]> : Result : Result);
|
|
9
|
+
type TExpand<Type extends TSchema> = (Type extends TUnion<infer Types extends TSchema[]> ? [...Types] : [Type]);
|
|
10
|
+
type TAppend<Current extends TSchema[][], Type extends TSchema, Result extends TSchema[][] = []> = (Current extends [infer Left extends TSchema[], ...infer Right extends TSchema[][]] ? TAppend<Right, Type, [...Result, [...Left, Type]]> : Result);
|
|
11
|
+
type TCross<Current extends TSchema[][], Variants extends TSchema[], Result extends TSchema[][] = []> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCross<Current, Right, [...Result, ...TAppend<Current, Left>]> : Result);
|
|
12
|
+
type TDistribute<ZippedArguments extends [boolean, TSchema][], Result extends TSchema[][] = [[]]> = (ZippedArguments extends [infer Left extends [boolean, TSchema], ...infer Right extends [boolean, TSchema][]] ? Left[0] extends true ? TDistribute<Right, TCross<Result, TExpand<Left[1]>>> : TDistribute<Right, TCross<Result, [Left[1]]>> : Result);
|
|
13
|
+
export type TDistributeArguments<Parameters extends TParameter[], Arguments extends TSchema[], Expression extends TSchema, DistributionNames extends string[] = TCollectDistributionNames<Expression>, DistributionArray extends boolean[] = TBuildDistributionArray<Parameters, DistributionNames>, ZippedArguments extends [boolean, TSchema][] = TZipDistributionArray<Arguments, DistributionArray>, Result extends TSchema[][] = Expression extends TDeferred<'Conditional', TSchema[]> ? TDistribute<ZippedArguments> : [Arguments]> = Result;
|
|
14
|
+
export declare function DistributeArguments<Parameters extends TParameter[], Arguments extends TSchema[], Expression extends TSchema>(parameters: [...Parameters], arguments_: [...Arguments], expression: Expression): TDistributeArguments<Parameters, Arguments, Expression>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
+
import { IsUnion } from '../../types/union.mjs';
|
|
4
|
+
import { IsDeferred } from '../../types/deferred.mjs';
|
|
5
|
+
import { IsRef } from '../../types/ref.mjs';
|
|
6
|
+
function CollectDistributionNames(expression, result = []) {
|
|
7
|
+
return (IsDeferred(expression) && Guard.IsEqual(expression.action, 'Conditional')
|
|
8
|
+
? IsRef(expression.parameters[0])
|
|
9
|
+
? CollectDistributionNames(expression.parameters[2], CollectDistributionNames(expression.parameters[3], [...result, expression.parameters[0].$ref]))
|
|
10
|
+
: CollectDistributionNames(expression.parameters[2], CollectDistributionNames(expression.parameters[3], result))
|
|
11
|
+
: result);
|
|
12
|
+
}
|
|
13
|
+
function BuildDistributionArray(parameters, names) {
|
|
14
|
+
return parameters.reduce((result, left) => [...result, names.includes(left.name)], []);
|
|
15
|
+
}
|
|
16
|
+
function ZipDistributionArray(arguments_, distributionArray, result = []) {
|
|
17
|
+
const [argumentLeft, ...argumentRight] = arguments_;
|
|
18
|
+
const [booleanLeft, ...booleanRight] = distributionArray;
|
|
19
|
+
return (Guard.IsGreaterThan(arguments_.length, 0)
|
|
20
|
+
? Guard.IsGreaterThan(distributionArray.length, 0)
|
|
21
|
+
? ZipDistributionArray(argumentRight, booleanRight, [...result, [booleanLeft, argumentLeft]])
|
|
22
|
+
: result
|
|
23
|
+
: result);
|
|
24
|
+
}
|
|
25
|
+
function Expand(type) {
|
|
26
|
+
return (IsUnion(type)
|
|
27
|
+
? [...type.anyOf]
|
|
28
|
+
: [type]);
|
|
29
|
+
}
|
|
30
|
+
function Append(current, type) {
|
|
31
|
+
return current.reduce((result, left) => [...result, [...left, type]], []);
|
|
32
|
+
}
|
|
33
|
+
function Cross(current, variants) {
|
|
34
|
+
return variants.reduce((result, left) => {
|
|
35
|
+
return [...result, ...Append(current, left)];
|
|
36
|
+
}, []);
|
|
37
|
+
}
|
|
38
|
+
function Distribute(zipped) {
|
|
39
|
+
return zipped.reduce((result, left) => {
|
|
40
|
+
return Guard.IsEqual(left[0], true)
|
|
41
|
+
? Cross(result, Expand(left[1]))
|
|
42
|
+
: Cross(result, [left[1]]); // - no-expansion
|
|
43
|
+
}, [[]]);
|
|
44
|
+
}
|
|
45
|
+
export function DistributeArguments(parameters, arguments_, expression) {
|
|
46
|
+
const distributionNames = CollectDistributionNames(expression);
|
|
47
|
+
const distributionArray = BuildDistributionArray(parameters, distributionNames);
|
|
48
|
+
const zippedArguments = ZipDistributionArray(arguments_, distributionArray);
|
|
49
|
+
return (IsDeferred(expression) && Guard.IsEqual(expression.action, 'Conditional')
|
|
50
|
+
? Distribute(zippedArguments)
|
|
51
|
+
: [arguments_]);
|
|
52
|
+
}
|
|
@@ -4,17 +4,20 @@ import { type TCallConstruct } from '../../types/call.mjs';
|
|
|
4
4
|
import { type TRef } from '../../types/ref.mjs';
|
|
5
5
|
import { type TGeneric } from '../../types/generic.mjs';
|
|
6
6
|
import { type TProperties } from '../../types/properties.mjs';
|
|
7
|
-
import { type
|
|
7
|
+
import { type TEvaluateUnion } from '../evaluate/index.mjs';
|
|
8
8
|
import { type TInstantiateType } from '../instantiate.mjs';
|
|
9
9
|
import { type TInstantiateTypes } from '../instantiate.mjs';
|
|
10
|
+
import { type TState } from '../instantiate.mjs';
|
|
11
|
+
import { type TDistributeArguments } from './distribute-arguments.mjs';
|
|
10
12
|
import { type TResolveTarget } from './resolve-target.mjs';
|
|
11
13
|
import { type TResolveArgumentsContext } from './resolve-arguments.mjs';
|
|
12
|
-
type TPeek<
|
|
13
|
-
type
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
callstack: [...State['callstack'], Name];
|
|
14
|
+
type TPeek<State extends TState, Result extends string = State['callstack'] extends [...infer _ extends string[], infer Top extends string] ? Top : ''> = Result;
|
|
15
|
+
type TIsTailCall<State extends TState, Name extends string, Result extends boolean = TPeek<State> extends Name ? true : false> = Result;
|
|
16
|
+
type TCallDispatch<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, Arguments extends TSchema[], ArgumentsContext extends TProperties = TResolveArgumentsContext<Context, State, Parameters, Arguments>, ReturnType extends TSchema = TInstantiateType<ArgumentsContext, {
|
|
17
|
+
callstack: [...State['callstack'], Target['$ref']];
|
|
17
18
|
}, Expression>> = TInstantiateType<Context, State, ReturnType>;
|
|
18
|
-
|
|
19
|
+
type TCallDistributed<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, DistributedArguments extends TSchema[][], Result extends TSchema[] = []> = (DistributedArguments extends [infer Arguments extends TSchema[], ...infer DistributedArguments extends TSchema[][]] ? TCallDispatch<Context, State, Target, Parameters, Expression, Arguments> extends infer ReturnType extends TSchema ? TCallDistributed<Context, State, Target, Parameters, Expression, DistributedArguments, [...Result, ReturnType]> : never : Result);
|
|
20
|
+
type TCallImmediate<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, InstantiatedArguments extends TSchema[], DistributedArguments extends TSchema[][] = TDistributeArguments<Parameters, InstantiatedArguments, Expression>, ReturnTypes extends TSchema[] = TCallDistributed<Context, State, Target, Parameters, Expression, DistributedArguments>, Result extends TSchema = ReturnTypes['length'] extends 1 ? ReturnTypes[0] : TEvaluateUnion<ReturnTypes>> = Result;
|
|
21
|
+
export type TCallInstantiate<Context extends TProperties, State extends TState, Target extends TSchema, Arguments extends TSchema[], InstantiatedArguments extends TSchema[] = TInstantiateTypes<Context, State, Arguments>, Resolved extends [string, TSchema] = TResolveTarget<Context, Target, Arguments>, Name extends string = Resolved[0], Type extends TSchema = Resolved[1], Result extends TSchema = (Type extends TGeneric<infer Parameters extends TParameter[], infer Expression extends TSchema> ? TIsTailCall<State, Name> extends true ? TCallConstruct<TRef<Name>, InstantiatedArguments> : TCallImmediate<Context, State, TRef<Name>, Parameters, Expression, InstantiatedArguments> : TCallConstruct<Target, InstantiatedArguments>)> = Result;
|
|
19
22
|
export declare function CallInstantiate<Context extends TProperties, State extends TState, Target extends TSchema, Arguments extends TSchema[]>(context: Context, state: State, target: Target, arguments_: [...Arguments]): TCallInstantiate<Context, State, Target, Arguments>;
|
|
20
23
|
export {};
|
|
@@ -3,36 +3,46 @@ import { Guard } from '../../../guard/index.mjs';
|
|
|
3
3
|
import { CallConstruct } from '../../types/call.mjs';
|
|
4
4
|
import { Ref } from '../../types/ref.mjs';
|
|
5
5
|
import { IsGeneric } from '../../types/generic.mjs';
|
|
6
|
+
import { EvaluateUnion } from '../evaluate/index.mjs';
|
|
6
7
|
import { InstantiateType } from '../instantiate.mjs';
|
|
7
8
|
import { InstantiateTypes } from '../instantiate.mjs';
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
9
|
+
// ------------------------------------------------------------------
|
|
10
|
+
// Infrastructure
|
|
11
|
+
// ------------------------------------------------------------------
|
|
12
|
+
import { DistributeArguments } from './distribute-arguments.mjs';
|
|
11
13
|
import { ResolveTarget } from './resolve-target.mjs';
|
|
12
14
|
import { ResolveArgumentsContext } from './resolve-arguments.mjs';
|
|
13
|
-
function Peek(
|
|
14
|
-
|
|
15
|
+
function Peek(state) {
|
|
16
|
+
const result = Guard.IsGreaterThan(state.callstack.length, 0) ? state.callstack[state.callstack.length - 1] : '';
|
|
17
|
+
return result;
|
|
15
18
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
return deferredCall;
|
|
20
|
-
}
|
|
21
|
-
function TailCall(context, state, name, arguments_) {
|
|
22
|
-
const deferredCall = DeferredCall(context, state, Ref(name), arguments_);
|
|
23
|
-
return deferredCall;
|
|
19
|
+
function IsTailCall(state, name) {
|
|
20
|
+
const result = Guard.IsEqual(Peek(state), name);
|
|
21
|
+
return result;
|
|
24
22
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const returnType = InstantiateType(argumentsContext, { callstack: [...state.callstack, name] }, expression);
|
|
23
|
+
function CallDispatch(context, state, target, parameters, expression, arguments_) {
|
|
24
|
+
const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
|
|
25
|
+
const returnType = InstantiateType(argumentsContext, { callstack: [...state.callstack, target.$ref] }, expression);
|
|
29
26
|
return InstantiateType(context, state, returnType);
|
|
30
27
|
}
|
|
28
|
+
function CallDistributed(context, state, target, parameters, expression, distributedArguments) {
|
|
29
|
+
return distributedArguments.reduce((result, arguments_) => [...result, CallDispatch(context, state, target, parameters, expression, arguments_)], []);
|
|
30
|
+
}
|
|
31
|
+
function CallImmediate(context, state, target, parameters, expression, arguments_) {
|
|
32
|
+
const distributedArguments = DistributeArguments(parameters, arguments_, expression);
|
|
33
|
+
const returnTypes = CallDistributed(context, state, target, parameters, expression, distributedArguments);
|
|
34
|
+
const result = returnTypes.length === 1 ? returnTypes[0] : EvaluateUnion(returnTypes);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
31
37
|
export function CallInstantiate(context, state, target, arguments_) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const instantiatedArguments = InstantiateTypes(context, state, arguments_);
|
|
39
|
+
const resolved = ResolveTarget(context, target, arguments_);
|
|
40
|
+
const name = resolved[0];
|
|
41
|
+
const type = resolved[1];
|
|
42
|
+
const result = (IsGeneric(type)
|
|
43
|
+
? IsTailCall(state, name)
|
|
44
|
+
? CallConstruct(Ref(name), instantiatedArguments)
|
|
45
|
+
: CallImmediate(context, state, Ref(name), type.parameters, type.expression, instantiatedArguments)
|
|
46
|
+
: CallConstruct(target, instantiatedArguments));
|
|
47
|
+
return result;
|
|
38
48
|
}
|
|
@@ -11,9 +11,9 @@ import { IsCall } from '../../types/call.mjs';
|
|
|
11
11
|
function AssertArgumentExtends(name, type, extends_) {
|
|
12
12
|
if (IsInfer(type) || IsCall(type) || ExtendsResult.IsExtendsTrueLike(Extends({}, type, extends_)))
|
|
13
13
|
return;
|
|
14
|
-
const cause = { parameter: name,
|
|
14
|
+
const cause = { parameter: name, expect: extends_, actual: type };
|
|
15
15
|
// @ts-ignore - no definition for { cause } options
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error(`Argument for parameter ${name} does not satisfy constraint`, { cause });
|
|
17
17
|
}
|
|
18
18
|
function BindArgument(context, state, name, extends_, type) {
|
|
19
19
|
const instantiatedArgument = InstantiateType(context, state, type);
|
|
@@ -9,7 +9,7 @@ import { type TEvaluateType } from './evaluate.mjs';
|
|
|
9
9
|
type TBroadFilter<Type extends TSchema, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCompare<Type, Left> extends typeof ResultRightInside ? TBroadFilter<Type, Right, [...Result]> : TBroadFilter<Type, Right, [...Result, Left]> : Result);
|
|
10
10
|
type TIsBroadestType<Type extends TSchema, Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCompare<Type, Left> extends typeof ResultLeftInside | typeof ResultEqual ? false : TIsBroadestType<Type, Right> : true);
|
|
11
11
|
type TBroadenType<Type extends TSchema, Types extends TSchema[], Evaluated extends TSchema = TEvaluateType<Type>, Result extends TSchema[] = (Evaluated extends TAny ? [Evaluated] : TIsBroadestType<Evaluated, Types> extends true ? [...TBroadFilter<Evaluated, Types>, Evaluated] : Types)> = Result;
|
|
12
|
-
type TBroadenTypes<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TObject ? TBroadenTypes<Right, [...Result, Left]> : TBroadenTypes<Right, TBroadenType<Left, Result>> : Result);
|
|
12
|
+
type TBroadenTypes<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? (Left extends TObject ? TBroadenTypes<Right, [...Result, Left]> : Left extends TNever ? TBroadenTypes<Right, Result> : TBroadenTypes<Right, TBroadenType<Left, Result>>) : Result);
|
|
13
13
|
export type TBroaden<Types extends TSchema[], Broadened extends TSchema[] = TBroadenTypes<Types>, Flattened extends TSchema[] = TFlatten<Broadened>, Result extends TSchema = (Flattened extends [] ? TNever : Flattened extends [infer Type extends TSchema] ? Type : TUnion<Flattened>)> = Result;
|
|
14
14
|
/** Broadens a set of types and returns either the most broad type, or union or disjoint types. */
|
|
15
15
|
export declare function Broaden<Types extends TSchema[]>(types: [...Types]): TBroaden<Types>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
-
import { IsSchema } from '../../types/schema.mjs';
|
|
4
3
|
import { IsAny } from '../../types/any.mjs';
|
|
5
|
-
import { Never } from '../../types/never.mjs';
|
|
4
|
+
import { Never, IsNever } from '../../types/never.mjs';
|
|
6
5
|
import { IsObject } from '../../types/object.mjs';
|
|
7
6
|
import { Union } from '../../types/union.mjs';
|
|
8
7
|
import { Compare, ResultRightInside, ResultLeftInside, ResultEqual } from './compare.mjs';
|
|
@@ -30,12 +29,12 @@ function BroadenType(type, types) {
|
|
|
30
29
|
: types);
|
|
31
30
|
}
|
|
32
31
|
function BroadenTypes(types, result = []) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
return types.reduce((result, left) => {
|
|
33
|
+
return (IsObject(left) ? [...result, left] : // push
|
|
34
|
+
IsNever(left) ? result : // ignore
|
|
35
|
+
BroadenType(left, result) // broaden
|
|
36
|
+
);
|
|
37
|
+
}, []);
|
|
39
38
|
}
|
|
40
39
|
/** Broadens a set of types and returns either the most broad type, or union or disjoint types. */
|
|
41
40
|
export function Broaden(types) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -57,12 +57,11 @@ License: MIT
|
|
|
57
57
|
|
|
58
58
|
## Contents
|
|
59
59
|
|
|
60
|
-
|
|
61
60
|
- [Type](#Type)
|
|
62
61
|
- [Value](#Value)
|
|
63
62
|
- [Script](#Script)
|
|
64
63
|
- [Schema](#Schema)
|
|
65
|
-
- [
|
|
64
|
+
- [Versions](#Versions)
|
|
66
65
|
- [Contribute](#Contribute)
|
|
67
66
|
|
|
68
67
|
|
|
@@ -223,60 +222,31 @@ const R = C.Parse({ x: 0, y: 0, z: 0 }) // const R: {
|
|
|
223
222
|
// } = ...
|
|
224
223
|
```
|
|
225
224
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
If upgrading from `@sinclair/typebox` 0.34.x refer to the 1.0 migration guide at the following URL.
|
|
225
|
+
<a name="Versions"></a>
|
|
229
226
|
|
|
230
|
-
|
|
227
|
+
## Versions
|
|
231
228
|
|
|
232
|
-
|
|
229
|
+
TypeBox provides two distinct versions that span two generations of the TypeScript compiler.
|
|
233
230
|
|
|
234
|
-
|
|
235
|
-
import { Type } from '@sinclair/typebox' // TB: 0.34.x
|
|
236
|
-
import { Static } from 'typebox' // TB: 1.0.0
|
|
231
|
+
### Version 0.x
|
|
237
232
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const A = Type.Object({
|
|
242
|
-
x: Type.Number(),
|
|
243
|
-
y: Type.Number(),
|
|
244
|
-
z: Type.Number()
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
const B = Type.Object({
|
|
248
|
-
a: Type.Number(),
|
|
249
|
-
b: Type.Number(),
|
|
250
|
-
c: Type.Number()
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
const C = Type.Composite([A, B])
|
|
233
|
+
```bash
|
|
234
|
+
$ npm install @sinclair/typebox # 0.x - LTS | TS 4-6
|
|
235
|
+
```
|
|
254
236
|
|
|
255
|
-
|
|
256
|
-
// Modern Inference
|
|
257
|
-
// ----------------------------------------------------------
|
|
258
|
-
type C = Static<typeof C> // type C = {
|
|
259
|
-
// x: number;
|
|
260
|
-
// y: number;
|
|
261
|
-
// z: number;
|
|
262
|
-
// a: number;
|
|
263
|
-
// b: number;
|
|
264
|
-
// c: number;
|
|
265
|
-
// }
|
|
237
|
+
Developed against TypeScript 4-6 and maintained under Long Term Support (LTS) for existing infrastructure on the 0.x revision line. ESM and CJS compatible.
|
|
266
238
|
|
|
267
|
-
|
|
268
|
-
// Modern Compile
|
|
269
|
-
// ----------------------------------------------------------
|
|
270
|
-
import Schema from 'typebox/schema'
|
|
239
|
+
### Version 1.x
|
|
271
240
|
|
|
272
|
-
|
|
241
|
+
```bash
|
|
242
|
+
$ npm install typebox # 1.x - Latest | TS 7 Native
|
|
273
243
|
```
|
|
274
244
|
|
|
275
|
-
|
|
245
|
+
Developed against the TypeScript 7 native compiler with advanced type inference and JSON Schema 2020-12 compliant validation, with backwards compatibility for `0.x` types. ESM only.
|
|
276
246
|
|
|
277
|
-
|
|
247
|
+
### Additional
|
|
278
248
|
|
|
279
|
-
|
|
249
|
+
The `1.x` version is recommended for most new projects and is the active development line that targets optimizations enabled by the TypeScript 7 native compiler. The `0.x` version is maintained under LTS for environments requiring CJS and ESM compatibility as well as support for older TypeScript compiler versions. For issues relating to `0.x` please submit them to the [TypeBox 0.x](https://github.com/sinclairzx81/sinclair-typebox) repository.
|
|
280
250
|
|
|
281
251
|
## Contribute
|
|
282
252
|
|