@sinclair/typebox 0.34.16 → 0.34.18
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.js +5 -0
- package/build/cjs/errors/errors.js +3 -0
- package/build/cjs/index.d.ts +3 -0
- package/build/cjs/index.js +3 -0
- package/build/cjs/syntax/runtime.d.ts +3 -1
- package/build/cjs/syntax/runtime.js +33 -3
- package/build/cjs/syntax/static.d.ts +22 -2
- package/build/cjs/type/argument/argument.d.ts +9 -0
- package/build/cjs/type/argument/argument.js +10 -0
- package/build/cjs/type/argument/index.d.ts +1 -0
- package/build/cjs/type/argument/index.js +18 -0
- package/build/cjs/type/guard/kind.d.ts +9 -6
- package/build/cjs/type/guard/kind.js +6 -0
- package/build/cjs/type/guard/type.d.ts +9 -6
- package/build/cjs/type/guard/type.js +9 -0
- package/build/cjs/type/index.d.ts +2 -0
- package/build/cjs/type/index.js +2 -0
- package/build/cjs/type/instantiate/index.d.ts +1 -0
- package/build/cjs/type/instantiate/index.js +18 -0
- package/build/cjs/type/instantiate/instantiate.d.ts +25 -0
- package/build/cjs/type/instantiate/instantiate.js +32 -0
- package/build/cjs/type/record/record.d.ts +16 -1
- package/build/cjs/type/record/record.js +53 -23
- package/build/cjs/type/remap/index.d.ts +1 -0
- package/build/cjs/type/remap/index.js +18 -0
- package/build/cjs/type/remap/remap.d.ts +30 -0
- package/build/cjs/type/remap/remap.js +47 -0
- package/build/cjs/type/type/javascript.d.ts +6 -0
- package/build/cjs/type/type/javascript.js +44 -34
- package/build/cjs/type/type/type.d.ts +3 -0
- package/build/cjs/type/type/type.js +123 -117
- package/build/cjs/value/check/check.js +5 -0
- package/build/cjs/value/create/create.js +5 -0
- package/build/esm/compiler/compiler.mjs +5 -0
- package/build/esm/errors/errors.mjs +3 -0
- package/build/esm/index.d.mts +3 -0
- package/build/esm/index.mjs +3 -0
- package/build/esm/syntax/runtime.d.mts +3 -1
- package/build/esm/syntax/runtime.mjs +33 -3
- package/build/esm/syntax/static.d.mts +22 -2
- package/build/esm/type/argument/argument.d.mts +9 -0
- package/build/esm/type/argument/argument.mjs +6 -0
- package/build/esm/type/argument/index.d.mts +1 -0
- package/build/esm/type/argument/index.mjs +1 -0
- package/build/esm/type/guard/kind.d.mts +9 -6
- package/build/esm/type/guard/kind.mjs +5 -0
- package/build/esm/type/guard/type.d.mts +9 -6
- package/build/esm/type/guard/type.mjs +8 -0
- package/build/esm/type/index.d.mts +2 -0
- package/build/esm/type/index.mjs +2 -0
- package/build/esm/type/instantiate/index.d.mts +1 -0
- package/build/esm/type/instantiate/index.mjs +1 -0
- package/build/esm/type/instantiate/instantiate.d.mts +25 -0
- package/build/esm/type/instantiate/instantiate.mjs +28 -0
- package/build/esm/type/record/record.d.mts +16 -1
- package/build/esm/type/record/record.mjs +35 -8
- package/build/esm/type/remap/index.d.mts +1 -0
- package/build/esm/type/remap/index.mjs +1 -0
- package/build/esm/type/remap/remap.d.mts +30 -0
- package/build/esm/type/remap/remap.mjs +43 -0
- package/build/esm/type/type/javascript.d.mts +6 -0
- package/build/esm/type/type/javascript.mjs +10 -0
- package/build/esm/type/type/type.d.mts +3 -0
- package/build/esm/type/type/type.mjs +3 -0
- package/build/esm/value/check/check.mjs +5 -0
- package/build/esm/value/create/create.mjs +5 -0
- package/package.json +1 -1
- package/readme.md +36 -39
|
@@ -1,125 +1,131 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
exports.Void = exports.Unsafe = exports.Unknown = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.Transform = exports.TemplateLiteral = exports.Symbol = void 0;
|
|
4
|
+
exports.Required = exports.Remap = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.Readonly = exports.Promise = exports.Pick = exports.Partial = exports.Parameters = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.Module = exports.Mapped = exports.Literal = exports.KeyOf = exports.Iterator = exports.Uppercase = exports.Lowercase = exports.Uncapitalize = exports.Capitalize = exports.Intersect = exports.Integer = exports.Instantiate = exports.InstanceType = exports.Index = exports.Function = exports.Extract = exports.Extends = exports.Exclude = exports.Enum = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Argument = exports.Any = void 0;
|
|
5
|
+
exports.Void = exports.Unsafe = exports.Unknown = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.Transform = exports.TemplateLiteral = exports.Symbol = exports.String = exports.ReturnType = exports.Rest = void 0;
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
// Type: Module
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
9
|
var index_1 = require("../any/index");
|
|
10
10
|
Object.defineProperty(exports, "Any", { enumerable: true, get: function () { return index_1.Any; } });
|
|
11
|
-
var index_2 = require("../
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
var index_3 = require("../
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
var index_4 = require("../
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
var index_5 = require("../
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
var index_6 = require("../
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
var index_7 = require("../
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
-
var index_8 = require("../
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
var index_9 = require("../
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
-
var index_10 = require("../constructor
|
|
28
|
-
Object.defineProperty(exports, "
|
|
29
|
-
var index_11 = require("../
|
|
30
|
-
Object.defineProperty(exports, "
|
|
31
|
-
var index_12 = require("../
|
|
32
|
-
Object.defineProperty(exports, "
|
|
33
|
-
var index_13 = require("../
|
|
34
|
-
Object.defineProperty(exports, "
|
|
35
|
-
var index_14 = require("../
|
|
36
|
-
Object.defineProperty(exports, "
|
|
37
|
-
var index_15 = require("../
|
|
38
|
-
Object.defineProperty(exports, "
|
|
39
|
-
var index_16 = require("../
|
|
40
|
-
Object.defineProperty(exports, "
|
|
41
|
-
var index_17 = require("../
|
|
42
|
-
Object.defineProperty(exports, "
|
|
43
|
-
var index_18 = require("../
|
|
44
|
-
Object.defineProperty(exports, "
|
|
45
|
-
var index_19 = require("../
|
|
46
|
-
Object.defineProperty(exports, "
|
|
47
|
-
var index_20 = require("../
|
|
48
|
-
Object.defineProperty(exports, "
|
|
49
|
-
var index_21 = require("../
|
|
50
|
-
Object.defineProperty(exports, "
|
|
51
|
-
|
|
52
|
-
Object.defineProperty(exports, "
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Object.defineProperty(exports, "
|
|
56
|
-
|
|
57
|
-
Object.defineProperty(exports, "
|
|
58
|
-
var index_24 = require("../
|
|
59
|
-
Object.defineProperty(exports, "
|
|
60
|
-
var index_25 = require("../
|
|
61
|
-
Object.defineProperty(exports, "
|
|
62
|
-
var index_26 = require("../
|
|
63
|
-
Object.defineProperty(exports, "
|
|
64
|
-
var index_27 = require("../
|
|
65
|
-
Object.defineProperty(exports, "
|
|
66
|
-
var index_28 = require("../
|
|
67
|
-
Object.defineProperty(exports, "
|
|
68
|
-
var index_29 = require("../
|
|
69
|
-
Object.defineProperty(exports, "
|
|
70
|
-
var index_30 = require("../
|
|
71
|
-
Object.defineProperty(exports, "
|
|
72
|
-
var index_31 = require("../
|
|
73
|
-
Object.defineProperty(exports, "
|
|
74
|
-
var index_32 = require("../
|
|
75
|
-
Object.defineProperty(exports, "
|
|
76
|
-
var index_33 = require("../
|
|
77
|
-
Object.defineProperty(exports, "
|
|
78
|
-
var index_34 = require("../
|
|
79
|
-
Object.defineProperty(exports, "
|
|
80
|
-
var index_35 = require("../
|
|
81
|
-
Object.defineProperty(exports, "
|
|
82
|
-
var index_36 = require("../
|
|
83
|
-
Object.defineProperty(exports, "
|
|
84
|
-
var index_37 = require("../
|
|
85
|
-
Object.defineProperty(exports, "
|
|
86
|
-
var index_38 = require("../
|
|
87
|
-
Object.defineProperty(exports, "
|
|
88
|
-
var index_39 = require("../
|
|
89
|
-
Object.defineProperty(exports, "
|
|
90
|
-
var index_40 = require("../
|
|
91
|
-
Object.defineProperty(exports, "
|
|
92
|
-
var index_41 = require("../
|
|
93
|
-
Object.defineProperty(exports, "
|
|
94
|
-
var index_42 = require("../
|
|
95
|
-
Object.defineProperty(exports, "
|
|
96
|
-
var index_43 = require("../
|
|
97
|
-
Object.defineProperty(exports, "
|
|
98
|
-
var index_44 = require("../
|
|
99
|
-
Object.defineProperty(exports, "
|
|
100
|
-
var index_45 = require("../
|
|
101
|
-
Object.defineProperty(exports, "
|
|
102
|
-
var index_46 = require("../
|
|
103
|
-
Object.defineProperty(exports, "
|
|
104
|
-
var index_47 = require("../
|
|
105
|
-
Object.defineProperty(exports, "
|
|
106
|
-
var index_48 = require("../
|
|
107
|
-
Object.defineProperty(exports, "
|
|
108
|
-
var index_49 = require("../
|
|
109
|
-
Object.defineProperty(exports, "
|
|
110
|
-
var index_50 = require("../
|
|
111
|
-
Object.defineProperty(exports, "
|
|
112
|
-
var index_51 = require("../
|
|
113
|
-
Object.defineProperty(exports, "
|
|
114
|
-
var index_52 = require("../
|
|
115
|
-
Object.defineProperty(exports, "
|
|
116
|
-
var index_53 = require("../
|
|
117
|
-
Object.defineProperty(exports, "
|
|
118
|
-
var index_54 = require("../
|
|
119
|
-
Object.defineProperty(exports, "
|
|
120
|
-
var index_55 = require("../
|
|
121
|
-
Object.defineProperty(exports, "
|
|
122
|
-
var index_56 = require("../
|
|
123
|
-
Object.defineProperty(exports, "
|
|
124
|
-
var index_57 = require("../
|
|
125
|
-
Object.defineProperty(exports, "
|
|
11
|
+
var index_2 = require("../argument/index");
|
|
12
|
+
Object.defineProperty(exports, "Argument", { enumerable: true, get: function () { return index_2.Argument; } });
|
|
13
|
+
var index_3 = require("../array/index");
|
|
14
|
+
Object.defineProperty(exports, "Array", { enumerable: true, get: function () { return index_3.Array; } });
|
|
15
|
+
var index_4 = require("../async-iterator/index");
|
|
16
|
+
Object.defineProperty(exports, "AsyncIterator", { enumerable: true, get: function () { return index_4.AsyncIterator; } });
|
|
17
|
+
var index_5 = require("../awaited/index");
|
|
18
|
+
Object.defineProperty(exports, "Awaited", { enumerable: true, get: function () { return index_5.Awaited; } });
|
|
19
|
+
var index_6 = require("../bigint/index");
|
|
20
|
+
Object.defineProperty(exports, "BigInt", { enumerable: true, get: function () { return index_6.BigInt; } });
|
|
21
|
+
var index_7 = require("../boolean/index");
|
|
22
|
+
Object.defineProperty(exports, "Boolean", { enumerable: true, get: function () { return index_7.Boolean; } });
|
|
23
|
+
var index_8 = require("../composite/index");
|
|
24
|
+
Object.defineProperty(exports, "Composite", { enumerable: true, get: function () { return index_8.Composite; } });
|
|
25
|
+
var index_9 = require("../const/index");
|
|
26
|
+
Object.defineProperty(exports, "Const", { enumerable: true, get: function () { return index_9.Const; } });
|
|
27
|
+
var index_10 = require("../constructor/index");
|
|
28
|
+
Object.defineProperty(exports, "Constructor", { enumerable: true, get: function () { return index_10.Constructor; } });
|
|
29
|
+
var index_11 = require("../constructor-parameters/index");
|
|
30
|
+
Object.defineProperty(exports, "ConstructorParameters", { enumerable: true, get: function () { return index_11.ConstructorParameters; } });
|
|
31
|
+
var index_12 = require("../date/index");
|
|
32
|
+
Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return index_12.Date; } });
|
|
33
|
+
var index_13 = require("../enum/index");
|
|
34
|
+
Object.defineProperty(exports, "Enum", { enumerable: true, get: function () { return index_13.Enum; } });
|
|
35
|
+
var index_14 = require("../exclude/index");
|
|
36
|
+
Object.defineProperty(exports, "Exclude", { enumerable: true, get: function () { return index_14.Exclude; } });
|
|
37
|
+
var index_15 = require("../extends/index");
|
|
38
|
+
Object.defineProperty(exports, "Extends", { enumerable: true, get: function () { return index_15.Extends; } });
|
|
39
|
+
var index_16 = require("../extract/index");
|
|
40
|
+
Object.defineProperty(exports, "Extract", { enumerable: true, get: function () { return index_16.Extract; } });
|
|
41
|
+
var index_17 = require("../function/index");
|
|
42
|
+
Object.defineProperty(exports, "Function", { enumerable: true, get: function () { return index_17.Function; } });
|
|
43
|
+
var index_18 = require("../indexed/index");
|
|
44
|
+
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return index_18.Index; } });
|
|
45
|
+
var index_19 = require("../instance-type/index");
|
|
46
|
+
Object.defineProperty(exports, "InstanceType", { enumerable: true, get: function () { return index_19.InstanceType; } });
|
|
47
|
+
var index_20 = require("../instantiate/index");
|
|
48
|
+
Object.defineProperty(exports, "Instantiate", { enumerable: true, get: function () { return index_20.Instantiate; } });
|
|
49
|
+
var index_21 = require("../integer/index");
|
|
50
|
+
Object.defineProperty(exports, "Integer", { enumerable: true, get: function () { return index_21.Integer; } });
|
|
51
|
+
var index_22 = require("../intersect/index");
|
|
52
|
+
Object.defineProperty(exports, "Intersect", { enumerable: true, get: function () { return index_22.Intersect; } });
|
|
53
|
+
var index_23 = require("../intrinsic/index");
|
|
54
|
+
Object.defineProperty(exports, "Capitalize", { enumerable: true, get: function () { return index_23.Capitalize; } });
|
|
55
|
+
Object.defineProperty(exports, "Uncapitalize", { enumerable: true, get: function () { return index_23.Uncapitalize; } });
|
|
56
|
+
Object.defineProperty(exports, "Lowercase", { enumerable: true, get: function () { return index_23.Lowercase; } });
|
|
57
|
+
Object.defineProperty(exports, "Uppercase", { enumerable: true, get: function () { return index_23.Uppercase; } });
|
|
58
|
+
var index_24 = require("../iterator/index");
|
|
59
|
+
Object.defineProperty(exports, "Iterator", { enumerable: true, get: function () { return index_24.Iterator; } });
|
|
60
|
+
var index_25 = require("../keyof/index");
|
|
61
|
+
Object.defineProperty(exports, "KeyOf", { enumerable: true, get: function () { return index_25.KeyOf; } });
|
|
62
|
+
var index_26 = require("../literal/index");
|
|
63
|
+
Object.defineProperty(exports, "Literal", { enumerable: true, get: function () { return index_26.Literal; } });
|
|
64
|
+
var index_27 = require("../mapped/index");
|
|
65
|
+
Object.defineProperty(exports, "Mapped", { enumerable: true, get: function () { return index_27.Mapped; } });
|
|
66
|
+
var index_28 = require("../module/index");
|
|
67
|
+
Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return index_28.Module; } });
|
|
68
|
+
var index_29 = require("../never/index");
|
|
69
|
+
Object.defineProperty(exports, "Never", { enumerable: true, get: function () { return index_29.Never; } });
|
|
70
|
+
var index_30 = require("../not/index");
|
|
71
|
+
Object.defineProperty(exports, "Not", { enumerable: true, get: function () { return index_30.Not; } });
|
|
72
|
+
var index_31 = require("../null/index");
|
|
73
|
+
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return index_31.Null; } });
|
|
74
|
+
var index_32 = require("../number/index");
|
|
75
|
+
Object.defineProperty(exports, "Number", { enumerable: true, get: function () { return index_32.Number; } });
|
|
76
|
+
var index_33 = require("../object/index");
|
|
77
|
+
Object.defineProperty(exports, "Object", { enumerable: true, get: function () { return index_33.Object; } });
|
|
78
|
+
var index_34 = require("../omit/index");
|
|
79
|
+
Object.defineProperty(exports, "Omit", { enumerable: true, get: function () { return index_34.Omit; } });
|
|
80
|
+
var index_35 = require("../optional/index");
|
|
81
|
+
Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return index_35.Optional; } });
|
|
82
|
+
var index_36 = require("../parameters/index");
|
|
83
|
+
Object.defineProperty(exports, "Parameters", { enumerable: true, get: function () { return index_36.Parameters; } });
|
|
84
|
+
var index_37 = require("../partial/index");
|
|
85
|
+
Object.defineProperty(exports, "Partial", { enumerable: true, get: function () { return index_37.Partial; } });
|
|
86
|
+
var index_38 = require("../pick/index");
|
|
87
|
+
Object.defineProperty(exports, "Pick", { enumerable: true, get: function () { return index_38.Pick; } });
|
|
88
|
+
var index_39 = require("../promise/index");
|
|
89
|
+
Object.defineProperty(exports, "Promise", { enumerable: true, get: function () { return index_39.Promise; } });
|
|
90
|
+
var index_40 = require("../readonly/index");
|
|
91
|
+
Object.defineProperty(exports, "Readonly", { enumerable: true, get: function () { return index_40.Readonly; } });
|
|
92
|
+
var index_41 = require("../readonly-optional/index");
|
|
93
|
+
Object.defineProperty(exports, "ReadonlyOptional", { enumerable: true, get: function () { return index_41.ReadonlyOptional; } });
|
|
94
|
+
var index_42 = require("../record/index");
|
|
95
|
+
Object.defineProperty(exports, "Record", { enumerable: true, get: function () { return index_42.Record; } });
|
|
96
|
+
var index_43 = require("../recursive/index");
|
|
97
|
+
Object.defineProperty(exports, "Recursive", { enumerable: true, get: function () { return index_43.Recursive; } });
|
|
98
|
+
var index_44 = require("../ref/index");
|
|
99
|
+
Object.defineProperty(exports, "Ref", { enumerable: true, get: function () { return index_44.Ref; } });
|
|
100
|
+
var index_45 = require("../regexp/index");
|
|
101
|
+
Object.defineProperty(exports, "RegExp", { enumerable: true, get: function () { return index_45.RegExp; } });
|
|
102
|
+
var index_46 = require("../remap/index");
|
|
103
|
+
Object.defineProperty(exports, "Remap", { enumerable: true, get: function () { return index_46.Remap; } });
|
|
104
|
+
var index_47 = require("../required/index");
|
|
105
|
+
Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return index_47.Required; } });
|
|
106
|
+
var index_48 = require("../rest/index");
|
|
107
|
+
Object.defineProperty(exports, "Rest", { enumerable: true, get: function () { return index_48.Rest; } });
|
|
108
|
+
var index_49 = require("../return-type/index");
|
|
109
|
+
Object.defineProperty(exports, "ReturnType", { enumerable: true, get: function () { return index_49.ReturnType; } });
|
|
110
|
+
var index_50 = require("../string/index");
|
|
111
|
+
Object.defineProperty(exports, "String", { enumerable: true, get: function () { return index_50.String; } });
|
|
112
|
+
var index_51 = require("../symbol/index");
|
|
113
|
+
Object.defineProperty(exports, "Symbol", { enumerable: true, get: function () { return index_51.Symbol; } });
|
|
114
|
+
var index_52 = require("../template-literal/index");
|
|
115
|
+
Object.defineProperty(exports, "TemplateLiteral", { enumerable: true, get: function () { return index_52.TemplateLiteral; } });
|
|
116
|
+
var index_53 = require("../transform/index");
|
|
117
|
+
Object.defineProperty(exports, "Transform", { enumerable: true, get: function () { return index_53.Transform; } });
|
|
118
|
+
var index_54 = require("../tuple/index");
|
|
119
|
+
Object.defineProperty(exports, "Tuple", { enumerable: true, get: function () { return index_54.Tuple; } });
|
|
120
|
+
var index_55 = require("../uint8array/index");
|
|
121
|
+
Object.defineProperty(exports, "Uint8Array", { enumerable: true, get: function () { return index_55.Uint8Array; } });
|
|
122
|
+
var index_56 = require("../undefined/index");
|
|
123
|
+
Object.defineProperty(exports, "Undefined", { enumerable: true, get: function () { return index_56.Undefined; } });
|
|
124
|
+
var index_57 = require("../union/index");
|
|
125
|
+
Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return index_57.Union; } });
|
|
126
|
+
var index_58 = require("../unknown/index");
|
|
127
|
+
Object.defineProperty(exports, "Unknown", { enumerable: true, get: function () { return index_58.Unknown; } });
|
|
128
|
+
var index_59 = require("../unsafe/index");
|
|
129
|
+
Object.defineProperty(exports, "Unsafe", { enumerable: true, get: function () { return index_59.Unsafe; } });
|
|
130
|
+
var index_60 = require("../void/index");
|
|
131
|
+
Object.defineProperty(exports, "Void", { enumerable: true, get: function () { return index_60.Void; } });
|
|
@@ -48,6 +48,9 @@ function IsDefined(value) {
|
|
|
48
48
|
function FromAny(schema, references, value) {
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
+
function FromArgument(schema, references, value) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
51
54
|
function FromArray(schema, references, value) {
|
|
52
55
|
if (!(0, index_10.IsArray)(value))
|
|
53
56
|
return false;
|
|
@@ -396,6 +399,8 @@ function Visit(schema, references, value) {
|
|
|
396
399
|
switch (schema_[index_4.Kind]) {
|
|
397
400
|
case 'Any':
|
|
398
401
|
return FromAny(schema_, references_, value);
|
|
402
|
+
case 'Argument':
|
|
403
|
+
return FromArgument(schema_, references_, value);
|
|
399
404
|
case 'Array':
|
|
400
405
|
return FromArray(schema_, references_, value);
|
|
401
406
|
case 'AsyncIterator':
|
|
@@ -40,6 +40,9 @@ function FromAny(schema, references) {
|
|
|
40
40
|
return {};
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
function FromArgument(schema, references) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
43
46
|
function FromArray(schema, references) {
|
|
44
47
|
if (schema.uniqueItems === true && !(0, index_1.HasPropertyKey)(schema, 'default')) {
|
|
45
48
|
throw new ValueCreateError(schema, 'Array with the uniqueItems constraint requires a default value');
|
|
@@ -398,6 +401,8 @@ function Visit(schema, references) {
|
|
|
398
401
|
switch (schema_[index_8.Kind]) {
|
|
399
402
|
case 'Any':
|
|
400
403
|
return FromAny(schema_, references_);
|
|
404
|
+
case 'Argument':
|
|
405
|
+
return FromArgument(schema_, references_);
|
|
401
406
|
case 'Array':
|
|
402
407
|
return FromArray(schema_, references_);
|
|
403
408
|
case 'AsyncIterator':
|
|
@@ -202,6 +202,9 @@ export var TypeCompiler;
|
|
|
202
202
|
function* FromAny(schema, references, value) {
|
|
203
203
|
yield 'true';
|
|
204
204
|
}
|
|
205
|
+
function* FromArgument(schema, references, value) {
|
|
206
|
+
yield 'true';
|
|
207
|
+
}
|
|
205
208
|
function* FromArray(schema, references, value) {
|
|
206
209
|
yield `Array.isArray(${value})`;
|
|
207
210
|
const [parameter, accumulator] = [CreateParameter('value', 'any'), CreateParameter('acc', 'number')];
|
|
@@ -486,6 +489,8 @@ export var TypeCompiler;
|
|
|
486
489
|
switch (schema_[Kind]) {
|
|
487
490
|
case 'Any':
|
|
488
491
|
return yield* FromAny(schema_, references_, value);
|
|
492
|
+
case 'Argument':
|
|
493
|
+
return yield* FromArgument(schema_, references_, value);
|
|
489
494
|
case 'Array':
|
|
490
495
|
return yield* FromArray(schema_, references_, value);
|
|
491
496
|
case 'AsyncIterator':
|
|
@@ -138,6 +138,7 @@ function Create(errorType, schema, path, value, errors = []) {
|
|
|
138
138
|
// Types
|
|
139
139
|
// --------------------------------------------------------------------------
|
|
140
140
|
function* FromAny(schema, references, path, value) { }
|
|
141
|
+
function* FromArgument(schema, references, path, value) { }
|
|
141
142
|
function* FromArray(schema, references, path, value) {
|
|
142
143
|
if (!IsArray(value)) {
|
|
143
144
|
return yield Create(ValueErrorType.Array, schema, path, value);
|
|
@@ -514,6 +515,8 @@ function* Visit(schema, references, path, value) {
|
|
|
514
515
|
switch (schema_[Kind]) {
|
|
515
516
|
case 'Any':
|
|
516
517
|
return yield* FromAny(schema_, references_, path, value);
|
|
518
|
+
case 'Argument':
|
|
519
|
+
return yield* FromArgument(schema_, references_, path, value);
|
|
517
520
|
case 'Array':
|
|
518
521
|
return yield* FromArray(schema_, references_, path, value);
|
|
519
522
|
case 'AsyncIterator':
|
package/build/esm/index.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './type/sets/index.mjs';
|
|
|
9
9
|
export * from './type/symbols/index.mjs';
|
|
10
10
|
export * from './type/any/index.mjs';
|
|
11
11
|
export * from './type/array/index.mjs';
|
|
12
|
+
export * from './type/argument/index.mjs';
|
|
12
13
|
export * from './type/async-iterator/index.mjs';
|
|
13
14
|
export * from './type/awaited/index.mjs';
|
|
14
15
|
export * from './type/bigint/index.mjs';
|
|
@@ -25,6 +26,7 @@ export * from './type/extract/index.mjs';
|
|
|
25
26
|
export * from './type/function/index.mjs';
|
|
26
27
|
export * from './type/indexed/index.mjs';
|
|
27
28
|
export * from './type/instance-type/index.mjs';
|
|
29
|
+
export * from './type/instantiate/index.mjs';
|
|
28
30
|
export * from './type/integer/index.mjs';
|
|
29
31
|
export * from './type/intersect/index.mjs';
|
|
30
32
|
export * from './type/iterator/index.mjs';
|
|
@@ -50,6 +52,7 @@ export * from './type/record/index.mjs';
|
|
|
50
52
|
export * from './type/recursive/index.mjs';
|
|
51
53
|
export * from './type/ref/index.mjs';
|
|
52
54
|
export * from './type/regexp/index.mjs';
|
|
55
|
+
export * from './type/remap/index.mjs';
|
|
53
56
|
export * from './type/required/index.mjs';
|
|
54
57
|
export * from './type/rest/index.mjs';
|
|
55
58
|
export * from './type/return-type/index.mjs';
|
package/build/esm/index.mjs
CHANGED
|
@@ -15,6 +15,7 @@ export * from './type/symbols/index.mjs';
|
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
export * from './type/any/index.mjs';
|
|
17
17
|
export * from './type/array/index.mjs';
|
|
18
|
+
export * from './type/argument/index.mjs';
|
|
18
19
|
export * from './type/async-iterator/index.mjs';
|
|
19
20
|
export * from './type/awaited/index.mjs';
|
|
20
21
|
export * from './type/bigint/index.mjs';
|
|
@@ -31,6 +32,7 @@ export * from './type/extract/index.mjs';
|
|
|
31
32
|
export * from './type/function/index.mjs';
|
|
32
33
|
export * from './type/indexed/index.mjs';
|
|
33
34
|
export * from './type/instance-type/index.mjs';
|
|
35
|
+
export * from './type/instantiate/index.mjs';
|
|
34
36
|
export * from './type/integer/index.mjs';
|
|
35
37
|
export * from './type/intersect/index.mjs';
|
|
36
38
|
export * from './type/iterator/index.mjs';
|
|
@@ -56,6 +58,7 @@ export * from './type/record/index.mjs';
|
|
|
56
58
|
export * from './type/recursive/index.mjs';
|
|
57
59
|
export * from './type/ref/index.mjs';
|
|
58
60
|
export * from './type/regexp/index.mjs';
|
|
61
|
+
export * from './type/remap/index.mjs';
|
|
59
62
|
export * from './type/required/index.mjs';
|
|
60
63
|
export * from './type/rest/index.mjs';
|
|
61
64
|
export * from './type/return-type/index.mjs';
|
|
@@ -2,7 +2,7 @@ import { Runtime } from '../parser/index.mjs';
|
|
|
2
2
|
import * as t from '../type/index.mjs';
|
|
3
3
|
export declare const Module: Runtime.Module<{
|
|
4
4
|
Literal: Runtime.IUnion<t.TLiteral<string> | t.TLiteral<number> | t.TLiteral<boolean>>;
|
|
5
|
-
Keyword: Runtime.IUnion<t.TAny | t.
|
|
5
|
+
Keyword: Runtime.IUnion<t.TAny | t.TBoolean | t.TBigInt | t.TNever | t.TString | t.TNumber | t.TInteger | t.TNull | t.TSymbol | t.TUndefined | t.TUnknown | t.TVoid>;
|
|
6
6
|
KeyOf: Runtime.IUnion<boolean>;
|
|
7
7
|
IndexArray: Runtime.IUnion<unknown[]>;
|
|
8
8
|
Extends: Runtime.IUnion<unknown[]>;
|
|
@@ -31,6 +31,7 @@ export declare const Module: Runtime.Module<{
|
|
|
31
31
|
Mapped: Runtime.ITuple<t.TLiteral<"Mapped types not supported">>;
|
|
32
32
|
AsyncIterator: Runtime.ITuple<t.TAsyncIterator<t.TSchema>>;
|
|
33
33
|
Iterator: Runtime.ITuple<t.TIterator<t.TSchema>>;
|
|
34
|
+
Argument: Runtime.ITuple<t.TNever | t.TArgument<number>>;
|
|
34
35
|
Awaited: Runtime.ITuple<t.TSchema>;
|
|
35
36
|
Array: Runtime.ITuple<t.TArray<t.TSchema>>;
|
|
36
37
|
Record: Runtime.ITuple<t.TNever>;
|
|
@@ -51,5 +52,6 @@ export declare const Module: Runtime.Module<{
|
|
|
51
52
|
Uncapitalize: Runtime.ITuple<t.TSchema>;
|
|
52
53
|
Date: Runtime.IConst<t.TDate>;
|
|
53
54
|
Uint8Array: Runtime.IConst<t.TUint8Array>;
|
|
55
|
+
GenericReference: Runtime.ITuple<t.TSchema>;
|
|
54
56
|
Reference: Runtime.IIdent<t.TSchema>;
|
|
55
57
|
}>;
|
|
@@ -30,16 +30,28 @@ function DestructureRight(values) {
|
|
|
30
30
|
: [values, undefined];
|
|
31
31
|
}
|
|
32
32
|
// ------------------------------------------------------------------
|
|
33
|
-
//
|
|
33
|
+
// Dereference
|
|
34
34
|
// ------------------------------------------------------------------
|
|
35
|
-
const
|
|
35
|
+
const Dereference = (context, key) => {
|
|
36
36
|
return key in context ? context[key] : t.Ref(key);
|
|
37
37
|
};
|
|
38
38
|
// ------------------------------------------------------------------
|
|
39
|
+
// GenericReference
|
|
40
|
+
// ------------------------------------------------------------------
|
|
41
|
+
function GenericReferenceMapping(results, context) {
|
|
42
|
+
const target = Dereference(context, results[0]);
|
|
43
|
+
return t.Instantiate(target, results[2]);
|
|
44
|
+
}
|
|
45
|
+
const GenericReference = Runtime.Tuple([Runtime.Ident(), Runtime.Const(LAngle), Runtime.Ref('Elements'), Runtime.Const(RAngle)], (results, context) => GenericReferenceMapping(results, context));
|
|
46
|
+
// ------------------------------------------------------------------
|
|
39
47
|
// Reference
|
|
40
48
|
// ------------------------------------------------------------------
|
|
49
|
+
function ReferenceMapping(result, context) {
|
|
50
|
+
const target = Dereference(context, result);
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
41
53
|
// prettier-ignore
|
|
42
|
-
const Reference = Runtime.Ident((
|
|
54
|
+
const Reference = Runtime.Ident((result, context) => ReferenceMapping(result, context));
|
|
43
55
|
// ------------------------------------------------------------------
|
|
44
56
|
// Literal
|
|
45
57
|
// ------------------------------------------------------------------
|
|
@@ -131,6 +143,7 @@ const Base = Runtime.Union([
|
|
|
131
143
|
Runtime.Ref('FunctionParameters'),
|
|
132
144
|
Runtime.Ref('InstanceType'),
|
|
133
145
|
Runtime.Ref('ReturnType'),
|
|
146
|
+
Runtime.Ref('Argument'),
|
|
134
147
|
Runtime.Ref('Awaited'),
|
|
135
148
|
Runtime.Ref('Array'),
|
|
136
149
|
Runtime.Ref('Record'),
|
|
@@ -147,6 +160,7 @@ const Base = Runtime.Union([
|
|
|
147
160
|
Runtime.Ref('Uncapitalize'),
|
|
148
161
|
Runtime.Ref('Date'),
|
|
149
162
|
Runtime.Ref('Uint8Array'),
|
|
163
|
+
Runtime.Ref('GenericReference'),
|
|
150
164
|
Runtime.Ref('Reference')
|
|
151
165
|
])])
|
|
152
166
|
], BaseMapping);
|
|
@@ -413,6 +427,20 @@ const ReturnType = Runtime.Tuple([
|
|
|
413
427
|
Runtime.Const(RAngle),
|
|
414
428
|
], value => t.ReturnType(value[2]));
|
|
415
429
|
// ------------------------------------------------------------------
|
|
430
|
+
// Argument
|
|
431
|
+
// ------------------------------------------------------------------
|
|
432
|
+
// prettier-ignore
|
|
433
|
+
const Argument = Runtime.Tuple([
|
|
434
|
+
Runtime.Const('Argument'),
|
|
435
|
+
Runtime.Const(LAngle),
|
|
436
|
+
Runtime.Ref('Type'),
|
|
437
|
+
Runtime.Const(RAngle),
|
|
438
|
+
], results => {
|
|
439
|
+
return t.KindGuard.IsLiteralNumber(results[2])
|
|
440
|
+
? t.Argument(Math.trunc(results[2].const))
|
|
441
|
+
: t.Never();
|
|
442
|
+
});
|
|
443
|
+
// ------------------------------------------------------------------
|
|
416
444
|
// Awaited
|
|
417
445
|
// ------------------------------------------------------------------
|
|
418
446
|
// prettier-ignore
|
|
@@ -606,6 +634,7 @@ export const Module = new Runtime.Module({
|
|
|
606
634
|
Mapped,
|
|
607
635
|
AsyncIterator,
|
|
608
636
|
Iterator,
|
|
637
|
+
Argument,
|
|
609
638
|
Awaited,
|
|
610
639
|
Array,
|
|
611
640
|
Record,
|
|
@@ -626,5 +655,6 @@ export const Module = new Runtime.Module({
|
|
|
626
655
|
Uncapitalize,
|
|
627
656
|
Date,
|
|
628
657
|
Uint8Array,
|
|
658
|
+
GenericReference,
|
|
629
659
|
Reference,
|
|
630
660
|
});
|
|
@@ -41,9 +41,18 @@ type Delimit<Parser extends Static.IParser, Delimiter extends Static.IParser> =
|
|
|
41
41
|
Static.Tuple<[Parser, DelimitTail<Parser, Delimiter>]>,
|
|
42
42
|
Static.Tuple<[]>
|
|
43
43
|
], DelimitMapping>);
|
|
44
|
-
type
|
|
44
|
+
type Dereference<Context extends t.TProperties, Ref extends string> = (Ref extends keyof Context ? Context[Ref] : t.TRef<Ref>);
|
|
45
|
+
interface GenericReferenceMapping extends Static.IMapping {
|
|
46
|
+
output: this['context'] extends t.TProperties ? this['input'] extends [infer Reference extends string, LAngle, infer Parameters extends t.TSchema[], RAngle] ? t.TInstantiate<Dereference<this['context'], Reference>, [...Parameters]> : never : never;
|
|
47
|
+
}
|
|
48
|
+
type GenericReference = Static.Tuple<[
|
|
49
|
+
Static.Ident,
|
|
50
|
+
Static.Const<LAngle>,
|
|
51
|
+
Elements,
|
|
52
|
+
Static.Const<RAngle>
|
|
53
|
+
], GenericReferenceMapping>;
|
|
45
54
|
interface ReferenceMapping extends Static.IMapping {
|
|
46
|
-
output: this['context'] extends t.TProperties ? this['input'] extends string ?
|
|
55
|
+
output: this['context'] extends t.TProperties ? this['input'] extends string ? Dereference<this['context'], this['input']> : never : never;
|
|
47
56
|
}
|
|
48
57
|
type Reference = Static.Ident<ReferenceMapping>;
|
|
49
58
|
interface LiteralBooleanMapping extends Static.IMapping {
|
|
@@ -119,6 +128,7 @@ type Base = Static.Union<[
|
|
|
119
128
|
Iterator,
|
|
120
129
|
ConstructorParameters,
|
|
121
130
|
FunctionParameters,
|
|
131
|
+
Argument,
|
|
122
132
|
InstanceType,
|
|
123
133
|
ReturnType,
|
|
124
134
|
Awaited,
|
|
@@ -137,6 +147,7 @@ type Base = Static.Union<[
|
|
|
137
147
|
Uncapitalize,
|
|
138
148
|
Date,
|
|
139
149
|
Uint8Array,
|
|
150
|
+
GenericReference,
|
|
140
151
|
Reference
|
|
141
152
|
]>
|
|
142
153
|
]>
|
|
@@ -337,6 +348,15 @@ type ReturnType = Static.Tuple<[
|
|
|
337
348
|
Type,
|
|
338
349
|
Static.Const<RAngle>
|
|
339
350
|
], ReturnTypeMapping>;
|
|
351
|
+
interface ArgumentMapping extends Static.IMapping {
|
|
352
|
+
output: this['input'] extends ['Argument', LAngle, infer Type extends t.TSchema, RAngle] ? Type extends t.TLiteral<infer Index extends number> ? t.TArgument<Index> : t.TNever : never;
|
|
353
|
+
}
|
|
354
|
+
type Argument = Static.Tuple<[
|
|
355
|
+
Static.Const<'Argument'>,
|
|
356
|
+
Static.Const<LAngle>,
|
|
357
|
+
Type,
|
|
358
|
+
Static.Const<RAngle>
|
|
359
|
+
], ArgumentMapping>;
|
|
340
360
|
interface AwaitedMapping extends Static.IMapping {
|
|
341
361
|
output: this['input'] extends ['Awaited', LAngle, infer Type extends t.TSchema, RAngle] ? t.TAwaited<Type> : never;
|
|
342
362
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
+
import { Kind } from '../symbols/index.mjs';
|
|
3
|
+
export interface TArgument<Index extends number = number> extends TSchema {
|
|
4
|
+
[Kind]: 'Argument';
|
|
5
|
+
static: unknown;
|
|
6
|
+
index: Index;
|
|
7
|
+
}
|
|
8
|
+
/** `[JavaScript]` Creates an Argument Type. */
|
|
9
|
+
export declare function Argument<Index extends number>(index: Index): TArgument<Index>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './argument.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './argument.mjs';
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Kind, Hint, TransformKind } from '../symbols/index.mjs';
|
|
2
2
|
import { TransformOptions } from '../transform/index.mjs';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TAny } from '../any/index.mjs';
|
|
4
|
+
import type { TArgument } from '../argument/index.mjs';
|
|
4
5
|
import type { TArray } from '../array/index.mjs';
|
|
6
|
+
import type { TAsyncIterator } from '../async-iterator/index.mjs';
|
|
5
7
|
import type { TBoolean } from '../boolean/index.mjs';
|
|
6
8
|
import type { TComputed } from '../computed/index.mjs';
|
|
7
|
-
import type { TRecord } from '../record/index.mjs';
|
|
8
|
-
import type { TString } from '../string/index.mjs';
|
|
9
|
-
import type { TUnion } from '../union/index.mjs';
|
|
10
|
-
import type { TAny } from '../any/index.mjs';
|
|
11
|
-
import type { TAsyncIterator } from '../async-iterator/index.mjs';
|
|
12
9
|
import type { TBigInt } from '../bigint/index.mjs';
|
|
13
10
|
import type { TConstructor } from '../constructor/index.mjs';
|
|
14
11
|
import type { TFunction } from '../function/index.mjs';
|
|
@@ -26,14 +23,18 @@ import type { TObject, TProperties } from '../object/index.mjs';
|
|
|
26
23
|
import type { TOptional } from '../optional/index.mjs';
|
|
27
24
|
import type { TPromise } from '../promise/index.mjs';
|
|
28
25
|
import type { TReadonly } from '../readonly/index.mjs';
|
|
26
|
+
import type { TRecord } from '../record/index.mjs';
|
|
29
27
|
import type { TRef } from '../ref/index.mjs';
|
|
30
28
|
import type { TRegExp } from '../regexp/index.mjs';
|
|
31
29
|
import type { TSchema } from '../schema/index.mjs';
|
|
30
|
+
import type { TString } from '../string/index.mjs';
|
|
32
31
|
import type { TSymbol } from '../symbol/index.mjs';
|
|
32
|
+
import type { TTemplateLiteral } from '../template-literal/index.mjs';
|
|
33
33
|
import type { TTuple } from '../tuple/index.mjs';
|
|
34
34
|
import type { TUint8Array } from '../uint8array/index.mjs';
|
|
35
35
|
import type { TUndefined } from '../undefined/index.mjs';
|
|
36
36
|
import type { TUnknown } from '../unknown/index.mjs';
|
|
37
|
+
import type { TUnion } from '../union/index.mjs';
|
|
37
38
|
import type { TUnsafe } from '../unsafe/index.mjs';
|
|
38
39
|
import type { TVoid } from '../void/index.mjs';
|
|
39
40
|
import type { TDate } from '../date/index.mjs';
|
|
@@ -44,6 +45,8 @@ export declare function IsReadonly<T extends TSchema>(value: T): value is TReado
|
|
|
44
45
|
export declare function IsOptional<T extends TSchema>(value: T): value is TOptional<T>;
|
|
45
46
|
/** `[Kind-Only]` Returns true if the given value is TAny */
|
|
46
47
|
export declare function IsAny(value: unknown): value is TAny;
|
|
48
|
+
/** `[Kind-Only]` Returns true if the given value is TArgument */
|
|
49
|
+
export declare function IsArgument(value: unknown): value is TArgument;
|
|
47
50
|
/** `[Kind-Only]` Returns true if the given value is TArray */
|
|
48
51
|
export declare function IsArray(value: unknown): value is TArray;
|
|
49
52
|
/** `[Kind-Only]` Returns true if the given value is TAsyncIterator */
|