arktype 2.2.10 → 3.0.0-beta.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/README.md +181 -15
- package/out/attributes.d.ts +50 -14
- package/out/checkers.d.ts +172 -0
- package/out/chunk-2U2AWCI3.js +626 -0
- package/out/chunk-4CUA5XIP.js +7 -0
- package/out/chunk-5U2ZMDNI.js +1566 -0
- package/out/chunk-DLWCO4RV.js +18 -0
- package/out/chunk-E3DZXEZK.js +72 -0
- package/out/chunk-EVCML554.js +47 -0
- package/out/chunk-G45P2CLE.js +63 -0
- package/out/chunk-GPNK5353.js +2529 -0
- package/out/chunk-MLKGABMK.js +9 -0
- package/out/chunk-NRIGTMPM.js +7 -0
- package/out/chunk-PRTMQCHS.js +3 -0
- package/out/chunk-R5G57XC7.js +7 -0
- package/out/chunk-RAZ3TXOE.js +313 -0
- package/out/chunk-SWOOCAHN.js +4 -0
- package/out/chunk-TAHPKDNM.js +3 -0
- package/out/chunk-UETB6YE2.js +14 -0
- package/out/chunk-UK5UGFOX.js +254 -0
- package/out/chunk-VV6YDN2D.js +6118 -0
- package/out/codecs.d.ts +21 -0
- package/out/codecs.js +7 -0
- package/out/config.d.ts +8 -3
- package/out/config.js +2 -3
- package/out/declare.d.ts +17 -3
- package/out/deferred.d.ts +10 -0
- package/out/errors.d.ts +1 -0
- package/out/errors.js +2 -0
- package/out/fn.d.ts +1 -1
- package/out/generic.d.ts +3 -3
- package/out/i18n.d.ts +2 -0
- package/out/i18n.js +2 -0
- package/out/index.d.ts +5 -4
- package/out/index.js +8 -9
- package/out/internal.d.ts +70 -0
- package/out/internal.js +17 -0
- package/out/island.d.ts +2 -0
- package/out/island.js +6 -0
- package/out/islandDependency.d.ts +2 -0
- package/out/islandDependency.js +18 -0
- package/out/keywords/Array.d.ts +2 -2
- package/out/keywords/builtins.d.ts +5 -3
- package/out/keywords/constructors.d.ts +9 -1
- package/out/keywords/functions.d.ts +254 -0
- package/out/keywords/keywords.d.ts +8 -9
- package/out/keywords/number.d.ts +2 -8
- package/out/keywords/phrases.d.ts +245 -0
- package/out/keywords/string.d.ts +14 -113
- package/out/keywords/ts.d.ts +35 -33
- package/out/keywords/ts.js +4 -82
- package/out/locale.d.ts +19 -0
- package/out/locales/de.d.ts +2 -0
- package/out/locales/de.js +2 -0
- package/out/locales/en.d.ts +4 -0
- package/out/locales/en.js +5 -0
- package/out/match.d.ts +6 -6
- package/out/module.d.ts +1 -1
- package/out/mutatesInput.js +3 -0
- package/out/parser/ast/generic.d.ts +6 -3
- package/out/parser/ast/infer.d.ts +1 -1
- package/out/parser/ast/validate.d.ts +11 -6
- package/out/parser/definition.d.ts +68 -7
- package/out/parser/objectLiteral.d.ts +40 -12
- package/out/parser/property.d.ts +3 -5
- package/out/parser/reduce/dynamic.d.ts +16 -7
- package/out/parser/reduce/shared.d.ts +4 -0
- package/out/parser/reduce/static.d.ts +13 -13
- package/out/parser/shift/operand/date.d.ts +0 -5
- package/out/parser/shift/operand/operand.d.ts +2 -1
- package/out/parser/shift/operand/unenclosed.d.ts +9 -6
- package/out/parser/shift/operand/unresolvable.d.ts +68 -0
- package/out/parser/shift/operator/bounds.d.ts +9 -4
- package/out/parser/shift/operator/brand.d.ts +2 -2
- package/out/parser/shift/operator/default.d.ts +2 -2
- package/out/parser/shift/operator/divisor.d.ts +2 -2
- package/out/parser/shift/operator/operator.d.ts +1 -1
- package/out/parser/shift/tokens.d.ts +9 -2
- package/out/parser/string.d.ts +61 -7
- package/out/parser/tupleExpressions.d.ts +7 -3
- package/out/precompiled.d.ts +1 -0
- package/out/precompiled.js +2 -0
- package/out/runtime.d.ts +181 -0
- package/out/runtime.js +4 -0
- package/out/runtimeDevelopment.d.ts +1 -0
- package/out/runtimeDevelopment.js +133 -0
- package/out/runtimeExports.d.ts +1 -0
- package/out/scope.d.ts +40 -11
- package/out/standalone/artifact.d.ts +265 -0
- package/out/standalone/baking.d.ts +201 -0
- package/out/standalone/combinators.d.ts +13 -0
- package/out/standalone/compilers.d.ts +23 -0
- package/out/standalone/creators.d.ts +41 -0
- package/out/standalone/fallbacks.d.ts +48 -0
- package/out/standalone/keys.d.ts +31 -0
- package/out/standalone/modules.d.ts +26 -0
- package/out/standalone/sites.d.ts +52 -0
- package/out/standalone/units.d.ts +31 -0
- package/out/standalone/values.d.ts +60 -0
- package/out/standalone.d.ts +16 -0
- package/out/type.d.ts +45 -6
- package/out/variants/array.d.ts +1 -1
- package/out/variants/base.d.ts +47 -27
- package/out/variants/date.d.ts +1 -1
- package/out/variants/instantiate.d.ts +4 -2
- package/out/variants/number.d.ts +1 -1
- package/out/variants/object.d.ts +17 -12
- package/out/variants/string.d.ts +1 -1
- package/package.json +169 -8
- package/skills/arktype/SKILL.md +278 -43
- package/skills/arktype/references/migrating.md +1296 -0
- package/skills/arktype/references/precompile.md +191 -0
- package/out/attributes.js +0 -3
- package/out/fn.js +0 -58
- package/out/generic.js +0 -37
- package/out/keywords/Array.js +0 -21
- package/out/keywords/FormData.js +0 -40
- package/out/keywords/TypedArray.js +0 -16
- package/out/keywords/builtins.js +0 -11
- package/out/keywords/constructors.js +0 -16
- package/out/keywords/keywords.js +0 -48
- package/out/keywords/number.js +0 -49
- package/out/keywords/string.js +0 -467
- package/out/match.js +0 -95
- package/out/module.js +0 -3
- package/out/nary.js +0 -1
- package/out/parser/ast/bounds.js +0 -1
- package/out/parser/ast/default.js +0 -1
- package/out/parser/ast/divisor.js +0 -1
- package/out/parser/ast/generic.js +0 -1
- package/out/parser/ast/infer.js +0 -1
- package/out/parser/ast/keyof.js +0 -1
- package/out/parser/ast/utils.js +0 -1
- package/out/parser/ast/validate.js +0 -3
- package/out/parser/definition.js +0 -78
- package/out/parser/objectLiteral.js +0 -113
- package/out/parser/property.js +0 -16
- package/out/parser/reduce/dynamic.js +0 -153
- package/out/parser/reduce/shared.js +0 -25
- package/out/parser/reduce/static.js +0 -1
- package/out/parser/shift/operand/date.js +0 -23
- package/out/parser/shift/operand/enclosed.js +0 -82
- package/out/parser/shift/operand/genericArgs.js +0 -16
- package/out/parser/shift/operand/operand.js +0 -16
- package/out/parser/shift/operand/unenclosed.js +0 -59
- package/out/parser/shift/operator/bounds.js +0 -91
- package/out/parser/shift/operator/brand.js +0 -6
- package/out/parser/shift/operator/default.js +0 -29
- package/out/parser/shift/operator/divisor.js +0 -13
- package/out/parser/shift/operator/operator.js +0 -28
- package/out/parser/shift/tokens.js +0 -37
- package/out/parser/string.js +0 -42
- package/out/parser/tupleExpressions.js +0 -75
- package/out/parser/tupleLiteral.js +0 -128
- package/out/scope.js +0 -106
- package/out/type.js +0 -55
- package/out/variants/array.js +0 -1
- package/out/variants/base.js +0 -1
- package/out/variants/date.js +0 -1
- package/out/variants/instantiate.js +0 -1
- package/out/variants/number.js +0 -1
- package/out/variants/object.js +0 -1
- package/out/variants/string.js +0 -1
- /package/out/{declare.js → mutatesInput.d.ts} +0 -0
package/out/keywords/string.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Intersection, type JsonSchema } from "@ark/schema";
|
|
2
|
-
import { type Json } from "@ark/util";
|
|
2
|
+
import { iso8601Matcher, type Json } from "@ark/util";
|
|
3
3
|
import type { To } from "../attributes.ts";
|
|
4
4
|
import type { Module, Submodule } from "../module.ts";
|
|
5
|
-
|
|
5
|
+
import { type KeywordPhraseAlias } from "./phrases.ts";
|
|
6
|
+
export { isLuhnValid } from "./functions.ts";
|
|
7
|
+
export declare const regexStringNode: (regex: RegExp, alias: KeywordPhraseAlias, annotations?: Pick<JsonSchema.String, "format" | "contentEncoding">) => Intersection.Node;
|
|
6
8
|
export declare const stringInteger: stringInteger.module;
|
|
7
9
|
export declare namespace stringInteger {
|
|
8
10
|
type module = Module<submodule>;
|
|
@@ -12,10 +14,7 @@ export declare namespace stringInteger {
|
|
|
12
14
|
parse: (In: string) => To<number>;
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
|
-
declare const base64:
|
|
16
|
-
root: unknown;
|
|
17
|
-
url: unknown;
|
|
18
|
-
}>;
|
|
17
|
+
declare const base64: base64.module;
|
|
19
18
|
declare namespace base64 {
|
|
20
19
|
type module = Module<submodule>;
|
|
21
20
|
type submodule = Submodule<$>;
|
|
@@ -33,8 +32,7 @@ export declare namespace capitalize {
|
|
|
33
32
|
preformatted: string;
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const creditCard: import("@ark/schema").BaseRoot<import("@ark/schema").InternalRootDeclaration>;
|
|
35
|
+
export declare const creditCard: () => import("@ark/schema").nodeOfKind<"intersection" | Intersection.BasisKind>;
|
|
38
36
|
type DayDelimiter = "." | "/" | "-";
|
|
39
37
|
type DayPart = DayPatterns[PartKey];
|
|
40
38
|
type PartKey = keyof DayPatterns;
|
|
@@ -53,7 +51,7 @@ export type DateFormat = "iso" | DayPattern;
|
|
|
53
51
|
export type DateOptions = {
|
|
54
52
|
format?: DateFormat;
|
|
55
53
|
};
|
|
56
|
-
export
|
|
54
|
+
export { iso8601Matcher };
|
|
57
55
|
export declare const tryParseDatePattern: (data: string, opts?: DateOptions) => Date | string;
|
|
58
56
|
export declare const stringDate: stringDate.module;
|
|
59
57
|
export declare namespace stringDate {
|
|
@@ -90,7 +88,6 @@ export declare namespace ip {
|
|
|
90
88
|
v6: string;
|
|
91
89
|
};
|
|
92
90
|
}
|
|
93
|
-
export declare const writeJsonSyntaxErrorProblem: (error: unknown) => string;
|
|
94
91
|
export declare const json: stringJson.module;
|
|
95
92
|
export declare namespace stringJson {
|
|
96
93
|
type module = Module<submodule>;
|
|
@@ -110,41 +107,11 @@ export declare namespace lower {
|
|
|
110
107
|
}
|
|
111
108
|
export declare const normalizedForms: readonly ["NFC", "NFD", "NFKC", "NFKD"];
|
|
112
109
|
export type NormalizedForm = (typeof normalizedForms)[number];
|
|
113
|
-
export declare const NFC: Module<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
export declare const
|
|
118
|
-
preformatted: unknown;
|
|
119
|
-
root: unknown;
|
|
120
|
-
}>;
|
|
121
|
-
export declare const NFKC: Module<{
|
|
122
|
-
preformatted: unknown;
|
|
123
|
-
root: unknown;
|
|
124
|
-
}>;
|
|
125
|
-
export declare const NFKD: Module<{
|
|
126
|
-
preformatted: unknown;
|
|
127
|
-
root: unknown;
|
|
128
|
-
}>;
|
|
129
|
-
export declare const normalize: Module<{
|
|
130
|
-
NFC: Submodule<{
|
|
131
|
-
preformatted: unknown;
|
|
132
|
-
root: unknown;
|
|
133
|
-
}>;
|
|
134
|
-
NFD: Submodule<{
|
|
135
|
-
preformatted: unknown;
|
|
136
|
-
root: unknown;
|
|
137
|
-
}>;
|
|
138
|
-
NFKC: Submodule<{
|
|
139
|
-
preformatted: unknown;
|
|
140
|
-
root: unknown;
|
|
141
|
-
}>;
|
|
142
|
-
NFKD: Submodule<{
|
|
143
|
-
preformatted: unknown;
|
|
144
|
-
root: unknown;
|
|
145
|
-
}>;
|
|
146
|
-
root: unknown;
|
|
147
|
-
}>;
|
|
110
|
+
export declare const NFC: Module<normalize.NFC.$>;
|
|
111
|
+
export declare const NFD: Module<normalize.NFD.$>;
|
|
112
|
+
export declare const NFKC: Module<normalize.NFKC.$>;
|
|
113
|
+
export declare const NFKD: Module<normalize.NFKD.$>;
|
|
114
|
+
export declare const normalize: normalize.module;
|
|
148
115
|
export declare namespace normalize {
|
|
149
116
|
type module = Module<submodule>;
|
|
150
117
|
type submodule = Submodule<$>;
|
|
@@ -219,17 +186,7 @@ export declare namespace url {
|
|
|
219
186
|
parse: (In: string) => To<URL>;
|
|
220
187
|
};
|
|
221
188
|
}
|
|
222
|
-
export declare const uuid:
|
|
223
|
-
root: string;
|
|
224
|
-
v1: unknown;
|
|
225
|
-
v2: unknown;
|
|
226
|
-
v3: unknown;
|
|
227
|
-
v4: unknown;
|
|
228
|
-
v5: unknown;
|
|
229
|
-
v6: unknown;
|
|
230
|
-
v7: unknown;
|
|
231
|
-
v8: unknown;
|
|
232
|
-
}>;
|
|
189
|
+
export declare const uuid: uuid.module;
|
|
233
190
|
export declare namespace uuid {
|
|
234
191
|
type module = Module<submodule>;
|
|
235
192
|
type submodule = Submodule<$>;
|
|
@@ -248,62 +205,7 @@ export declare namespace uuid {
|
|
|
248
205
|
type flat = {};
|
|
249
206
|
}
|
|
250
207
|
}
|
|
251
|
-
export declare const string:
|
|
252
|
-
alpha: unknown;
|
|
253
|
-
alphanumeric: unknown;
|
|
254
|
-
base58: unknown;
|
|
255
|
-
base64: Submodule<{
|
|
256
|
-
root: unknown;
|
|
257
|
-
url: unknown;
|
|
258
|
-
}>;
|
|
259
|
-
capitalize: Submodule<capitalize.submodule>;
|
|
260
|
-
creditCard: unknown;
|
|
261
|
-
date: Submodule<stringDate.submodule>;
|
|
262
|
-
digits: unknown;
|
|
263
|
-
email: unknown;
|
|
264
|
-
hex: unknown;
|
|
265
|
-
integer: Submodule<stringInteger.submodule>;
|
|
266
|
-
ip: Submodule<ip.submodule>;
|
|
267
|
-
json: Submodule<stringJson.submodule>;
|
|
268
|
-
lower: Submodule<lower.submodule>;
|
|
269
|
-
normalize: Submodule<{
|
|
270
|
-
NFC: Submodule<{
|
|
271
|
-
preformatted: unknown;
|
|
272
|
-
root: unknown;
|
|
273
|
-
}>;
|
|
274
|
-
NFD: Submodule<{
|
|
275
|
-
preformatted: unknown;
|
|
276
|
-
root: unknown;
|
|
277
|
-
}>;
|
|
278
|
-
NFKC: Submodule<{
|
|
279
|
-
preformatted: unknown;
|
|
280
|
-
root: unknown;
|
|
281
|
-
}>;
|
|
282
|
-
NFKD: Submodule<{
|
|
283
|
-
preformatted: unknown;
|
|
284
|
-
root: unknown;
|
|
285
|
-
}>;
|
|
286
|
-
root: unknown;
|
|
287
|
-
}>;
|
|
288
|
-
numeric: Submodule<stringNumeric.submodule>;
|
|
289
|
-
regex: unknown;
|
|
290
|
-
root: unknown;
|
|
291
|
-
semver: unknown;
|
|
292
|
-
trim: Submodule<trim.submodule>;
|
|
293
|
-
upper: Submodule<upper.submodule>;
|
|
294
|
-
url: Submodule<url.submodule>;
|
|
295
|
-
uuid: Submodule<{
|
|
296
|
-
root: string;
|
|
297
|
-
v1: unknown;
|
|
298
|
-
v2: unknown;
|
|
299
|
-
v3: unknown;
|
|
300
|
-
v4: unknown;
|
|
301
|
-
v5: unknown;
|
|
302
|
-
v6: unknown;
|
|
303
|
-
v7: unknown;
|
|
304
|
-
v8: unknown;
|
|
305
|
-
}>;
|
|
306
|
-
}>;
|
|
208
|
+
export declare const string: string.module;
|
|
307
209
|
export declare namespace string {
|
|
308
210
|
type module = Module<string.submodule>;
|
|
309
211
|
type submodule = Submodule<$>;
|
|
@@ -333,4 +235,3 @@ export declare namespace string {
|
|
|
333
235
|
uuid: uuid.submodule;
|
|
334
236
|
};
|
|
335
237
|
}
|
|
336
|
-
export {};
|
package/out/keywords/ts.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
1
|
+
import { type BaseRoot } from "@ark/schema";
|
|
2
|
+
import { Hkt, type Json, type Key, type omit, type pick, type show, type Thunk } from "@ark/util";
|
|
3
|
+
import type { required, To } from "../attributes.ts";
|
|
3
4
|
import type { Module, Submodule } from "../module.ts";
|
|
5
|
+
export declare const tsKeywordDefinitions: Record<keyof arkTsKeywords.$, Thunk<BaseRoot>>;
|
|
4
6
|
export declare const arkTsKeywords: arkTsKeywords;
|
|
5
7
|
export type arkTsKeywords = Module<arkTsKeywords.$>;
|
|
6
8
|
export declare namespace arkTsKeywords {
|
|
@@ -20,10 +22,7 @@ export declare namespace arkTsKeywords {
|
|
|
20
22
|
undefined: undefined;
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
|
-
export declare const unknown: Module<
|
|
24
|
-
any: unknown;
|
|
25
|
-
root: unknown;
|
|
26
|
-
}>;
|
|
25
|
+
export declare const unknown: Module<unknown.$>;
|
|
27
26
|
export declare namespace unknown {
|
|
28
27
|
type submodule = Submodule<$>;
|
|
29
28
|
type $ = {
|
|
@@ -31,10 +30,7 @@ export declare namespace unknown {
|
|
|
31
30
|
any: any;
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
export declare const json: Module<
|
|
35
|
-
root: unknown;
|
|
36
|
-
stringify: unknown;
|
|
37
|
-
}>;
|
|
33
|
+
export declare const json: Module<json.$>;
|
|
38
34
|
export declare namespace json {
|
|
39
35
|
type submodule = Submodule<$>;
|
|
40
36
|
type $ = {
|
|
@@ -42,13 +38,7 @@ export declare namespace json {
|
|
|
42
38
|
stringify: (In: Json) => To<string>;
|
|
43
39
|
};
|
|
44
40
|
}
|
|
45
|
-
export declare const object: Module<
|
|
46
|
-
json: Submodule<{
|
|
47
|
-
root: unknown;
|
|
48
|
-
stringify: unknown;
|
|
49
|
-
}>;
|
|
50
|
-
root: unknown;
|
|
51
|
-
}>;
|
|
41
|
+
export declare const object: Module<object.$>;
|
|
52
42
|
export declare namespace object {
|
|
53
43
|
type submodule = Submodule<$>;
|
|
54
44
|
type $ = {
|
|
@@ -56,53 +46,65 @@ export declare namespace object {
|
|
|
56
46
|
json: json.submodule;
|
|
57
47
|
};
|
|
58
48
|
}
|
|
59
|
-
declare class RecordHkt extends Hkt<[Key, unknown]> {
|
|
49
|
+
export declare class RecordHkt extends Hkt<[Key, unknown]> {
|
|
60
50
|
body: Record<this[0], this[1]>;
|
|
51
|
+
private record;
|
|
61
52
|
description: string;
|
|
62
53
|
}
|
|
63
|
-
declare const Record: import("@ark/schema").GenericRoot<readonly [["K", Key], ["V", unknown]], RecordHkt>;
|
|
54
|
+
declare const Record: () => import("@ark/schema").GenericRoot<readonly [["K", Key], ["V", unknown]], RecordHkt>;
|
|
64
55
|
declare class PickHkt extends Hkt<[object, Key]> {
|
|
65
56
|
body: pick<this[0], this[1] & keyof this[0]>;
|
|
66
57
|
description: string;
|
|
67
58
|
}
|
|
68
|
-
declare const Pick: import("@ark/schema").GenericRoot<readonly [["T", object], ["K", Key]], PickHkt>;
|
|
59
|
+
declare const Pick: () => import("@ark/schema").GenericRoot<readonly [["T", object], ["K", Key]], PickHkt>;
|
|
69
60
|
declare class OmitHkt extends Hkt<[object, Key]> {
|
|
70
61
|
body: omit<this[0], this[1] & keyof this[0]>;
|
|
71
62
|
description: string;
|
|
72
63
|
}
|
|
73
|
-
declare const Omit: import("@ark/schema").GenericRoot<readonly [["T", object], ["K", Key]], OmitHkt>;
|
|
64
|
+
declare const Omit: () => import("@ark/schema").GenericRoot<readonly [["T", object], ["K", Key]], OmitHkt>;
|
|
74
65
|
declare class PartialHkt extends Hkt<[object]> {
|
|
75
66
|
body: show<Partial<this[0]>>;
|
|
76
67
|
description: string;
|
|
77
68
|
}
|
|
78
|
-
declare const Partial: import("@ark/schema").GenericRoot<readonly [["T", object]], PartialHkt>;
|
|
69
|
+
declare const Partial: () => import("@ark/schema").GenericRoot<readonly [["T", object]], PartialHkt>;
|
|
79
70
|
declare class RequiredHkt extends Hkt<[object]> {
|
|
80
|
-
body: show<
|
|
71
|
+
body: show<required<this[0]>>;
|
|
81
72
|
description: string;
|
|
82
73
|
}
|
|
83
|
-
declare const Required: import("@ark/schema").GenericRoot<readonly [["T", object]], RequiredHkt>;
|
|
74
|
+
declare const Required: () => import("@ark/schema").GenericRoot<readonly [["T", object]], RequiredHkt>;
|
|
84
75
|
declare class ExcludeHkt extends Hkt<[unknown, unknown]> {
|
|
85
76
|
body: Exclude<this[0], this[1]>;
|
|
86
77
|
description: string;
|
|
87
78
|
}
|
|
88
|
-
declare const Exclude: import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExcludeHkt>;
|
|
79
|
+
declare const Exclude: () => import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExcludeHkt>;
|
|
89
80
|
declare class ExtractHkt extends Hkt<[unknown, unknown]> {
|
|
90
81
|
body: Extract<this[0], this[1]>;
|
|
91
82
|
description: string;
|
|
92
83
|
}
|
|
93
|
-
declare const Extract: import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExtractHkt>;
|
|
84
|
+
declare const Extract: () => import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExtractHkt>;
|
|
85
|
+
export declare const tsGenericDefinitions: {
|
|
86
|
+
Exclude: () => import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExcludeHkt>;
|
|
87
|
+
Extract: () => import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExtractHkt>;
|
|
88
|
+
Omit: () => import("@ark/schema").GenericRoot<readonly [["T", object], ["K", Key]], OmitHkt>;
|
|
89
|
+
Partial: () => import("@ark/schema").GenericRoot<readonly [["T", object]], PartialHkt>;
|
|
90
|
+
Pick: () => import("@ark/schema").GenericRoot<readonly [["T", object], ["K", Key]], PickHkt>;
|
|
91
|
+
Record: () => import("@ark/schema").GenericRoot<readonly [["K", Key], ["V", unknown]], RecordHkt>;
|
|
92
|
+
Required: () => import("@ark/schema").GenericRoot<readonly [["T", object]], RequiredHkt>;
|
|
93
|
+
};
|
|
94
94
|
export declare const arkTsGenerics: arkTsGenerics.module;
|
|
95
95
|
export declare namespace arkTsGenerics {
|
|
96
96
|
type module = Module<arkTsGenerics.$>;
|
|
97
97
|
type submodule = Submodule<$>;
|
|
98
98
|
type $ = {
|
|
99
|
-
Exclude: typeof Exclude
|
|
100
|
-
Extract: typeof Extract
|
|
101
|
-
Omit: typeof Omit
|
|
102
|
-
Partial: typeof Partial
|
|
103
|
-
Pick: typeof Pick
|
|
104
|
-
Record: typeof Record
|
|
105
|
-
Required: typeof Required
|
|
99
|
+
Exclude: ReturnType<typeof Exclude>["t"];
|
|
100
|
+
Extract: ReturnType<typeof Extract>["t"];
|
|
101
|
+
Omit: ReturnType<typeof Omit>["t"];
|
|
102
|
+
Partial: ReturnType<typeof Partial>["t"];
|
|
103
|
+
Pick: ReturnType<typeof Pick>["t"];
|
|
104
|
+
Record: ReturnType<typeof Record>["t"];
|
|
105
|
+
Required: ReturnType<typeof Required>["t"];
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
+
export declare const writeUnresolvedFilterMessage: <operator extends string>(operator: operator) => writeUnresolvedFilterMessage<operator>;
|
|
109
|
+
export type writeUnresolvedFilterMessage<operator extends string> = `${operator} can't filter a type still being defined`;
|
|
108
110
|
export {};
|
package/out/keywords/ts.js
CHANGED
|
@@ -1,82 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
bigint: intrinsic.bigint,
|
|
6
|
-
boolean: intrinsic.boolean,
|
|
7
|
-
false: intrinsic.false,
|
|
8
|
-
never: intrinsic.never,
|
|
9
|
-
null: intrinsic.null,
|
|
10
|
-
number: intrinsic.number,
|
|
11
|
-
object: intrinsic.object,
|
|
12
|
-
string: intrinsic.string,
|
|
13
|
-
symbol: intrinsic.symbol,
|
|
14
|
-
true: intrinsic.true,
|
|
15
|
-
unknown: intrinsic.unknown,
|
|
16
|
-
undefined: intrinsic.undefined
|
|
17
|
-
});
|
|
18
|
-
export const unknown = Scope.module({
|
|
19
|
-
root: intrinsic.unknown,
|
|
20
|
-
any: intrinsic.unknown
|
|
21
|
-
}, {
|
|
22
|
-
name: "unknown"
|
|
23
|
-
});
|
|
24
|
-
export const json = Scope.module({
|
|
25
|
-
root: intrinsic.jsonObject,
|
|
26
|
-
stringify: node("morph", {
|
|
27
|
-
in: intrinsic.jsonObject,
|
|
28
|
-
morphs: (data) => JSON.stringify(data),
|
|
29
|
-
declaredOut: intrinsic.string
|
|
30
|
-
})
|
|
31
|
-
}, {
|
|
32
|
-
name: "object.json"
|
|
33
|
-
});
|
|
34
|
-
export const object = Scope.module({
|
|
35
|
-
root: intrinsic.object,
|
|
36
|
-
json
|
|
37
|
-
}, {
|
|
38
|
-
name: "object"
|
|
39
|
-
});
|
|
40
|
-
class RecordHkt extends Hkt {
|
|
41
|
-
description = 'instantiate an object from an index signature and corresponding value type like `Record("string", "number")`';
|
|
42
|
-
}
|
|
43
|
-
const Record = genericNode(["K", intrinsic.key], "V")(args => ({
|
|
44
|
-
domain: "object",
|
|
45
|
-
index: {
|
|
46
|
-
signature: args.K,
|
|
47
|
-
value: args.V
|
|
48
|
-
}
|
|
49
|
-
}), RecordHkt);
|
|
50
|
-
class PickHkt extends Hkt {
|
|
51
|
-
description = 'pick a set of properties from an object like `Pick(User, "name | age")`';
|
|
52
|
-
}
|
|
53
|
-
const Pick = genericNode(["T", intrinsic.object], ["K", intrinsic.key])(args => args.T.pick(args.K), PickHkt);
|
|
54
|
-
class OmitHkt extends Hkt {
|
|
55
|
-
description = 'omit a set of properties from an object like `Omit(User, "age")`';
|
|
56
|
-
}
|
|
57
|
-
const Omit = genericNode(["T", intrinsic.object], ["K", intrinsic.key])(args => args.T.omit(args.K), OmitHkt);
|
|
58
|
-
class PartialHkt extends Hkt {
|
|
59
|
-
description = "make all named properties of an object optional like `Partial(User)`";
|
|
60
|
-
}
|
|
61
|
-
const Partial = genericNode(["T", intrinsic.object])(args => args.T.partial(), PartialHkt);
|
|
62
|
-
class RequiredHkt extends Hkt {
|
|
63
|
-
description = "make all named properties of an object required like `Required(User)`";
|
|
64
|
-
}
|
|
65
|
-
const Required = genericNode(["T", intrinsic.object])(args => args.T.required(), RequiredHkt);
|
|
66
|
-
class ExcludeHkt extends Hkt {
|
|
67
|
-
description = 'exclude branches of a union like `Exclude("boolean", "true")`';
|
|
68
|
-
}
|
|
69
|
-
const Exclude = genericNode("T", "U")(args => args.T.exclude(args.U), ExcludeHkt);
|
|
70
|
-
class ExtractHkt extends Hkt {
|
|
71
|
-
description = 'extract branches of a union like `Extract("0 | false | 1", "number")`';
|
|
72
|
-
}
|
|
73
|
-
const Extract = genericNode("T", "U")(args => args.T.extract(args.U), ExtractHkt);
|
|
74
|
-
export const arkTsGenerics = Scope.module({
|
|
75
|
-
Exclude,
|
|
76
|
-
Extract,
|
|
77
|
-
Omit,
|
|
78
|
-
Partial,
|
|
79
|
-
Pick,
|
|
80
|
-
Record,
|
|
81
|
-
Required
|
|
82
|
-
});
|
|
1
|
+
export { RecordHkt, arkTsGenerics, arkTsKeywords, json, object, tsGenericDefinitions, tsKeywordDefinitions, unknown, writeUnresolvedFilterMessage } from "../chunk-GPNK5353.js";
|
|
2
|
+
import "../chunk-G45P2CLE.js";
|
|
3
|
+
import "../chunk-UK5UGFOX.js";
|
|
4
|
+
import "../chunk-MLKGABMK.js";
|
package/out/locale.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ArkErrorCode, Locale as BaseLocale } from "@ark/schema";
|
|
2
|
+
import type { KeywordPhraseAlias } from "./keywords/phrases.ts";
|
|
3
|
+
/** the text arktype's errors render in, with a phrase per builtin keyword */
|
|
4
|
+
export type Locale = BaseLocale<KeywordPhraseAlias>;
|
|
5
|
+
export declare namespace Locale {
|
|
6
|
+
type Info = BaseLocale.Info;
|
|
7
|
+
type Data = BaseLocale.Data<KeywordPhraseAlias>;
|
|
8
|
+
type Writers = BaseLocale.Writers;
|
|
9
|
+
type CodeWriters<code extends ArkErrorCode = ArkErrorCode> = BaseLocale.CodeWriters<code>;
|
|
10
|
+
type ExpectedContext<code extends ArkErrorCode = ArkErrorCode> = BaseLocale.ExpectedContext<code>;
|
|
11
|
+
type ExpectedWriter<code extends ArkErrorCode = ArkErrorCode> = BaseLocale.ExpectedWriter<code>;
|
|
12
|
+
type ActualWriter<code extends ArkErrorCode = ArkErrorCode> = BaseLocale.ActualWriter<code>;
|
|
13
|
+
type MessageWriter<code extends ArkErrorCode = ArkErrorCode> = BaseLocale.MessageWriter<code>;
|
|
14
|
+
type LineWriter = BaseLocale.LineWriter;
|
|
15
|
+
type KeywordPhrase = BaseLocale.KeywordPhrase;
|
|
16
|
+
type KeywordWriters = BaseLocale.KeywordWriters;
|
|
17
|
+
type KeywordExpectedWriter = BaseLocale.KeywordExpectedWriter;
|
|
18
|
+
type Complete = BaseLocale.Complete<KeywordPhraseAlias>;
|
|
19
|
+
}
|
package/out/match.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { type ArkErrors, type BaseRoot, type Morph } from "@ark/schema";
|
|
|
2
2
|
import { Callable, type conform, type ErrorMessage, type ErrorType, type isDisjoint, type Key, type numericStringKeyOf, type propValueOf, type show, type unionToTuple } from "@ark/util";
|
|
3
3
|
import type { distill, Out } from "./attributes.ts";
|
|
4
4
|
import type { type } from "./keywords/keywords.ts";
|
|
5
|
+
import type { validateDefinition } from "./parser/definition.ts";
|
|
5
6
|
import type { BaseCompletions } from "./parser/string.ts";
|
|
6
|
-
import type { InternalScope } from "./scope.ts";
|
|
7
|
+
import type { bindThis, InternalScope } from "./scope.ts";
|
|
7
8
|
import type { Inferred } from "./variants/base.ts";
|
|
8
9
|
type MatchParserContext<input = unknown> = {
|
|
9
10
|
cases: Morph[];
|
|
@@ -97,17 +98,17 @@ interface ChainableMatchParser<ctx extends MatchParserContext> {
|
|
|
97
98
|
match: CaseMatchParser<ctx>;
|
|
98
99
|
default: DefaultMethod<ctx>;
|
|
99
100
|
at: AtParser<ctx>;
|
|
100
|
-
/** @experimental */
|
|
101
101
|
strings: StringsParser<ctx>;
|
|
102
102
|
}
|
|
103
103
|
export type DefaultCaseKeyword = "never" | "assert" | "reject";
|
|
104
104
|
type DefaultCase<ctx extends MatchParserContext = MatchParserContext<any>> = DefaultCaseKeyword | Morph<ctx["input"]>;
|
|
105
105
|
type DefaultMethod<ctx extends MatchParserContext> = <const def extends DefaultCase<ctx>>(def: def) => finalizeMatchParser<ctx, def>;
|
|
106
|
+
type validateCase<def, ctx extends MatchParserContext> = validateDefinition<def, ctx["$"], bindThis<def>>;
|
|
106
107
|
type validateCases<cases, ctx extends MatchParserContext> = {
|
|
107
|
-
[def in keyof cases
|
|
108
|
+
[def in keyof cases]?: def extends "default" ? DefaultCase<ctx> : def extends number ? (In: inferCaseArg<`${def}`, ctx, "out">) => unknown : def extends validateCase<def, ctx> ? (In: inferCaseArg<def, ctx, "out">) => unknown : validateCase<def, ctx>;
|
|
108
109
|
};
|
|
109
110
|
type errorCases<cases, ctx extends MatchParserContext> = {
|
|
110
|
-
[def in keyof cases]?: def extends "default" ? DefaultCase<ctx> : def extends number ? (In: inferCaseArg<`${def}`, ctx, "out">) => unknown : def extends
|
|
111
|
+
[def in keyof cases]?: def extends "default" ? DefaultCase<ctx> : def extends number ? (In: inferCaseArg<`${def}`, ctx, "out">) => unknown : def extends validateCase<def, ctx> ? (In: inferCaseArg<def, ctx, "out">) => unknown : ErrorType<validateCase<def, ctx>>;
|
|
111
112
|
} & {
|
|
112
113
|
[k in BaseCompletions<ctx["$"], {}>]?: (In: inferCaseArg<k, ctx, "out">) => unknown;
|
|
113
114
|
} & {
|
|
@@ -115,7 +116,7 @@ type errorCases<cases, ctx extends MatchParserContext> = {
|
|
|
115
116
|
};
|
|
116
117
|
export type CaseMatchParser<ctx extends MatchParserContext> = <const cases>(def: cases extends validateCases<cases, ctx> ? cases : errorCases<cases, ctx>) => addCasesToParser<cases, ctx, "def">;
|
|
117
118
|
type finalizeMatchParser<ctx extends MatchParserContext, defaultCase extends DefaultCase<ctx>> = addDefaultToContext<ctx, defaultCase> extends (infer ctx extends MatchParserContext) ? Match<ctx["input"], ctx["cases"]> : never;
|
|
118
|
-
export interface Match<In = any, cases extends Morph[] = Morph[]> extends Inferred<(In: Morph.In<cases[number]>) => Out<ReturnType<cases[number]>>> {
|
|
119
|
+
export interface Match<in out In = any, in out cases extends Morph[] = Morph[]> extends Inferred<(In: Morph.In<cases[number]>) => Out<ReturnType<cases[number]>>> {
|
|
119
120
|
<const data extends In>(data: data): {
|
|
120
121
|
[i in numericStringKeyOf<cases>]: isDisjoint<data, Morph.In<cases[i]>> extends true ? never : Morph.Out<cases[i]>;
|
|
121
122
|
}[numericStringKeyOf<cases>];
|
|
@@ -144,7 +145,6 @@ export declare class InternalChainedMatchParser extends Callable<InternalCasePar
|
|
|
144
145
|
protected caseEntries(entries: CaseEntry[]): InternalChainedMatchParser | Match;
|
|
145
146
|
default(defaultCase: DefaultCase): Match;
|
|
146
147
|
}
|
|
147
|
-
export declare const throwOnDefault: ArkErrors.Handler;
|
|
148
148
|
export declare const chainedAtMessage = "A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')";
|
|
149
149
|
export type chainedAtMessage = typeof chainedAtMessage;
|
|
150
150
|
export declare const doubleAtMessage = "At most one key matcher may be specified per expression";
|
package/out/module.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ export type instantiateExport<t, $> = [
|
|
|
19
19
|
t
|
|
20
20
|
] extends [PreparsedNodeResolution] ? [
|
|
21
21
|
t
|
|
22
|
-
] extends [anyOrNever] ? Type<t, $> : t extends GenericAst<infer params, infer body, infer body
|
|
22
|
+
] extends [anyOrNever] ? Type<t, $> : t extends GenericAst<infer params, infer body, infer body$, any> ? Generic<params, body, body$, $> : t extends Submodule<infer exports> ? BoundModule<exports, $> : never : Type<t, $>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { GenericAst, GenericParamAst, writeUnsatisfiedParameterConstraintMessage } from "@ark/schema";
|
|
2
|
-
import type { array, ErrorMessage, Hkt, typeToString } from "@ark/util";
|
|
2
|
+
import type { array, ErrorMessage, Hkt, Key, typeToString } from "@ark/util";
|
|
3
|
+
import type { RecordHkt } from "../../keywords/ts.ts";
|
|
3
4
|
import type { UnparsedScope } from "../../scope.ts";
|
|
4
5
|
import type { inferDefinition } from "../definition.ts";
|
|
5
6
|
import type { inferAstRoot, inferExpression } from "./infer.ts";
|
|
6
7
|
import type { astToString } from "./utils.ts";
|
|
7
8
|
import type { validateAst } from "./validate.ts";
|
|
8
9
|
export type GenericInstantiationAst<generic extends GenericAst = GenericAst, argAsts extends unknown[] = unknown[]> = [generic, "<>", argAsts];
|
|
9
|
-
export type inferGenericInstantiation<g extends GenericAst, argAsts extends unknown[], $, args> = g["bodyDef"] extends
|
|
10
|
+
export type inferGenericInstantiation<g extends GenericAst, argAsts extends unknown[], $, args> = g["bodyDef"] extends RecordHkt ? {
|
|
11
|
+
[k in inferExpression<argAsts[0], $, args> & Key]: inferExpression<argAsts[1], $, args>;
|
|
12
|
+
} : g["bodyDef"] extends Hkt ? Hkt.apply<g["bodyDef"], {
|
|
10
13
|
[i in keyof argAsts]: inferExpression<argAsts[i], $, args>;
|
|
11
14
|
}> : inferDefinition<g["bodyDef"], resolveScope<g["$"], $>, {
|
|
12
|
-
[i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts],
|
|
15
|
+
[i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts], $, args>;
|
|
13
16
|
}>;
|
|
14
17
|
export type validateGenericInstantiation<g extends GenericAst, argAsts extends unknown[], $, args> = validateGenericArgs<g["paramsAst"], argAsts, $, args, []>;
|
|
15
18
|
type validateGenericArgs<params extends array<GenericParamAst>, argAsts extends array, $, args, indices extends 1[]> = argAsts extends readonly [infer arg, ...infer argsTail] ? validateAst<arg, $, args> extends infer e extends ErrorMessage ? e : inferAstRoot<arg, $, args> extends params[indices["length"]][1] ? validateGenericArgs<params, argsTail, $, args, [...indices, 1]> : ErrorMessage<writeUnsatisfiedParameterConstraintMessage<params[indices["length"]][0], typeToString<params[indices["length"]][1]>, astToString<arg>>> : undefined;
|
|
@@ -19,7 +19,7 @@ export type InferredAst<t = unknown, def extends string = string> = [
|
|
|
19
19
|
"inferred",
|
|
20
20
|
def
|
|
21
21
|
];
|
|
22
|
-
export type inferExpression<ast, $, args> = ast extends array ? ast extends
|
|
22
|
+
export type inferExpression<ast, $, args> = ast extends array ? ast extends [infer resolution, "inferred", unknown] ? resolution : ast[1] extends "def" ? inferDefinition<ast[0], $, args> : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? inferExpression<ast[2], $, args> : inferExpression<ast[0], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "|>" ? inferPipe<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? inferDefaultLiteral<ast[2]> extends infer defaultValue ? withDefault<inferExpression<ast[0], $, args>, defaultValue> : never : ast[1] extends "#" ? type.brand<inferExpression<ast[0], $, args>, ast[2]> : ast[1] extends "%" | "?" ? inferExpression<ast[0], $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? inferGenericInstantiation<g, argAsts, $, args> : ast[0] extends "keyof" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;
|
|
23
23
|
export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
|
|
24
24
|
export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
|
|
25
25
|
export type PostfixExpression<operator extends PostfixToken = PostfixToken, operand = unknown> = readonly [operand, operator];
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
import type { arkKind, PrivateDeclaration, writeMissingSubmoduleAccessMessage } from "@ark/schema";
|
|
2
|
-
import type { anyOrNever, BigintLiteral, Completion, ErrorMessage, NumberLiteral, writeMalformedNumericLiteralMessage } from "@ark/util";
|
|
2
|
+
import type { anyOrNever, array, BigintLiteral, Completion, ErrorMessage, NumberLiteral, writeMalformedNumericLiteralMessage } from "@ark/util";
|
|
3
3
|
import type { Generic } from "../../generic.ts";
|
|
4
4
|
import type { BranchOperator, Comparator } from "../reduce/shared.ts";
|
|
5
5
|
import type { writeInvalidGenericArgCountMessage } from "../shift/operand/genericArgs.ts";
|
|
6
6
|
import type { DefaultLiteral } from "../shift/operator/default.ts";
|
|
7
|
+
import type { InfixToken } from "../shift/tokens.ts";
|
|
7
8
|
import type { parseString } from "../string.ts";
|
|
8
9
|
import type { validateRange } from "./bounds.ts";
|
|
9
10
|
import type { validateDefault } from "./default.ts";
|
|
10
11
|
import type { validateDivisor } from "./divisor.ts";
|
|
11
12
|
import type { GenericInstantiationAst, validateGenericInstantiation } from "./generic.ts";
|
|
12
|
-
import type {
|
|
13
|
+
import type { InferredAst } from "./infer.ts";
|
|
13
14
|
import type { validateKeyof } from "./keyof.ts";
|
|
14
15
|
import type { astToString } from "./utils.ts";
|
|
15
|
-
export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends
|
|
16
|
+
export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends array ? ast[1] extends "def" ? ast[2] extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : undefined : ast[1] extends BranchOperator ? validateInfix<ast, $, args> : ast[1] extends "[]" | "?" ? validateAst<ast[0], $, args> : ast[1] extends Comparator ? validateRange<ast[0], ast[1], ast[2], $, args> : ast[1] extends "%" ? validateDivisor<ast[0], $, args> : ast[1] extends "=" ? validateDefault<ast[0], ast[2] & DefaultLiteral, $, args> : ast[1] extends "#" ? validateAst<ast[0], $, args> : ast[1] extends InfixToken ? ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> : ast extends ["keyof", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericInstantiation<g, argAsts, $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
|
|
17
|
+
ast: ast;
|
|
18
|
+
} : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
|
|
16
19
|
ast: ast;
|
|
17
20
|
};
|
|
18
21
|
type writeUnexpectedExpressionMessage<expression extends string> = `Failed to parse the expression resulting from ${expression}`;
|
|
19
22
|
export declare const writePrefixedPrivateReferenceMessage: <name extends string>(name: name) => writePrefixedPrivateReferenceMessage<name>;
|
|
20
23
|
export type writePrefixedPrivateReferenceMessage<name extends string> = `Private type references should not include '#'. Use '${name}' instead.`;
|
|
21
|
-
type validateInferredAst<inferred, def extends string> = def extends NumberLiteral ? number extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral ? bigint extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : [inferred] extends [anyOrNever] ? undefined : def extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : inferred extends
|
|
24
|
+
type validateInferredAst<inferred, def extends string> = def extends NumberLiteral ? number extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral ? bigint extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : [inferred] extends [anyOrNever] ? undefined : def extends PrivateDeclaration<infer name> ? ErrorMessage<writePrefixedPrivateReferenceMessage<name>> : inferred extends {
|
|
25
|
+
[arkKind]: "generic";
|
|
26
|
+
} ? inferred extends Generic ? ErrorMessage<writeInvalidGenericArgCountMessage<def, inferred["names"], []>> : undefined : inferred extends {
|
|
22
27
|
[arkKind]: "module";
|
|
23
28
|
} ? "root" extends keyof inferred ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : def extends ErrorMessage ? def : undefined;
|
|
24
|
-
export type validateString<def extends string, $, args> = parseString<def, $, args
|
|
25
|
-
type validateInfix<ast extends
|
|
29
|
+
export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends (infer result extends ErrorMessage) ? result extends Completion<infer text> ? text : result : def;
|
|
30
|
+
type validateInfix<ast extends array, $, args> = validateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e : validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e : undefined;
|
|
26
31
|
export declare const shallowOptionalMessage = "Optional definitions like 'string?' are only valid as properties in an object or tuple";
|
|
27
32
|
export type shallowOptionalMessage = typeof shallowOptionalMessage;
|
|
28
33
|
export declare const shallowDefaultableMessage = "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";
|