@sinclair/typebox 0.33.22 → 0.34.1
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/cjs/compiler/compiler.d.ts +2 -2
- package/build/cjs/compiler/compiler.js +13 -2
- package/build/cjs/errors/errors.js +7 -0
- package/build/cjs/index.d.ts +1 -2
- package/build/cjs/index.js +1 -2
- package/build/cjs/syntax/parse.d.ts +14 -15
- package/build/cjs/syntax/parse.js +6 -5
- package/build/cjs/syntax/runtime.d.ts +20 -4
- package/build/cjs/syntax/runtime.js +183 -28
- package/build/cjs/syntax/static.d.ts +107 -23
- package/build/cjs/type/array/array.d.ts +1 -1
- package/build/cjs/type/awaited/awaited.d.ts +8 -3
- package/build/cjs/type/awaited/awaited.js +20 -20
- package/build/cjs/type/computed/computed.d.ts +9 -0
- package/build/cjs/type/computed/computed.js +10 -0
- package/build/cjs/type/computed/index.d.ts +1 -0
- package/build/cjs/type/{deref → computed}/index.js +1 -1
- package/build/cjs/type/guard/kind.d.ts +12 -4
- package/build/cjs/type/guard/kind.js +15 -0
- package/build/cjs/type/guard/type.d.ts +9 -3
- package/build/cjs/type/guard/type.js +19 -0
- package/build/cjs/type/index.d.ts +1 -2
- package/build/cjs/type/index.js +1 -2
- package/build/cjs/type/indexed/indexed-from-mapped-key.d.ts +6 -6
- package/build/cjs/type/indexed/indexed-from-mapped-key.js +10 -10
- package/build/cjs/type/indexed/indexed-from-mapped-result.d.ts +5 -5
- package/build/cjs/type/indexed/indexed-from-mapped-result.js +11 -10
- package/build/cjs/type/indexed/indexed-property-keys.d.ts +6 -6
- package/build/cjs/type/indexed/indexed-property-keys.js +14 -14
- package/build/cjs/type/indexed/indexed.d.ts +34 -20
- package/build/cjs/type/indexed/indexed.js +59 -46
- package/build/cjs/type/intersect/intersect-evaluated.d.ts +6 -6
- package/build/cjs/type/intersect/intersect-evaluated.js +16 -16
- package/build/cjs/type/intersect/intersect.d.ts +2 -2
- package/build/cjs/type/intersect/intersect.js +6 -6
- package/build/cjs/type/keyof/keyof-from-mapped-result.d.ts +6 -6
- package/build/cjs/type/keyof/keyof-from-mapped-result.js +10 -10
- package/build/cjs/type/keyof/keyof-property-keys.d.ts +7 -7
- package/build/cjs/type/keyof/keyof-property-keys.js +22 -22
- package/build/cjs/type/keyof/keyof.d.ts +11 -6
- package/build/cjs/type/keyof/keyof.js +22 -13
- package/build/cjs/type/module/compute.d.ts +54 -0
- package/build/cjs/type/module/compute.js +154 -0
- package/build/cjs/type/module/index.d.ts +1 -0
- package/build/cjs/type/{strict → module}/index.js +1 -1
- package/build/cjs/type/module/infer.d.ts +43 -0
- package/build/cjs/type/module/infer.js +3 -0
- package/build/cjs/type/module/module.d.ts +27 -0
- package/build/cjs/type/module/module.js +37 -0
- package/build/cjs/type/not/not.d.ts +1 -1
- package/build/cjs/type/not/not.js +2 -2
- package/build/cjs/type/omit/omit-from-mapped-key.d.ts +6 -6
- package/build/cjs/type/omit/omit-from-mapped-key.js +10 -12
- package/build/cjs/type/omit/omit-from-mapped-result.d.ts +5 -5
- package/build/cjs/type/omit/omit-from-mapped-result.js +10 -10
- package/build/cjs/type/omit/omit.d.ts +26 -14
- package/build/cjs/type/omit/omit.js +46 -35
- package/build/cjs/type/partial/partial.d.ts +11 -7
- package/build/cjs/type/partial/partial.js +36 -24
- package/build/cjs/type/pick/pick-from-mapped-key.d.ts +6 -6
- package/build/cjs/type/pick/pick-from-mapped-key.js +10 -10
- package/build/cjs/type/pick/pick-from-mapped-result.d.ts +5 -5
- package/build/cjs/type/pick/pick-from-mapped-result.js +10 -10
- package/build/cjs/type/pick/pick.d.ts +25 -15
- package/build/cjs/type/pick/pick.js +47 -36
- package/build/cjs/type/record/record.d.ts +4 -2
- package/build/cjs/type/record/record.js +31 -28
- package/build/cjs/type/ref/ref.d.ts +4 -7
- package/build/cjs/type/ref/ref.js +3 -11
- package/build/cjs/type/required/required.d.ts +12 -8
- package/build/cjs/type/required/required.js +37 -25
- package/build/cjs/type/static/static.d.ts +1 -1
- package/build/cjs/type/tuple/tuple.d.ts +1 -1
- package/build/cjs/type/tuple/tuple.js +4 -4
- package/build/cjs/type/type/javascript.d.ts +10 -10
- package/build/cjs/type/type/javascript.js +6 -6
- package/build/cjs/type/type/json.d.ts +45 -68
- package/build/cjs/type/type/json.js +82 -98
- package/build/cjs/type/type/type.d.ts +1 -2
- package/build/cjs/type/type/type.js +55 -57
- package/build/cjs/type/union/union-evaluated.d.ts +6 -6
- package/build/cjs/type/union/union-evaluated.js +11 -10
- package/build/cjs/type/union/union.d.ts +1 -1
- package/build/cjs/type/union/union.js +4 -4
- package/build/cjs/value/cast/cast.js +8 -1
- package/build/cjs/value/check/check.js +11 -4
- package/build/cjs/value/clean/clean.js +8 -1
- package/build/cjs/value/convert/convert.js +7 -0
- package/build/cjs/value/create/create.js +7 -0
- package/build/cjs/value/default/default.js +7 -0
- package/build/cjs/value/transform/decode.js +18 -7
- package/build/cjs/value/transform/encode.js +18 -7
- package/build/cjs/value/transform/has.js +18 -18
- package/build/esm/compiler/compiler.d.mts +2 -2
- package/build/esm/compiler/compiler.mjs +13 -2
- package/build/esm/errors/errors.mjs +7 -0
- package/build/esm/index.d.mts +1 -2
- package/build/esm/index.mjs +1 -2
- package/build/esm/syntax/parse.d.mts +14 -15
- package/build/esm/syntax/parse.mjs +6 -5
- package/build/esm/syntax/runtime.d.mts +20 -4
- package/build/esm/syntax/runtime.mjs +183 -28
- package/build/esm/syntax/static.d.mts +107 -23
- package/build/esm/type/array/array.d.mts +1 -1
- package/build/esm/type/awaited/awaited.d.mts +8 -3
- package/build/esm/type/awaited/awaited.mjs +20 -20
- package/build/esm/type/computed/computed.d.mts +9 -0
- package/build/esm/type/computed/computed.mjs +6 -0
- package/build/esm/type/computed/index.d.mts +1 -0
- package/build/esm/type/computed/index.mjs +1 -0
- package/build/esm/type/guard/kind.d.mts +12 -4
- package/build/esm/type/guard/kind.mjs +12 -0
- package/build/esm/type/guard/type.d.mts +9 -3
- package/build/esm/type/guard/type.mjs +17 -0
- package/build/esm/type/index.d.mts +1 -2
- package/build/esm/type/index.mjs +1 -2
- package/build/esm/type/indexed/indexed-from-mapped-key.d.mts +6 -6
- package/build/esm/type/indexed/indexed-from-mapped-key.mjs +10 -10
- package/build/esm/type/indexed/indexed-from-mapped-result.d.mts +5 -5
- package/build/esm/type/indexed/indexed-from-mapped-result.mjs +11 -10
- package/build/esm/type/indexed/indexed-property-keys.d.mts +6 -6
- package/build/esm/type/indexed/indexed-property-keys.mjs +14 -14
- package/build/esm/type/indexed/indexed.d.mts +34 -20
- package/build/esm/type/indexed/indexed.mjs +55 -42
- package/build/esm/type/intersect/intersect-evaluated.d.mts +6 -6
- package/build/esm/type/intersect/intersect-evaluated.mjs +16 -16
- package/build/esm/type/intersect/intersect.d.mts +2 -2
- package/build/esm/type/intersect/intersect.mjs +6 -6
- package/build/esm/type/keyof/keyof-from-mapped-result.d.mts +6 -6
- package/build/esm/type/keyof/keyof-from-mapped-result.mjs +10 -10
- package/build/esm/type/keyof/keyof-property-keys.d.mts +7 -7
- package/build/esm/type/keyof/keyof-property-keys.mjs +22 -22
- package/build/esm/type/keyof/keyof.d.mts +11 -6
- package/build/esm/type/keyof/keyof.mjs +22 -13
- package/build/esm/type/module/compute.d.mts +54 -0
- package/build/esm/type/module/compute.mjs +148 -0
- package/build/esm/type/module/index.d.mts +1 -0
- package/build/esm/type/module/index.mjs +1 -0
- package/build/esm/type/module/infer.d.mts +43 -0
- package/build/esm/type/module/infer.mjs +1 -0
- package/build/esm/type/module/module.d.mts +27 -0
- package/build/esm/type/module/module.mjs +31 -0
- package/build/esm/type/not/not.d.mts +1 -1
- package/build/esm/type/not/not.mjs +2 -2
- package/build/esm/type/omit/omit-from-mapped-key.d.mts +6 -6
- package/build/esm/type/omit/omit-from-mapped-key.mjs +10 -12
- package/build/esm/type/omit/omit-from-mapped-result.d.mts +5 -5
- package/build/esm/type/omit/omit-from-mapped-result.mjs +10 -10
- package/build/esm/type/omit/omit.d.mts +26 -14
- package/build/esm/type/omit/omit.mjs +43 -32
- package/build/esm/type/partial/partial.d.mts +11 -7
- package/build/esm/type/partial/partial.mjs +29 -17
- package/build/esm/type/pick/pick-from-mapped-key.d.mts +6 -6
- package/build/esm/type/pick/pick-from-mapped-key.mjs +10 -10
- package/build/esm/type/pick/pick-from-mapped-result.d.mts +5 -5
- package/build/esm/type/pick/pick-from-mapped-result.mjs +10 -10
- package/build/esm/type/pick/pick.d.mts +25 -15
- package/build/esm/type/pick/pick.mjs +43 -32
- package/build/esm/type/record/record.d.mts +4 -2
- package/build/esm/type/record/record.mjs +15 -12
- package/build/esm/type/ref/ref.d.mts +4 -7
- package/build/esm/type/ref/ref.mjs +3 -11
- package/build/esm/type/required/required.d.mts +12 -8
- package/build/esm/type/required/required.mjs +33 -21
- package/build/esm/type/static/static.d.mts +1 -1
- package/build/esm/type/tuple/tuple.d.mts +1 -1
- package/build/esm/type/tuple/tuple.mjs +4 -4
- package/build/esm/type/type/javascript.d.mts +10 -10
- package/build/esm/type/type/javascript.mjs +6 -6
- package/build/esm/type/type/json.d.mts +45 -68
- package/build/esm/type/type/json.mjs +47 -63
- package/build/esm/type/type/type.d.mts +1 -2
- package/build/esm/type/type/type.mjs +1 -2
- package/build/esm/type/union/union-evaluated.d.mts +6 -6
- package/build/esm/type/union/union-evaluated.mjs +11 -10
- package/build/esm/type/union/union.d.mts +1 -1
- package/build/esm/type/union/union.mjs +4 -4
- package/build/esm/value/cast/cast.mjs +9 -2
- package/build/esm/value/check/check.mjs +11 -4
- package/build/esm/value/clean/clean.mjs +9 -2
- package/build/esm/value/convert/convert.mjs +7 -0
- package/build/esm/value/create/create.mjs +7 -0
- package/build/esm/value/default/default.mjs +7 -0
- package/build/esm/value/transform/decode.mjs +13 -2
- package/build/esm/value/transform/encode.mjs +13 -2
- package/build/esm/value/transform/has.mjs +2 -2
- package/package.json +1 -1
- package/readme.md +230 -97
- package/build/cjs/type/deref/deref.d.ts +0 -22
- package/build/cjs/type/deref/deref.js +0 -106
- package/build/cjs/type/deref/index.d.ts +0 -1
- package/build/cjs/type/strict/index.d.ts +0 -1
- package/build/cjs/type/strict/strict.d.ts +0 -12
- package/build/cjs/type/strict/strict.js +0 -16
- package/build/esm/type/deref/deref.d.mts +0 -22
- package/build/esm/type/deref/deref.mjs +0 -102
- package/build/esm/type/deref/index.d.mts +0 -1
- package/build/esm/type/deref/index.mjs +0 -1
- package/build/esm/type/strict/index.d.mts +0 -1
- package/build/esm/type/strict/index.mjs +0 -1
- package/build/esm/type/strict/strict.d.mts +0 -12
- package/build/esm/type/strict/strict.mjs +0 -12
|
@@ -5,76 +5,76 @@ exports.HasTransform = HasTransform;
|
|
|
5
5
|
const index_1 = require("../deref/index");
|
|
6
6
|
const index_2 = require("../../type/symbols/index");
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
|
-
//
|
|
8
|
+
// KindGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
|
-
const
|
|
10
|
+
const kind_1 = require("../../type/guard/kind");
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// ValueGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
14
|
const index_3 = require("../guard/index");
|
|
15
15
|
// prettier-ignore
|
|
16
16
|
function FromArray(schema, references) {
|
|
17
|
-
return (0,
|
|
17
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.items, references);
|
|
18
18
|
}
|
|
19
19
|
// prettier-ignore
|
|
20
20
|
function FromAsyncIterator(schema, references) {
|
|
21
|
-
return (0,
|
|
21
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.items, references);
|
|
22
22
|
}
|
|
23
23
|
// prettier-ignore
|
|
24
24
|
function FromConstructor(schema, references) {
|
|
25
|
-
return (0,
|
|
25
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.returns, references) || schema.parameters.some((schema) => Visit(schema, references));
|
|
26
26
|
}
|
|
27
27
|
// prettier-ignore
|
|
28
28
|
function FromFunction(schema, references) {
|
|
29
|
-
return (0,
|
|
29
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.returns, references) || schema.parameters.some((schema) => Visit(schema, references));
|
|
30
30
|
}
|
|
31
31
|
// prettier-ignore
|
|
32
32
|
function FromIntersect(schema, references) {
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, kind_1.IsTransform)(schema) || (0, kind_1.IsTransform)(schema.unevaluatedProperties) || schema.allOf.some((schema) => Visit(schema, references));
|
|
34
34
|
}
|
|
35
35
|
// prettier-ignore
|
|
36
36
|
function FromIterator(schema, references) {
|
|
37
|
-
return (0,
|
|
37
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.items, references);
|
|
38
38
|
}
|
|
39
39
|
// prettier-ignore
|
|
40
40
|
function FromNot(schema, references) {
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.not, references);
|
|
42
42
|
}
|
|
43
43
|
// prettier-ignore
|
|
44
44
|
function FromObject(schema, references) {
|
|
45
|
-
return ((0,
|
|
45
|
+
return ((0, kind_1.IsTransform)(schema) ||
|
|
46
46
|
Object.values(schema.properties).some((schema) => Visit(schema, references)) ||
|
|
47
|
-
((0,
|
|
47
|
+
((0, kind_1.IsSchema)(schema.additionalProperties) && Visit(schema.additionalProperties, references)));
|
|
48
48
|
}
|
|
49
49
|
// prettier-ignore
|
|
50
50
|
function FromPromise(schema, references) {
|
|
51
|
-
return (0,
|
|
51
|
+
return (0, kind_1.IsTransform)(schema) || Visit(schema.item, references);
|
|
52
52
|
}
|
|
53
53
|
// prettier-ignore
|
|
54
54
|
function FromRecord(schema, references) {
|
|
55
55
|
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
56
56
|
const property = schema.patternProperties[pattern];
|
|
57
|
-
return (0,
|
|
57
|
+
return (0, kind_1.IsTransform)(schema) || Visit(property, references) || ((0, kind_1.IsSchema)(schema.additionalProperties) && (0, kind_1.IsTransform)(schema.additionalProperties));
|
|
58
58
|
}
|
|
59
59
|
// prettier-ignore
|
|
60
60
|
function FromRef(schema, references) {
|
|
61
|
-
if ((0,
|
|
61
|
+
if ((0, kind_1.IsTransform)(schema))
|
|
62
62
|
return true;
|
|
63
63
|
return Visit((0, index_1.Deref)(schema, references), references);
|
|
64
64
|
}
|
|
65
65
|
// prettier-ignore
|
|
66
66
|
function FromThis(schema, references) {
|
|
67
|
-
if ((0,
|
|
67
|
+
if ((0, kind_1.IsTransform)(schema))
|
|
68
68
|
return true;
|
|
69
69
|
return Visit((0, index_1.Deref)(schema, references), references);
|
|
70
70
|
}
|
|
71
71
|
// prettier-ignore
|
|
72
72
|
function FromTuple(schema, references) {
|
|
73
|
-
return (0,
|
|
73
|
+
return (0, kind_1.IsTransform)(schema) || (!(0, index_3.IsUndefined)(schema.items) && schema.items.some((schema) => Visit(schema, references)));
|
|
74
74
|
}
|
|
75
75
|
// prettier-ignore
|
|
76
76
|
function FromUnion(schema, references) {
|
|
77
|
-
return (0,
|
|
77
|
+
return (0, kind_1.IsTransform)(schema) || schema.anyOf.some((schema) => Visit(schema, references));
|
|
78
78
|
}
|
|
79
79
|
// prettier-ignore
|
|
80
80
|
function Visit(schema, references) {
|
|
@@ -114,7 +114,7 @@ function Visit(schema, references) {
|
|
|
114
114
|
case 'Union':
|
|
115
115
|
return FromUnion(schema_, references_);
|
|
116
116
|
default:
|
|
117
|
-
return (0,
|
|
117
|
+
return (0, kind_1.IsTransform)(schema);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
const visited = new Set();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ValueErrorIterator } from '../errors/index.mjs';
|
|
2
2
|
import { TypeBoxError } from '../type/error/index.mjs';
|
|
3
3
|
import type { TSchema } from '../type/schema/index.mjs';
|
|
4
|
-
import type { Static, StaticDecode } from '../type/static/index.mjs';
|
|
4
|
+
import type { Static, StaticDecode, StaticEncode } from '../type/static/index.mjs';
|
|
5
5
|
export type CheckFunction = (value: unknown) => boolean;
|
|
6
6
|
export declare class TypeCheck<T extends TSchema> {
|
|
7
7
|
private readonly schema;
|
|
@@ -19,7 +19,7 @@ export declare class TypeCheck<T extends TSchema> {
|
|
|
19
19
|
/** Decodes a value or throws if error */
|
|
20
20
|
Decode<Static = StaticDecode<T>, Result extends Static = Static>(value: unknown): Result;
|
|
21
21
|
/** Encodes a value or throws if error */
|
|
22
|
-
Encode<Static =
|
|
22
|
+
Encode<Static = StaticEncode<T>, Result extends Static = Static>(value: unknown): Result;
|
|
23
23
|
}
|
|
24
24
|
export declare class TypeCompilerUnknownTypeError extends TypeBoxError {
|
|
25
25
|
readonly schema: TSchema;
|
|
@@ -255,6 +255,11 @@ export var TypeCompiler;
|
|
|
255
255
|
function* FromFunction(schema, references, value) {
|
|
256
256
|
yield `(typeof ${value} === 'function')`;
|
|
257
257
|
}
|
|
258
|
+
function* FromImport(schema, references, value) {
|
|
259
|
+
const definitions = globalThis.Object.values(schema.$defs);
|
|
260
|
+
const target = schema.$defs[schema.$ref];
|
|
261
|
+
yield* Visit(target, [...references, ...definitions], value);
|
|
262
|
+
}
|
|
258
263
|
function* FromInteger(schema, references, value) {
|
|
259
264
|
yield `Number.isInteger(${value})`;
|
|
260
265
|
if (IsNumber(schema.exclusiveMaximum))
|
|
@@ -372,9 +377,13 @@ export var TypeCompiler;
|
|
|
372
377
|
function* FromRef(schema, references, value) {
|
|
373
378
|
const target = Deref(schema, references);
|
|
374
379
|
// Reference: If we have seen this reference before we can just yield and return the function call.
|
|
375
|
-
// If this isn't the case we defer to visit to generate and set the
|
|
376
|
-
|
|
380
|
+
// If this isn't the case we defer to visit to generate and set the _recursion_end_for_ for subsequent
|
|
381
|
+
// passes. This operation is very awkward as we are using the functions state to store values to
|
|
382
|
+
// enable self referential types to terminate. This needs to be refactored.
|
|
383
|
+
const recursiveEnd = `_recursion_end_for_${schema.$ref}`;
|
|
384
|
+
if (state.functions.has(recursiveEnd))
|
|
377
385
|
return yield `${CreateFunctionName(schema.$ref)}(${value})`;
|
|
386
|
+
state.functions.set(recursiveEnd, ''); // terminate recursion here by setting the name.
|
|
378
387
|
yield* Visit(target, references, value);
|
|
379
388
|
}
|
|
380
389
|
function* FromRegExp(schema, references, value) {
|
|
@@ -481,6 +490,8 @@ export var TypeCompiler;
|
|
|
481
490
|
return yield* FromDate(schema_, references_, value);
|
|
482
491
|
case 'Function':
|
|
483
492
|
return yield* FromFunction(schema_, references_, value);
|
|
493
|
+
case 'Import':
|
|
494
|
+
return yield* FromImport(schema_, references_, value);
|
|
484
495
|
case 'Integer':
|
|
485
496
|
return yield* FromInteger(schema_, references_, value);
|
|
486
497
|
case 'Intersect':
|
|
@@ -232,6 +232,11 @@ function* FromFunction(schema, references, path, value) {
|
|
|
232
232
|
if (!IsFunction(value))
|
|
233
233
|
yield Create(ValueErrorType.Function, schema, path, value);
|
|
234
234
|
}
|
|
235
|
+
function* FromImport(schema, references, path, value) {
|
|
236
|
+
const definitions = globalThis.Object.values(schema.$defs);
|
|
237
|
+
const target = schema.$defs[schema.$ref];
|
|
238
|
+
yield* Visit(target, [...references, ...definitions], path, value);
|
|
239
|
+
}
|
|
235
240
|
function* FromInteger(schema, references, path, value) {
|
|
236
241
|
if (!IsInteger(value))
|
|
237
242
|
return yield Create(ValueErrorType.Integer, schema, path, value);
|
|
@@ -523,6 +528,8 @@ function* Visit(schema, references, path, value) {
|
|
|
523
528
|
return yield* FromDate(schema_, references_, path, value);
|
|
524
529
|
case 'Function':
|
|
525
530
|
return yield* FromFunction(schema_, references_, path, value);
|
|
531
|
+
case 'Import':
|
|
532
|
+
return yield* FromImport(schema_, references_, path, value);
|
|
526
533
|
case 'Integer':
|
|
527
534
|
return yield* FromInteger(schema_, references_, path, value);
|
|
528
535
|
case 'Intersect':
|
package/build/esm/index.d.mts
CHANGED
|
@@ -18,7 +18,6 @@ export * from './type/const/index.mjs';
|
|
|
18
18
|
export * from './type/constructor/index.mjs';
|
|
19
19
|
export * from './type/constructor-parameters/index.mjs';
|
|
20
20
|
export * from './type/date/index.mjs';
|
|
21
|
-
export * from './type/deref/index.mjs';
|
|
22
21
|
export * from './type/enum/index.mjs';
|
|
23
22
|
export * from './type/exclude/index.mjs';
|
|
24
23
|
export * from './type/extends/index.mjs';
|
|
@@ -32,6 +31,7 @@ export * from './type/iterator/index.mjs';
|
|
|
32
31
|
export * from './type/intrinsic/index.mjs';
|
|
33
32
|
export * from './type/keyof/index.mjs';
|
|
34
33
|
export * from './type/literal/index.mjs';
|
|
34
|
+
export * from './type/module/index.mjs';
|
|
35
35
|
export * from './type/mapped/index.mjs';
|
|
36
36
|
export * from './type/never/index.mjs';
|
|
37
37
|
export * from './type/not/index.mjs';
|
|
@@ -55,7 +55,6 @@ export * from './type/rest/index.mjs';
|
|
|
55
55
|
export * from './type/return-type/index.mjs';
|
|
56
56
|
export * from './type/schema/index.mjs';
|
|
57
57
|
export * from './type/static/index.mjs';
|
|
58
|
-
export * from './type/strict/index.mjs';
|
|
59
58
|
export * from './type/string/index.mjs';
|
|
60
59
|
export * from './type/symbol/index.mjs';
|
|
61
60
|
export * from './type/template-literal/index.mjs';
|
package/build/esm/index.mjs
CHANGED
|
@@ -24,7 +24,6 @@ export * from './type/const/index.mjs';
|
|
|
24
24
|
export * from './type/constructor/index.mjs';
|
|
25
25
|
export * from './type/constructor-parameters/index.mjs';
|
|
26
26
|
export * from './type/date/index.mjs';
|
|
27
|
-
export * from './type/deref/index.mjs';
|
|
28
27
|
export * from './type/enum/index.mjs';
|
|
29
28
|
export * from './type/exclude/index.mjs';
|
|
30
29
|
export * from './type/extends/index.mjs';
|
|
@@ -38,6 +37,7 @@ export * from './type/iterator/index.mjs';
|
|
|
38
37
|
export * from './type/intrinsic/index.mjs';
|
|
39
38
|
export * from './type/keyof/index.mjs';
|
|
40
39
|
export * from './type/literal/index.mjs';
|
|
40
|
+
export * from './type/module/index.mjs';
|
|
41
41
|
export * from './type/mapped/index.mjs';
|
|
42
42
|
export * from './type/never/index.mjs';
|
|
43
43
|
export * from './type/not/index.mjs';
|
|
@@ -61,7 +61,6 @@ export * from './type/rest/index.mjs';
|
|
|
61
61
|
export * from './type/return-type/index.mjs';
|
|
62
62
|
export * from './type/schema/index.mjs';
|
|
63
63
|
export * from './type/static/index.mjs';
|
|
64
|
-
export * from './type/strict/index.mjs';
|
|
65
64
|
export * from './type/string/index.mjs';
|
|
66
65
|
export * from './type/symbol/index.mjs';
|
|
67
66
|
export * from './type/template-literal/index.mjs';
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import * as Types from '../type/index.mjs';
|
|
1
2
|
import { Static } from './parsebox/index.mjs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** `[
|
|
6
|
-
export type
|
|
7
|
-
/** `[
|
|
8
|
-
export
|
|
9
|
-
/** `[
|
|
10
|
-
export declare function Parse<
|
|
11
|
-
/** `[
|
|
12
|
-
export declare function
|
|
13
|
-
/** `[
|
|
14
|
-
export declare function ParseOnly<
|
|
15
|
-
/** `[Experimental]` Parses a TypeBox TSchema from TypeScript syntax */
|
|
16
|
-
export declare function ParseOnly<Code extends string>(code: Code, options?: SchemaOptions): TSchema | undefined;
|
|
3
|
+
import { Main } from './static.mjs';
|
|
4
|
+
/** `[Syntax]` Infers a TypeBox type from TypeScript syntax. */
|
|
5
|
+
export type StaticParseAsSchema<Context extends Record<PropertyKey, Types.TSchema>, Code extends string> = Static.Parse<Main, Code, Context>[0];
|
|
6
|
+
/** `[Syntax]` Infers a TypeScript type from TypeScript syntax. */
|
|
7
|
+
export type StaticParseAsType<Context extends Record<PropertyKey, Types.TSchema>, Code extends string> = StaticParseAsSchema<Context, Code> extends infer Type extends Types.TSchema ? Types.StaticDecode<Type> : undefined;
|
|
8
|
+
/** `[Syntax]` Parses a TypeBox type from TypeScript syntax. */
|
|
9
|
+
export declare function Parse<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): StaticParseAsSchema<Context, Code>;
|
|
10
|
+
/** `[Syntax]` Parses a TypeBox type from TypeScript syntax. */
|
|
11
|
+
export declare function Parse<Code extends string>(code: Code, options?: Types.SchemaOptions): StaticParseAsSchema<{}, Code>;
|
|
12
|
+
/** `[Syntax]` Parses a TypeBox TSchema from TypeScript syntax. This function does not infer the type. */
|
|
13
|
+
export declare function ParseOnly<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined;
|
|
14
|
+
/** `[Syntax]` Parses a TypeBox TSchema from TypeScript syntax */
|
|
15
|
+
export declare function ParseOnly<Code extends string>(code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Types from '../type/index.mjs';
|
|
2
2
|
import { Module } from './runtime.mjs';
|
|
3
|
-
/** `[
|
|
3
|
+
/** `[Syntax]` Parses a TypeBox type from TypeScript syntax. */
|
|
4
4
|
export function Parse(...args) {
|
|
5
5
|
return ParseOnly.apply(null, args);
|
|
6
6
|
}
|
|
7
|
-
/** `[
|
|
7
|
+
/** `[Syntax]` Parses a TypeBox TSchema from TypeScript syntax. This function does not infer the type. */
|
|
8
8
|
export function ParseOnly(...args) {
|
|
9
9
|
const withContext = typeof args[0] === 'string' ? false : true;
|
|
10
10
|
const [context, code, options] = withContext ? [args[0], args[1], args[2] || {}] : [{}, args[0], args[1] || {}];
|
|
11
|
-
const type = Module.Parse('
|
|
12
|
-
return
|
|
11
|
+
const type = Module.Parse('Main', code, context)[0];
|
|
12
|
+
// Note: Parsing may return either a ModuleInstance or Type. We only apply options on the Type.
|
|
13
|
+
return Types.KindGuard.IsSchema(type) ? Types.CloneType(type, options) : type;
|
|
13
14
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { Runtime } from './parsebox/index.mjs';
|
|
2
2
|
import * as Types from '../type/index.mjs';
|
|
3
3
|
export declare const Module: Runtime.Module<{
|
|
4
|
+
ExportModifier: Runtime.IUnion<boolean>;
|
|
5
|
+
HeritageList: Runtime.IUnion<Types.TSchema[]>;
|
|
6
|
+
Heritage: Runtime.IUnion<unknown[]>;
|
|
7
|
+
InterfaceDeclaration: Runtime.ITuple<{
|
|
8
|
+
[x: string]: Types.TIntersect<[...Types.TRef<string>[], Types.TObject<Types.TProperties>]>;
|
|
9
|
+
}>;
|
|
10
|
+
TypeAliasDeclaration: Runtime.ITuple<{
|
|
11
|
+
[x: string]: Types.TSchema;
|
|
12
|
+
}>;
|
|
13
|
+
ModuleType: Runtime.IUnion<unknown>;
|
|
14
|
+
ModuleProperties: Runtime.IUnion<Types.TProperties>;
|
|
15
|
+
ModuleDeclaration: Runtime.ITuple<Types.TModule<Types.TProperties, {
|
|
16
|
+
[x: string]: Types.TSchema;
|
|
17
|
+
[x: number]: Types.TSchema;
|
|
18
|
+
}>>;
|
|
4
19
|
Literal: Runtime.IUnion<Types.TLiteral<string> | Types.TLiteral<number> | Types.TLiteral<boolean>>;
|
|
5
20
|
Keyword: Runtime.IUnion<Types.TAny | Types.TNever | Types.TString | Types.TBoolean | Types.TNumber | Types.TInteger | Types.TBigInt | Types.TNull | Types.TSymbol | Types.TUndefined | Types.TUnknown | Types.TVoid>;
|
|
6
21
|
KeyOf: Runtime.IUnion<boolean>;
|
|
@@ -14,14 +29,14 @@ export declare const Module: Runtime.Module<{
|
|
|
14
29
|
Expr: Runtime.ITuple<Types.TSchema>;
|
|
15
30
|
Type: Runtime.IRef<unknown>;
|
|
16
31
|
PropertyKey: Runtime.IUnion<string>;
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
Readonly: Runtime.IUnion<boolean>;
|
|
33
|
+
Optional: Runtime.IUnion<boolean>;
|
|
19
34
|
Property: Runtime.ITuple<{
|
|
20
35
|
[x: string]: Types.TSchema;
|
|
21
36
|
}>;
|
|
22
37
|
PropertyDelimiter: Runtime.IUnion<[","] | [",", "\n"] | [";"] | [";", "\n"] | ["\n"]>;
|
|
23
|
-
Properties: Runtime.IUnion<
|
|
24
|
-
Object: Runtime.ITuple<Types.TObject<
|
|
38
|
+
Properties: Runtime.IUnion<Types.TProperties>;
|
|
39
|
+
Object: Runtime.ITuple<Types.TObject<Types.TProperties>>;
|
|
25
40
|
Elements: Runtime.IUnion<unknown[]>;
|
|
26
41
|
Tuple: Runtime.ITuple<Types.TTuple<Types.TSchema[]>>;
|
|
27
42
|
Parameter: Runtime.ITuple<Types.TSchema>;
|
|
@@ -52,4 +67,5 @@ export declare const Module: Runtime.Module<{
|
|
|
52
67
|
Date: Runtime.IConst<Types.TDate>;
|
|
53
68
|
Uint8Array: Runtime.IConst<Types.TUint8Array>;
|
|
54
69
|
Reference: Runtime.IIdent<Types.TSchema>;
|
|
70
|
+
Main: Runtime.IUnion<unknown>;
|
|
55
71
|
}>;
|
|
@@ -19,6 +19,7 @@ const SemiColon = ';';
|
|
|
19
19
|
const SingleQuote = "'";
|
|
20
20
|
const DoubleQuote = '"';
|
|
21
21
|
const Tilde = '`';
|
|
22
|
+
const Equals = '=';
|
|
22
23
|
// ------------------------------------------------------------------
|
|
23
24
|
// DestructureRight
|
|
24
25
|
// ------------------------------------------------------------------
|
|
@@ -29,12 +30,133 @@ function DestructureRight(values) {
|
|
|
29
30
|
: [values, undefined];
|
|
30
31
|
}
|
|
31
32
|
// ------------------------------------------------------------------
|
|
33
|
+
// Deref
|
|
34
|
+
// ------------------------------------------------------------------
|
|
35
|
+
const Deref = (context, key) => {
|
|
36
|
+
return key in context ? context[key] : Types.Ref(key);
|
|
37
|
+
};
|
|
38
|
+
// ------------------------------------------------------------------
|
|
39
|
+
// ExportModifier
|
|
40
|
+
// ------------------------------------------------------------------
|
|
41
|
+
// prettier-ignore
|
|
42
|
+
const ExportModifierMapping = (values) => {
|
|
43
|
+
return values.length === 1;
|
|
44
|
+
};
|
|
45
|
+
// prettier-ignore
|
|
46
|
+
const ExportModifier = Runtime.Union([
|
|
47
|
+
Runtime.Tuple([Runtime.Const('export')]), Runtime.Tuple([])
|
|
48
|
+
], ExportModifierMapping);
|
|
49
|
+
// ------------------------------------------------------------------
|
|
50
|
+
// TypeAliasDeclaration
|
|
51
|
+
// ------------------------------------------------------------------
|
|
52
|
+
// prettier-ignore
|
|
53
|
+
const TypeAliasDeclarationMapping = (_Export, _Keyword, Ident, _Equals, Type) => {
|
|
54
|
+
return { [Ident]: Type };
|
|
55
|
+
};
|
|
56
|
+
// prettier-ignore
|
|
57
|
+
const TypeAliasDeclaration = Runtime.Tuple([
|
|
58
|
+
Runtime.Ref('ExportModifier'),
|
|
59
|
+
Runtime.Const('type'),
|
|
60
|
+
Runtime.Ident(),
|
|
61
|
+
Runtime.Const(Equals),
|
|
62
|
+
Runtime.Ref('Type')
|
|
63
|
+
], value => TypeAliasDeclarationMapping(...value));
|
|
64
|
+
// ------------------------------------------------------------------
|
|
65
|
+
// HeritageList
|
|
66
|
+
// ------------------------------------------------------------------
|
|
67
|
+
// prettier-ignore (note, heritage list should disallow trailing comma)
|
|
68
|
+
const HeritageListDelimiter = Runtime.Union([Runtime.Tuple([Runtime.Const(Comma), Runtime.Const(Newline)]), Runtime.Tuple([Runtime.Const(Comma)])]);
|
|
69
|
+
// prettier-ignore
|
|
70
|
+
const HeritageListMapping = (values, context) => {
|
|
71
|
+
return (values.length === 3 ? [Deref(context, values[0]), ...values[2]] :
|
|
72
|
+
values.length === 1 ? [Deref(context, values[0])] :
|
|
73
|
+
[]);
|
|
74
|
+
};
|
|
75
|
+
// prettier-ignore
|
|
76
|
+
const HeritageList = Runtime.Union([
|
|
77
|
+
Runtime.Tuple([Runtime.Ident(), HeritageListDelimiter, Runtime.Ref('HeritageList')]),
|
|
78
|
+
Runtime.Tuple([Runtime.Ident()]),
|
|
79
|
+
Runtime.Tuple([])
|
|
80
|
+
], HeritageListMapping);
|
|
81
|
+
// ------------------------------------------------------------------
|
|
82
|
+
// Heritage
|
|
83
|
+
// ------------------------------------------------------------------
|
|
84
|
+
// prettier-ignore
|
|
85
|
+
const HeritageMapping = (values) => {
|
|
86
|
+
return (values.length === 2 ? values[1] : []);
|
|
87
|
+
};
|
|
88
|
+
// prettier-ignore
|
|
89
|
+
const Heritage = Runtime.Union([
|
|
90
|
+
Runtime.Tuple([Runtime.Const('extends'), Runtime.Ref('HeritageList')]),
|
|
91
|
+
Runtime.Tuple([])
|
|
92
|
+
], HeritageMapping);
|
|
93
|
+
// ------------------------------------------------------------------
|
|
94
|
+
// InterfaceDeclaration
|
|
95
|
+
// ------------------------------------------------------------------
|
|
96
|
+
// prettier-ignore
|
|
97
|
+
const InterfaceDeclarationMapping = (_0, _1, Ident, Heritage, _4, Properties, _6) => {
|
|
98
|
+
return { [Ident]: Types.Intersect([...Heritage, Types.Object(Properties)]) };
|
|
99
|
+
};
|
|
100
|
+
// prettier-ignore
|
|
101
|
+
const InterfaceDeclaration = Runtime.Tuple([
|
|
102
|
+
Runtime.Ref('ExportModifier'),
|
|
103
|
+
Runtime.Const('interface'),
|
|
104
|
+
Runtime.Ident(),
|
|
105
|
+
Runtime.Ref('Heritage'),
|
|
106
|
+
Runtime.Const(LBrace),
|
|
107
|
+
Runtime.Ref('Properties'),
|
|
108
|
+
Runtime.Const(RBrace),
|
|
109
|
+
], values => InterfaceDeclarationMapping(...values));
|
|
110
|
+
// ------------------------------------------------------------------
|
|
111
|
+
// ModuleType
|
|
112
|
+
// ------------------------------------------------------------------
|
|
113
|
+
// prettier-ignore
|
|
114
|
+
const ModuleType = Runtime.Union([
|
|
115
|
+
Runtime.Ref('InterfaceDeclaration'),
|
|
116
|
+
Runtime.Ref('TypeAliasDeclaration')
|
|
117
|
+
]);
|
|
118
|
+
// ------------------------------------------------------------------
|
|
119
|
+
// ModuleProperties
|
|
120
|
+
// ------------------------------------------------------------------
|
|
121
|
+
// prettier-ignore
|
|
122
|
+
const ModulePropertiesDelimiter = Runtime.Union([
|
|
123
|
+
Runtime.Tuple([Runtime.Const(SemiColon), Runtime.Const(Newline)]),
|
|
124
|
+
Runtime.Tuple([Runtime.Const(SemiColon)]),
|
|
125
|
+
Runtime.Tuple([Runtime.Const(Newline)]),
|
|
126
|
+
]);
|
|
127
|
+
// prettier-ignore
|
|
128
|
+
const ModulePropertiesMapping = (values) => {
|
|
129
|
+
return (values.length === 3 ? { ...values[0], ...values[2] } :
|
|
130
|
+
values.length === 1 ? values[0] :
|
|
131
|
+
{});
|
|
132
|
+
};
|
|
133
|
+
// prettier-ignore
|
|
134
|
+
const ModuleProperties = Runtime.Union([
|
|
135
|
+
Runtime.Tuple([Runtime.Ref('ModuleType'), ModulePropertiesDelimiter, Runtime.Ref('ModuleProperties')]),
|
|
136
|
+
Runtime.Tuple([Runtime.Ref('ModuleType')]),
|
|
137
|
+
Runtime.Tuple([]),
|
|
138
|
+
], ModulePropertiesMapping);
|
|
139
|
+
// ------------------------------------------------------------------
|
|
140
|
+
// ModuleDeclaration
|
|
141
|
+
// ------------------------------------------------------------------
|
|
142
|
+
// prettier-ignore
|
|
143
|
+
const ModuleIdentifier = Runtime.Union([
|
|
144
|
+
Runtime.Tuple([Runtime.Ident()]),
|
|
145
|
+
Runtime.Tuple([])
|
|
146
|
+
]);
|
|
147
|
+
// prettier-ignore
|
|
148
|
+
const ModuleDeclarationMapping = (_1, _2, _Ident, _3, Properties, _5) => {
|
|
149
|
+
return Types.Module(Properties);
|
|
150
|
+
};
|
|
151
|
+
// prettier-ignore
|
|
152
|
+
const ModuleDeclaration = Runtime.Tuple([
|
|
153
|
+
Runtime.Ref('ExportModifier'), Runtime.Const('module'), ModuleIdentifier, Runtime.Const(LBrace), Runtime.Ref('ModuleProperties'), Runtime.Const(RBrace)
|
|
154
|
+
], values => ModuleDeclarationMapping(...values));
|
|
155
|
+
// ------------------------------------------------------------------
|
|
32
156
|
// Reference
|
|
33
157
|
// ------------------------------------------------------------------
|
|
34
158
|
// prettier-ignore
|
|
35
|
-
const Reference = Runtime.Ident((value, context) =>
|
|
36
|
-
return value in context ? context[value] : Types.Ref(value);
|
|
37
|
-
});
|
|
159
|
+
const Reference = Runtime.Ident((value, context) => Deref(context, value));
|
|
38
160
|
// ------------------------------------------------------------------
|
|
39
161
|
// Literal
|
|
40
162
|
// ------------------------------------------------------------------
|
|
@@ -157,7 +279,9 @@ const FactorExtends = (Type, Extends) => {
|
|
|
157
279
|
// prettier-ignore
|
|
158
280
|
const FactorIndexArray = (Type, IndexArray) => {
|
|
159
281
|
const [Left, Right] = DestructureRight(IndexArray);
|
|
160
|
-
return (!Types.ValueGuard.IsUndefined(Right) ? (
|
|
282
|
+
return (!Types.ValueGuard.IsUndefined(Right) ? (
|
|
283
|
+
// note: Indexed types require reimplementation to replace `[number]` indexers
|
|
284
|
+
Right.length === 1 ? Types.Index(FactorIndexArray(Type, Left), Right[0]) :
|
|
161
285
|
Right.length === 0 ? Types.Array(FactorIndexArray(Type, Left)) :
|
|
162
286
|
Types.Never()) : Type);
|
|
163
287
|
};
|
|
@@ -220,24 +344,21 @@ const Type = Runtime.Ref('Expr');
|
|
|
220
344
|
// ------------------------------------------------------------------
|
|
221
345
|
// Properties
|
|
222
346
|
// ------------------------------------------------------------------
|
|
223
|
-
// prettier-ignore
|
|
224
347
|
const PropertyKey = Runtime.Union([Runtime.Ident(), Runtime.String([SingleQuote, DoubleQuote])]);
|
|
348
|
+
const Readonly = Runtime.Union([Runtime.Tuple([Runtime.Const('readonly')]), Runtime.Tuple([])], (value) => value.length > 0);
|
|
349
|
+
const Optional = Runtime.Union([Runtime.Tuple([Runtime.Const(Question)]), Runtime.Tuple([])], (value) => value.length > 0);
|
|
225
350
|
// prettier-ignore
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const PropertyMapping = (Readonly, Key, Optional, _, Type) => ({
|
|
231
|
-
[Key]: (Readonly && Optional ? Types.ReadonlyOptional(Type) :
|
|
232
|
-
Readonly && !Optional ? Types.Readonly(Type) :
|
|
233
|
-
!Readonly && Optional ? Types.Optional(Type) :
|
|
351
|
+
const PropertyMapping = (IsReadonly, Key, IsOptional, _, Type) => ({
|
|
352
|
+
[Key]: (IsReadonly && IsOptional ? Types.ReadonlyOptional(Type) :
|
|
353
|
+
IsReadonly && !IsOptional ? Types.Readonly(Type) :
|
|
354
|
+
!IsReadonly && IsOptional ? Types.Optional(Type) :
|
|
234
355
|
Type)
|
|
235
356
|
});
|
|
236
357
|
// prettier-ignore
|
|
237
358
|
const Property = Runtime.Tuple([
|
|
238
|
-
Runtime.Ref('
|
|
359
|
+
Runtime.Ref('Readonly'),
|
|
239
360
|
Runtime.Ref('PropertyKey'),
|
|
240
|
-
Runtime.Ref('
|
|
361
|
+
Runtime.Ref('Optional'),
|
|
241
362
|
Runtime.Const(Colon),
|
|
242
363
|
Runtime.Ref('Type'),
|
|
243
364
|
], value => PropertyMapping(...value));
|
|
@@ -255,23 +376,21 @@ const Properties = Runtime.Union([
|
|
|
255
376
|
Runtime.Tuple([Runtime.Ref('Property'), Runtime.Ref('PropertyDelimiter')]),
|
|
256
377
|
Runtime.Tuple([Runtime.Ref('Property')]),
|
|
257
378
|
Runtime.Tuple([])
|
|
258
|
-
], values => (values.length === 3 ?
|
|
259
|
-
values.length === 2 ?
|
|
260
|
-
values.length === 1 ?
|
|
261
|
-
|
|
379
|
+
], values => (values.length === 3 ? { ...values[0], ...values[2] } :
|
|
380
|
+
values.length === 2 ? values[0] :
|
|
381
|
+
values.length === 1 ? values[0] :
|
|
382
|
+
{}));
|
|
262
383
|
// ------------------------------------------------------------------
|
|
263
384
|
// Object
|
|
264
385
|
// ------------------------------------------------------------------
|
|
265
386
|
// prettier-ignore
|
|
266
|
-
const ObjectMapping = (
|
|
267
|
-
return { ...properties, ...record };
|
|
268
|
-
}, {}));
|
|
387
|
+
const ObjectMapping = (_0, Properties, _2) => Types.Object(Properties);
|
|
269
388
|
// prettier-ignore
|
|
270
389
|
const _Object = Runtime.Tuple([
|
|
271
390
|
Runtime.Const(LBrace),
|
|
272
391
|
Runtime.Ref('Properties'),
|
|
273
392
|
Runtime.Const(RBrace)
|
|
274
|
-
], values => ObjectMapping(values
|
|
393
|
+
], values => ObjectMapping(...values));
|
|
275
394
|
// ------------------------------------------------------------------
|
|
276
395
|
// Tuple
|
|
277
396
|
// ------------------------------------------------------------------
|
|
@@ -340,7 +459,15 @@ const MappedMapping = (values) => {
|
|
|
340
459
|
};
|
|
341
460
|
// prettier-ignore
|
|
342
461
|
const Mapped = Runtime.Tuple([
|
|
343
|
-
Runtime.Const(LBrace),
|
|
462
|
+
Runtime.Const(LBrace),
|
|
463
|
+
Runtime.Const(LBracket),
|
|
464
|
+
Runtime.Ident(),
|
|
465
|
+
Runtime.Const('in'),
|
|
466
|
+
Runtime.Ref('Type'),
|
|
467
|
+
Runtime.Const(RBracket),
|
|
468
|
+
Runtime.Const(Colon),
|
|
469
|
+
Runtime.Ref('Type'),
|
|
470
|
+
Runtime.Const(RBrace)
|
|
344
471
|
], MappedMapping);
|
|
345
472
|
// ------------------------------------------------------------------
|
|
346
473
|
// AsyncIterator
|
|
@@ -561,10 +688,34 @@ const Date = Runtime.Const('Date', Runtime.As(Types.Date()));
|
|
|
561
688
|
// ------------------------------------------------------------------
|
|
562
689
|
const Uint8Array = Runtime.Const('Uint8Array', Runtime.As(Types.Uint8Array()));
|
|
563
690
|
// ------------------------------------------------------------------
|
|
691
|
+
// Main
|
|
692
|
+
// ------------------------------------------------------------------
|
|
693
|
+
// prettier-ignore
|
|
694
|
+
const Main = Runtime.Union([
|
|
695
|
+
ModuleDeclaration,
|
|
696
|
+
TypeAliasDeclaration,
|
|
697
|
+
InterfaceDeclaration,
|
|
698
|
+
Type
|
|
699
|
+
]);
|
|
700
|
+
// ------------------------------------------------------------------
|
|
564
701
|
// Module
|
|
565
702
|
// ------------------------------------------------------------------
|
|
566
703
|
// prettier-ignore
|
|
567
704
|
export const Module = new Runtime.Module({
|
|
705
|
+
// ----------------------------------------------------------------
|
|
706
|
+
// Modules, Interfaces and Type Aliases
|
|
707
|
+
// ----------------------------------------------------------------
|
|
708
|
+
ExportModifier,
|
|
709
|
+
HeritageList,
|
|
710
|
+
Heritage,
|
|
711
|
+
InterfaceDeclaration,
|
|
712
|
+
TypeAliasDeclaration,
|
|
713
|
+
ModuleType,
|
|
714
|
+
ModuleProperties,
|
|
715
|
+
ModuleDeclaration,
|
|
716
|
+
// ----------------------------------------------------------------
|
|
717
|
+
// Type Expressions
|
|
718
|
+
// ----------------------------------------------------------------
|
|
568
719
|
Literal,
|
|
569
720
|
Keyword,
|
|
570
721
|
KeyOf,
|
|
@@ -576,10 +727,10 @@ export const Module = new Runtime.Module({
|
|
|
576
727
|
ExprTerm,
|
|
577
728
|
ExprTail,
|
|
578
729
|
Expr,
|
|
579
|
-
Type,
|
|
730
|
+
Type, // Alias for Expr
|
|
580
731
|
PropertyKey,
|
|
581
|
-
|
|
582
|
-
|
|
732
|
+
Readonly,
|
|
733
|
+
Optional,
|
|
583
734
|
Property,
|
|
584
735
|
PropertyDelimiter,
|
|
585
736
|
Properties,
|
|
@@ -613,5 +764,9 @@ export const Module = new Runtime.Module({
|
|
|
613
764
|
Uncapitalize,
|
|
614
765
|
Date,
|
|
615
766
|
Uint8Array,
|
|
616
|
-
Reference
|
|
767
|
+
Reference,
|
|
768
|
+
// ----------------------------------------------------------------
|
|
769
|
+
// Main
|
|
770
|
+
// ----------------------------------------------------------------
|
|
771
|
+
Main
|
|
617
772
|
});
|