arktype 2.0.0-rc.4 → 2.0.0-rc.6

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.
Files changed (92) hide show
  1. package/out/generic.d.ts +34 -36
  2. package/out/generic.js +1 -1
  3. package/out/index.d.ts +2 -2
  4. package/out/index.js +1 -1
  5. package/out/intersect.d.ts +2 -4
  6. package/out/keywords/ark.d.ts +20 -3
  7. package/out/keywords/ark.js +3 -2
  8. package/out/keywords/ast.d.ts +97 -102
  9. package/out/keywords/builtins.js +2 -2
  10. package/out/keywords/constructors/Array.d.ts +1 -1
  11. package/out/keywords/constructors/Array.js +4 -4
  12. package/out/keywords/constructors/Date.d.ts +31 -0
  13. package/out/keywords/constructors/FormData.d.ts +1 -1
  14. package/out/keywords/constructors/FormData.js +3 -3
  15. package/out/keywords/constructors/TypedArray.js +2 -2
  16. package/out/keywords/constructors/constructors.js +2 -2
  17. package/out/keywords/number/epoch.d.ts +1 -2
  18. package/out/keywords/number/number.d.ts +31 -6
  19. package/out/keywords/number/number.js +17 -5
  20. package/out/keywords/string/capitalize.d.ts +1 -1
  21. package/out/keywords/string/capitalize.js +3 -3
  22. package/out/keywords/string/date.d.ts +3 -7
  23. package/out/keywords/string/date.js +11 -11
  24. package/out/keywords/string/integer.d.ts +1 -1
  25. package/out/keywords/string/integer.js +5 -5
  26. package/out/keywords/string/ip.d.ts +1 -1
  27. package/out/keywords/string/ip.js +3 -3
  28. package/out/keywords/string/json.d.ts +1 -1
  29. package/out/keywords/string/json.js +4 -4
  30. package/out/keywords/string/lower.d.ts +1 -1
  31. package/out/keywords/string/lower.js +3 -3
  32. package/out/keywords/string/normalize.d.ts +14 -18
  33. package/out/keywords/string/normalize.js +11 -11
  34. package/out/keywords/string/numeric.d.ts +1 -1
  35. package/out/keywords/string/numeric.js +5 -5
  36. package/out/keywords/string/string.d.ts +18 -22
  37. package/out/keywords/string/string.js +3 -3
  38. package/out/keywords/string/trim.d.ts +1 -1
  39. package/out/keywords/string/trim.js +3 -3
  40. package/out/keywords/string/upper.d.ts +1 -1
  41. package/out/keywords/string/upper.js +3 -3
  42. package/out/keywords/string/url.d.ts +1 -1
  43. package/out/keywords/string/url.js +5 -5
  44. package/out/keywords/string/uuid.d.ts +2 -2
  45. package/out/keywords/string/uuid.js +3 -3
  46. package/out/keywords/ts.d.ts +11 -0
  47. package/out/keywords/ts.js +7 -3
  48. package/out/keywords/utils.d.ts +1 -1
  49. package/out/keywords/utils.js +1 -1
  50. package/out/{subtypes → methods}/array.d.ts +6 -6
  51. package/out/methods/base.d.ts +87 -0
  52. package/out/{subtypes → methods}/date.d.ts +5 -5
  53. package/out/methods/morph.d.ts +13 -0
  54. package/out/{subtypes → methods}/number.d.ts +6 -6
  55. package/out/{subtypes → methods}/object.d.ts +1 -2
  56. package/out/{subtypes → methods}/string.d.ts +7 -7
  57. package/out/{subtypes → methods}/validator.d.ts +2 -2
  58. package/out/methods/validator.js +1 -0
  59. package/out/module.d.ts +2 -2
  60. package/out/parser/objectLiteral.d.ts +5 -30
  61. package/out/parser/objectLiteral.js +18 -21
  62. package/out/parser/semantic/default.d.ts +3 -4
  63. package/out/parser/semantic/default.js +1 -1
  64. package/out/parser/semantic/infer.d.ts +8 -7
  65. package/out/parser/semantic/validate.d.ts +2 -2
  66. package/out/parser/string/reduce/dynamic.d.ts +1 -2
  67. package/out/parser/string/reduce/dynamic.js +2 -4
  68. package/out/parser/string/shift/operand/date.d.ts +2 -0
  69. package/out/parser/string/shift/operand/enclosed.d.ts +2 -1
  70. package/out/parser/string/shift/operand/enclosed.js +7 -3
  71. package/out/parser/string/shift/operator/default.d.ts +2 -5
  72. package/out/parser/string/shift/operator/default.js +1 -6
  73. package/out/parser/string/string.d.ts +2 -3
  74. package/out/parser/tuple.d.ts +6 -5
  75. package/out/parser/tuple.js +13 -6
  76. package/out/scope.d.ts +9 -5
  77. package/out/scope.js +12 -8
  78. package/out/type.d.ts +13 -12
  79. package/out/type.js +4 -1
  80. package/package.json +3 -3
  81. package/out/subtypes/base.d.ts +0 -85
  82. package/out/subtypes/morph.d.ts +0 -13
  83. /package/out/{subtypes/array.js → keywords/constructors/Date.js} +0 -0
  84. /package/out/{subtypes/base.js → methods/array.js} +0 -0
  85. /package/out/{subtypes/date.js → methods/base.js} +0 -0
  86. /package/out/{subtypes/instantiate.js → methods/date.js} +0 -0
  87. /package/out/{subtypes → methods}/instantiate.d.ts +0 -0
  88. /package/out/{subtypes/morph.js → methods/instantiate.js} +0 -0
  89. /package/out/{subtypes/number.js → methods/morph.js} +0 -0
  90. /package/out/{subtypes/object.js → methods/number.js} +0 -0
  91. /package/out/{subtypes/string.js → methods/object.js} +0 -0
  92. /package/out/{subtypes/validator.js → methods/string.js} +0 -0
@@ -8,7 +8,7 @@ export declare namespace trim {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: (In: string) => To<string.trimmed>;
11
+ root: (In: string) => To<string.trimmed>;
12
12
  preformatted: string.trimmed;
13
13
  };
14
14
  }
@@ -1,11 +1,11 @@
1
1
  import { rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
2
+ import { arkModule } from "../utils.js";
3
3
  import { regexStringNode } from "./utils.js";
4
4
  const preformatted = regexStringNode(
5
5
  // no leading or trailing whitespace
6
6
  /^\S.*\S$|^\S?$/, "trimmed");
7
- export const trim = submodule({
8
- $root: rootNode({
7
+ export const trim = arkModule({
8
+ root: rootNode({
9
9
  in: "string",
10
10
  morphs: (s) => s.trim(),
11
11
  declaredOut: preformatted
@@ -8,7 +8,7 @@ export declare namespace upper {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: (In: string) => To<string.uppercase>;
11
+ root: (In: string) => To<string.uppercase>;
12
12
  preformatted: string.uppercase;
13
13
  };
14
14
  }
@@ -1,9 +1,9 @@
1
1
  import { rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
2
+ import { arkModule } from "../utils.js";
3
3
  import { regexStringNode } from "./utils.js";
4
4
  const preformatted = regexStringNode(/^[A-Z]*$/, "only uppercase letters");
5
- export const upper = submodule({
6
- $root: rootNode({
5
+ export const upper = arkModule({
6
+ root: rootNode({
7
7
  in: "string",
8
8
  morphs: (s) => s.toUpperCase(),
9
9
  declaredOut: preformatted
@@ -8,7 +8,7 @@ export declare namespace url {
8
8
  type module = Module<submodule>;
9
9
  type submodule = Submodule<$>;
10
10
  type $ = {
11
- $root: string.url;
11
+ root: string.url;
12
12
  parse: (In: string.url) => To<URL>;
13
13
  };
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import { rootNode } from "@ark/schema";
2
- import { submodule } from "../utils.js";
2
+ import { arkModule } from "../utils.js";
3
3
  const isParsableUrl = (s) => {
4
4
  if (URL.canParse)
5
5
  return URL.canParse(s);
@@ -12,17 +12,17 @@ const isParsableUrl = (s) => {
12
12
  return false;
13
13
  }
14
14
  };
15
- const $root = rootNode({
15
+ const root = rootNode({
16
16
  domain: "string",
17
17
  predicate: {
18
18
  meta: "a URL string",
19
19
  predicate: isParsableUrl
20
20
  }
21
21
  });
22
- export const url = submodule({
23
- $root,
22
+ export const url = arkModule({
23
+ root,
24
24
  parse: rootNode({
25
- declaredIn: $root,
25
+ declaredIn: root,
26
26
  in: "string",
27
27
  morphs: (s, ctx) => {
28
28
  try {
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
2
  import type { Branded, constrain } from "../ast.ts";
3
3
  export declare const uuid: Module<{
4
- $root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
4
+ root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
5
5
  v4: unknown;
6
6
  v6: unknown;
7
7
  v1: unknown;
@@ -28,7 +28,7 @@ export declare namespace uuid {
28
28
  type module = Module<submodule>;
29
29
  type submodule = Submodule<$>;
30
30
  type $ = {
31
- $root: string.uuid;
31
+ root: string.uuid;
32
32
  v1: string.uuid.v1;
33
33
  v2: string.uuid.v2;
34
34
  v3: string.uuid.v3;
@@ -1,10 +1,10 @@
1
- import { submodule } from "../utils.js";
1
+ import { arkModule } from "../utils.js";
2
2
  import { regexStringNode } from "./utils.js";
3
3
  // Based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isUUID.js
4
- export const uuid = submodule({
4
+ export const uuid = arkModule({
5
5
  // the meta tuple expression ensures the error message does not delegate
6
6
  // to the individual branches, which are too detailed
7
- $root: ["versioned | nil | max", "@", "a UUID"],
7
+ root: ["versioned | nil | max", "@", "a UUID"],
8
8
  "#nil": "'00000000-0000-0000-0000-000000000000'",
9
9
  "#max": "'ffffffff-ffff-ffff-ffff-ffffffffffff'",
10
10
  "#versioned": /[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,
@@ -19,6 +19,17 @@ export declare namespace arkTsKeywords {
19
19
  undefined: undefined;
20
20
  };
21
21
  }
22
+ export declare const unknown: Module<{
23
+ root: unknown;
24
+ any: unknown;
25
+ }>;
26
+ export declare namespace unknown {
27
+ type submodule = Submodule<$>;
28
+ type $ = {
29
+ root: unknown;
30
+ any: any;
31
+ };
32
+ }
22
33
  declare class RecordHkt extends Hkt<[Key, unknown]> {
23
34
  body: Record<this[0], this[1]>;
24
35
  }
@@ -1,7 +1,7 @@
1
1
  import { genericNode, intrinsic } from "@ark/schema";
2
2
  import { Hkt } from "@ark/util";
3
- import { submodule } from "./utils.js";
4
- export const arkTsKeywords = submodule({
3
+ import { arkModule } from "./utils.js";
4
+ export const arkTsKeywords = arkModule({
5
5
  bigint: intrinsic.bigint,
6
6
  boolean: intrinsic.boolean,
7
7
  false: intrinsic.false,
@@ -15,6 +15,10 @@ export const arkTsKeywords = submodule({
15
15
  unknown: intrinsic.unknown,
16
16
  undefined: intrinsic.undefined
17
17
  });
18
+ export const unknown = arkModule({
19
+ root: intrinsic.unknown,
20
+ any: intrinsic.unknown
21
+ });
18
22
  class RecordHkt extends Hkt {
19
23
  }
20
24
  const Record = genericNode(["K", intrinsic.key], "V")(args => ({
@@ -42,7 +46,7 @@ const Exclude = genericNode("T", "U")(args => args.T.exclude(args.U), ExcludeHkt
42
46
  class ExtractHkt extends Hkt {
43
47
  }
44
48
  const Extract = genericNode("T", "U")(args => args.T.extract(args.U), ExtractHkt);
45
- export const arkTsGenerics = submodule({
49
+ export const arkTsGenerics = arkModule({
46
50
  Record,
47
51
  Pick,
48
52
  Omit,
@@ -1 +1 @@
1
- export declare const submodule: import("../scope.ts").ModuleParser;
1
+ export declare const arkModule: import("../scope.ts").ModuleParser;
@@ -1,2 +1,2 @@
1
1
  import { module } from "../scope.js";
2
- export const submodule = module;
2
+ export const arkModule = module;
@@ -1,13 +1,13 @@
1
1
  import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
2
- import type { applyConstraint } from "../keywords/ast.ts";
2
+ import type { applyConstraintSchema } from "../keywords/ast.ts";
3
3
  import type { ObjectType } from "./object.ts";
4
4
  interface Type<
5
5
  /** @ts-ignore cast variance */
6
6
  out t extends readonly unknown[] = readonly unknown[], $ = {}> extends ObjectType<t, $> {
7
- atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "minLength", schema>, $>;
8
- atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "maxLength", schema>, $>;
9
- moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
- lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
- exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraint<t, "exactLength", schema>, $>;
7
+ atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", schema>, $>;
8
+ atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", schema>, $>;
9
+ moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
+ exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraintSchema<t, "exactLength", schema>, $>;
12
12
  }
13
13
  export type { Type as ArrayType };
@@ -0,0 +1,87 @@
1
+ import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
2
+ import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
3
+ import type { inferIntersection } from "../intersect.ts";
4
+ import type { type } from "../keywords/ark.ts";
5
+ import type { applyConstraint, Default, distill, inferMorphOut, inferPipes, Optional } from "../keywords/ast.ts";
6
+ import type { Scope } from "../scope.ts";
7
+ import type { ArrayType } from "./array.ts";
8
+ import type { instantiateType } from "./instantiate.ts";
9
+ /** @ts-ignore cast variance */
10
+ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkErrors> {
11
+ t: t;
12
+ inferBrandableIn: distill.brandable.In<t>;
13
+ inferBrandableOut: distill.brandable.Out<t>;
14
+ inferIntrospectableOut: distill.introspectable.Out<t>;
15
+ infer: distill.Out<t>;
16
+ inferIn: distill.In<t>;
17
+ [inferred]: t;
18
+ json: Json;
19
+ toJsonSchema(): JsonSchema;
20
+ description: string;
21
+ expression: string;
22
+ internal: BaseRoot;
23
+ $: Scope<$>;
24
+ assert(data: unknown): this["infer"];
25
+ allows(data: unknown): data is this["inferIn"];
26
+ traverse(data: unknown): distill.Out<t> | ArkErrors;
27
+ configure(meta: MetaSchema): this;
28
+ describe(description: string): this;
29
+ optional<r = applyConstraint<t, Optional>>(): instantiateType<r, $>;
30
+ default<value extends this["infer"], r = (In?: this["inferBrandableIn"]) => Default<value>>(value: value): instantiateType<r, $>;
31
+ onUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
32
+ onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
33
+ from(literal: this["inferIn"]): this["infer"];
34
+ as<t = unset>(...args: validateChainedAsArgs<t>): instantiateType<t, $>;
35
+ get in(): instantiateType<this["inferBrandableIn"], $>;
36
+ get out(): instantiateType<this["inferIntrospectableOut"], $>;
37
+ intersect<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<inferIntersection<t, r>, $> | Disjoint;
38
+ and<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<inferIntersection<t, r>, $>;
39
+ or<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<t | r, $>;
40
+ array(): ArrayType<t[], $>;
41
+ pipe: ChainedPipes<t, $>;
42
+ equals<def>(def: type.validate<def, $>): this is instantiateType<type.infer<def, $>, $>;
43
+ extract<def>(r: type.validate<def, $>): instantiateType<Extract<t, type.infer<def, $>>, $>;
44
+ exclude<def>(r: type.validate<def, $>): instantiateType<Exclude<t, type.infer<def, $>>, $>;
45
+ extends<def>(other: type.validate<def, $>): this is instantiateType<type.infer<def, $>, $>;
46
+ overlaps<def>(r: type.validate<def, $>): boolean;
47
+ distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
48
+ /** @deprecated */
49
+ apply: Function["apply"];
50
+ /** @deprecated */
51
+ bind: Function["bind"];
52
+ /** @deprecated */
53
+ call: Function["call"];
54
+ /** @deprecated */
55
+ caller: Function;
56
+ /** @deprecated */
57
+ length: number;
58
+ /** @deprecated */
59
+ name: string;
60
+ /** @deprecated */
61
+ prototype: Function["prototype"];
62
+ /** @deprecated */
63
+ arguments: Function["arguments"];
64
+ /** @deprecated */
65
+ Symbol: never;
66
+ }
67
+ interface ChainedPipeSignature<t, $> {
68
+ <a extends Morph<distill.Out<t>>, r = instantiateType<inferPipes<t, [a]>, $>>(a: a): r;
69
+ <a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, r = instantiateType<inferPipes<t, [a, b]>, $>>(a: a, b: b): r;
70
+ <a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, r = instantiateType<inferPipes<t, [a, b, c]>, $>>(a: a, b: b, c: c): r;
71
+ <a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, r = instantiateType<inferPipes<t, [a, b, c, d]>, $>>(a: a, b: b, c: c, d: d): r;
72
+ <a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, r = instantiateType<inferPipes<t, [a, b, c, d, e]>, $>>(a: a, b: b, c: c, d: d, e: e): r;
73
+ <a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f): r;
74
+ <a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f, g]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): r;
75
+ }
76
+ export interface ChainedPipes<t, $> extends ChainedPipeSignature<t, $> {
77
+ try: ChainedPipeSignature<t, $>;
78
+ }
79
+ type validateChainedAsArgs<t> = [
80
+ t
81
+ ] extends [unset] ? [
82
+ t
83
+ ] extends [anyOrNever] ? [
84
+ ] : [
85
+ ErrorMessage<"as requires an explicit type parameter like myType.as<t>()">
86
+ ] : [];
87
+ export type { Type as BaseType };
@@ -1,11 +1,11 @@
1
1
  import type { ExclusiveDateRangeSchema, exclusivizeRangeSchema, InclusiveDateRangeSchema } from "@ark/schema";
2
- import type { applyConstraint } from "../keywords/ast.ts";
2
+ import type { applyConstraintSchema } from "../keywords/ast.ts";
3
3
  import type { ObjectType } from "./object.ts";
4
4
  /** @ts-ignore cast variance */
5
5
  interface Type<out t extends globalThis.Date = globalThis.Date, $ = {}> extends ObjectType<t, $> {
6
- atOrAfter<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<applyConstraint<t, "after", schema>, $>;
7
- atOrBefore<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<applyConstraint<t, "before", schema>, $>;
8
- laterThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<applyConstraint<t, "after", exclusivizeRangeSchema<schema>>, $>;
9
- earlierThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<applyConstraint<t, "before", exclusivizeRangeSchema<schema>>, $>;
6
+ atOrAfter<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "after", schema>, $>;
7
+ atOrBefore<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "before", schema>, $>;
8
+ laterThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "after", exclusivizeRangeSchema<schema>>, $>;
9
+ earlierThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "before", exclusivizeRangeSchema<schema>>, $>;
10
10
  }
11
11
  export type { Type as DateType };
@@ -0,0 +1,13 @@
1
+ import type { Predicate, PredicateCast } from "@ark/schema";
2
+ import type { inferPipe } from "../intersect.ts";
3
+ import type { type } from "../keywords/ark.ts";
4
+ import type { applyConstraintSchema, Out, To } from "../keywords/ast.ts";
5
+ import type { BaseType } from "./base.ts";
6
+ /** @ts-ignore cast variance */
7
+ interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {
8
+ to<const def, r = type.infer<def, $>>(def: type.validate<def, $>): Type<inferPipe<t, r>, $>;
9
+ narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): Type<([
10
+ narrowed
11
+ ] extends [never] ? applyConstraintSchema<this["inferBrandableOut"], "predicate", Predicate> : narrowed) extends infer o ? this["inferIntrospectableOut"] extends this["inferBrandableOut"] ? (In: this["inferBrandableIn"]) => To<o> : (In: this["inferBrandableIn"]) => Out<o> : never, $>;
12
+ }
13
+ export type { Type as MorphType };
@@ -1,12 +1,12 @@
1
1
  import type { Divisor, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
2
- import type { applyConstraint } from "../keywords/ast.ts";
2
+ import type { applyConstraintSchema } from "../keywords/ast.ts";
3
3
  import type { ValidatorType } from "./validator.ts";
4
4
  /** @ts-ignore cast variance */
5
5
  interface Type<out t extends number = number, $ = {}> extends ValidatorType<t, $> {
6
- divisibleBy<const schema extends Divisor.Schema>(schema: schema): Type<applyConstraint<t, "divisor", schema>, $>;
7
- atLeast<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "min", schema>, $>;
8
- atMost<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "max", schema>, $>;
9
- moreThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "min", exclusivizeRangeSchema<schema>>, $>;
10
- lessThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "max", exclusivizeRangeSchema<schema>>, $>;
6
+ divisibleBy<const schema extends Divisor.Schema>(schema: schema): Type<applyConstraintSchema<t, "divisor", schema>, $>;
7
+ atLeast<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "min", schema>, $>;
8
+ atMost<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "max", schema>, $>;
9
+ moreThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "min", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "max", exclusivizeRangeSchema<schema>>, $>;
11
11
  }
12
12
  export type { Type as NumberType };
@@ -1,7 +1,6 @@
1
1
  import type { array, ErrorType, merge } from "@ark/util";
2
2
  import type { arkKeyOf, getArkKey, toArkKey } from "../keys.ts";
3
3
  import type { type } from "../keywords/ark.ts";
4
- import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
5
4
  import type { ArrayType } from "./array.ts";
6
5
  import type { instantiateType } from "./instantiate.ts";
7
6
  import type { ValidatorType } from "./validator.ts";
@@ -22,7 +21,7 @@ interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $
22
21
  omit<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
23
22
  [k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k];
24
23
  }, $>;
25
- merge<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object>, $>;
24
+ merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object>, $>;
26
25
  required(): Type<{
27
26
  [k in keyof t]-?: t[k];
28
27
  }, $>;
@@ -1,13 +1,13 @@
1
1
  import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema, Pattern } from "@ark/schema";
2
- import type { applyConstraint } from "../keywords/ast.ts";
2
+ import type { applyConstraintSchema } from "../keywords/ast.ts";
3
3
  import type { ValidatorType } from "./validator.ts";
4
4
  /** @ts-ignore cast variance */
5
5
  interface Type<out t extends string = string, $ = {}> extends ValidatorType<t, $> {
6
- matching<const schema extends Pattern.Schema>(schema: schema): Type<applyConstraint<t, "pattern", schema>, $>;
7
- atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "minLength", schema>, $>;
8
- atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "maxLength", schema>, $>;
9
- moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
- lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraint<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
- exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraint<t, "exactLength", schema>, $>;
6
+ matching<const schema extends Pattern.Schema>(schema: schema): Type<applyConstraintSchema<t, "pattern", schema>, $>;
7
+ atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", schema>, $>;
8
+ atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", schema>, $>;
9
+ moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
+ exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraintSchema<t, "exactLength", schema>, $>;
12
12
  }
13
13
  export type { Type as StringType };
@@ -1,11 +1,11 @@
1
1
  import type { Predicate, PredicateCast } from "@ark/schema";
2
- import type { applyConstraint } from "../keywords/ast.ts";
2
+ import type { applyConstraintSchema } from "../keywords/ast.ts";
3
3
  import type { BaseType } from "./base.ts";
4
4
  import type { instantiateType } from "./instantiate.ts";
5
5
  /** @ts-ignore cast variance */
6
6
  interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {
7
7
  narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): instantiateType<[
8
8
  narrowed
9
- ] extends [never] ? applyConstraint<t, "predicate", Predicate> : narrowed, $>;
9
+ ] extends [never] ? applyConstraintSchema<t, "predicate", Predicate> : narrowed, $>;
10
10
  }
11
11
  export type { Type as ValidatorType };
@@ -0,0 +1 @@
1
+ export {};
package/out/module.d.ts CHANGED
@@ -12,8 +12,8 @@ export interface BoundModule<exports extends {}, $> extends RootModule<bindExpor
12
12
  export type bindExportsToScope<exports, $> = {
13
13
  [k in keyof exports]: instantiateExport<exports[k], $>;
14
14
  } & unknown;
15
- export type Submodule<exports extends {}> = RootModule<exports & ("$root" extends keyof exports ? {
16
- [inferred]: exports["$root"];
15
+ export type Submodule<exports extends {}> = RootModule<exports & ("root" extends keyof exports ? {
16
+ [inferred]: exports["root"];
17
17
  } : {})>;
18
18
  export type instantiateExport<t, $> = [
19
19
  t
@@ -1,6 +1,6 @@
1
1
  import { type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
2
- import { type anyOrNever, type conform, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util";
3
- import type { constrain, Default } from "../keywords/ast.ts";
2
+ import { type anyOrNever, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util";
3
+ import type { constrain } from "../keywords/ast.ts";
4
4
  import type { ParseContext } from "../scope.ts";
5
5
  import type { inferDefinition, validateDefinition } from "./definition.ts";
6
6
  import type { astToString } from "./semantic/utils.ts";
@@ -13,38 +13,15 @@ export type inferObjectLiteral<def extends object, $, args> = show<"..." extends
13
13
  * Infers the contents of an object literal, ignoring a spread definition
14
14
  */
15
15
  type _inferObjectLiteral<def extends object, $, args> = {
16
- -readonly [k in keyof def as nonOptionalKeyFrom<k, $, args>]: def[k] extends (DefaultValueTuple<infer baseDef, infer defaultValue>) ? [
16
+ -readonly [k in keyof def as nonOptionalKeyFrom<k, $, args>]: [
17
17
  def[k]
18
- ] extends [anyOrNever] ? def[k] : (In?: inferDefinition<baseDef, $, args>) => Default<defaultValue> : inferDefinition<def[k], $, args>;
18
+ ] extends [anyOrNever] ? def[k] : inferDefinition<def[k], $, args>;
19
19
  } & {
20
20
  -readonly [k in keyof def as optionalKeyFrom<k>]?: inferDefinition<def[k], $, args>;
21
21
  };
22
22
  export type validateObjectLiteral<def, $, args> = {
23
- [k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? ErrorType<message> : inferDefinition<indexDef, $, args> extends Key | constrain<Key, {}> ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidPropertyKeyMessage<indexDef>> : k extends "..." ? inferDefinition<def[k], $, args> extends object ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidSpreadTypeMessage<astToString<def[k]>>> : k extends "+" ? UndeclaredKeyBehavior : validateDefaultableValue<def, k, $, args>;
23
+ [k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? ErrorType<message> : inferDefinition<indexDef, $, args> extends Key | constrain<Key, {}> ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidPropertyKeyMessage<indexDef>> : k extends "..." ? inferDefinition<def[k], $, args> extends object ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidSpreadTypeMessage<astToString<def[k]>>> : k extends "+" ? UndeclaredKeyBehavior : validateDefinition<def[k], $, args>;
24
24
  };
25
- type validateDefaultableValue<def, k extends keyof def, $, args> = def[k] extends DefaultValueTuple ? [
26
- def[k]
27
- ] extends [anyOrNever] ?
28
- /** this extra [anyOrNever] check is required to ensure that nested `type` invocations
29
- * like the following are not prematurely validated by the outer call:
30
- *
31
- * ```ts
32
- * type({
33
- * "test?": type("string").pipe(x => x === "true")
34
- * })
35
- * ```
36
- */
37
- def[k] : validateDefaultValueTuple<def[k], k, $, args> : validateDefinition<def[k], $, args>;
38
- type DefaultValueTuple<baseDef = unknown, defaultValue = unknown> = readonly [
39
- baseDef,
40
- "=",
41
- defaultValue
42
- ];
43
- type validateDefaultValueTuple<def extends DefaultValueTuple, k extends PropertyKey, $, args> = parseKey<k>["kind"] extends "required" ? conform<def, readonly [
44
- validateDefinition<def[0], $, args>,
45
- "=",
46
- inferDefinition<def[0], $, args>
47
- ]> : ErrorMessage<invalidDefaultKeyKindMessage>;
48
25
  type nonOptionalKeyFrom<k, $, args> = parseKey<k> extends PreparsedKey<"required", infer inner> ? inner : parseKey<k> extends PreparsedKey<"index", infer inner> ? inferDefinition<inner, $, args> extends infer t extends Key ? t : never : never;
49
26
  type optionalKeyFrom<k> = parseKey<k> extends PreparsedKey<"optional", infer inner> ? inner : never;
50
27
  type PreparsedKey<kind extends ParsedKeyKind = ParsedKeyKind, key extends Key = Key> = {
@@ -67,8 +44,6 @@ export type ParsedSpreadEntry = {
67
44
  node: BaseRoot;
68
45
  };
69
46
  export declare const parseEntry: (key: Key, value: unknown, ctx: ParseContext) => listable<ParsedEntry>;
70
- export declare const invalidDefaultKeyKindMessage = "Only required keys may specify default values, e.g. { value: 'number = 0' }";
71
- export type invalidDefaultKeyKindMessage = typeof invalidDefaultKeyKindMessage;
72
47
  declare const parseKey: (key: Key) => PreparsedKey;
73
48
  type parseKey<k> = k extends `${infer inner}?` ? inner extends `${infer baseName}${EscapeToken}` ? PreparsedKey.from<{
74
49
  kind: "required";
@@ -1,6 +1,5 @@
1
- import { ArkErrors, normalizeIndex } from "@ark/schema";
2
- import { append, escapeToken, isArray, printable, stringAndSymbolicEntriesOf, throwParseError } from "@ark/util";
3
- import { writeUnassignableDefaultValueMessage } from "./semantic/default.js";
1
+ import { normalizeIndex } from "@ark/schema";
2
+ import { append, escapeToken, printable, stringAndSymbolicEntriesOf, throwParseError } from "@ark/util";
4
3
  export const parseObjectLiteral = (def, ctx) => {
5
4
  let spread;
6
5
  const structure = {};
@@ -45,22 +44,7 @@ export const parseEntry = (key, value, ctx) => {
45
44
  }
46
45
  if (parsedKey.kind === "...")
47
46
  return { kind: "spread", node: ctx.$.parse(value, ctx) };
48
- const parsedValue = isArray(value) && value[1] === "=" ?
49
- [ctx.$.parse(value[0], ctx), "=", value[2]]
50
- : ctx.$.parse(value, ctx, true);
51
- if (isArray(parsedValue)) {
52
- if (parsedKey.kind !== "required")
53
- throwParseError(invalidDefaultKeyKindMessage);
54
- const out = parsedValue[0].traverse(parsedValue[2]);
55
- if (out instanceof ArkErrors) {
56
- throwParseError(writeUnassignableDefaultValueMessage(printable(parsedKey.key), out.message));
57
- }
58
- return ctx.$.node("optional", {
59
- key: parsedKey.key,
60
- value: parsedValue[0],
61
- default: parsedValue[2]
62
- });
63
- }
47
+ const parsedValue = ctx.$.parse(value, ctx);
64
48
  if (parsedKey.kind === "index") {
65
49
  const signature = ctx.$.parse(parsedKey.key, ctx);
66
50
  const normalized = normalizeIndex(signature, parsedValue, ctx.$);
@@ -70,13 +54,26 @@ export const parseEntry = (key, value, ctx) => {
70
54
  : normalized.index
71
55
  : (normalized.required ?? []));
72
56
  }
57
+ if (parsedValue.meta) {
58
+ if ("default" in parsedValue.meta) {
59
+ return ctx.$.node("optional", {
60
+ key: parsedKey.key,
61
+ value: parsedValue,
62
+ default: parsedValue.meta.default
63
+ });
64
+ }
65
+ if (parsedValue.meta.optional) {
66
+ return ctx.$.node("optional", {
67
+ key: parsedKey.key,
68
+ value: parsedValue
69
+ });
70
+ }
71
+ }
73
72
  return ctx.$.node(parsedKey.kind, {
74
73
  key: parsedKey.key,
75
74
  value: parsedValue
76
75
  });
77
76
  };
78
- // single quote use here is better for TypeScript's inlined error to avoid escapes
79
- export const invalidDefaultKeyKindMessage = `Only required keys may specify default values, e.g. { value: 'number = 0' }`;
80
77
  const parseKey = (key) => typeof key === "symbol" ? { kind: "required", key }
81
78
  : key.at(-1) === "?" ?
82
79
  key.at(-2) === escapeToken ?
@@ -1,9 +1,8 @@
1
+ import type { writeUnassignableDefaultValueMessage } from "@ark/schema";
1
2
  import type { ErrorMessage } from "@ark/util";
2
- import type { inferAmbient } from "../../type.ts";
3
+ import type { type } from "../../keywords/ark.ts";
3
4
  import type { UnitLiteral } from "../string/shift/operator/default.ts";
4
5
  import type { inferAstOut } from "./infer.ts";
5
6
  import type { astToString } from "./utils.ts";
6
7
  import type { validateAst } from "./validate.ts";
7
- export type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : inferAmbient<unitLiteral> extends inferAstOut<baseAst, $, args> ? undefined : ErrorMessage<writeUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>>;
8
- export declare const writeUnassignableDefaultValueMessage: <key extends string, message extends string>(key: key, message: message) => string;
9
- export type writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} is not assignable to ${baseDef}`;
8
+ export type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : type.infer<unitLiteral> extends inferAstOut<baseAst, $, args> ? undefined : ErrorMessage<writeUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>>;
@@ -1 +1 @@
1
- export const writeUnassignableDefaultValueMessage = (key, message) => `Default value at ${key} ${message}`;
1
+ export {};
@@ -1,14 +1,15 @@
1
1
  import type { GenericAst } from "@ark/schema";
2
2
  import type { Hkt, array } from "@ark/util";
3
3
  import type { inferIntersection } from "../../intersect.ts";
4
- import type { Date, Default, LimitLiteral, applyConstraint, distillIn, distillOut, normalizeLimit } from "../../keywords/ast.ts";
4
+ import type { type } from "../../keywords/ark.ts";
5
+ import type { Default, LimitLiteral, applyConstraintSchema, distill, normalizeLimit } from "../../keywords/ast.ts";
6
+ import type { Date } from "../../keywords/constructors/Date.ts";
5
7
  import type { UnparsedScope } from "../../scope.ts";
6
- import type { inferAmbient } from "../../type.ts";
7
8
  import type { inferDefinition } from "../definition.ts";
8
9
  import type { Comparator, MinComparator } from "../string/reduce/shared.ts";
9
10
  export type inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;
10
- export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;
11
- export type inferAstOut<ast, $, args> = distillOut<inferAstRoot<ast, $, args>>;
11
+ export type inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>;
12
+ export type inferAstOut<ast, $, args> = distill.Out<inferAstRoot<ast, $, args>>;
12
13
  export type DefAst<def = unknown, alias extends string = string> = [
13
14
  def,
14
15
  "def",
@@ -25,8 +26,8 @@ export type inferExpression<ast, $, args> = ast extends array ? ast extends Infe
25
26
  [i in keyof argAsts]: inferExpression<argAsts[i], $, args>;
26
27
  }> : inferDefinition<g["bodyDef"], resolveScope<g["$"], $>, {
27
28
  [i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts], resolveScope<g["arg$"], $>, args>;
28
- }> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? inferAmbient<ast[2]> extends infer defaultValue ? (In?: inferExpression<ast[0], $, args>) => Default<defaultValue> : never : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? constrainBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : constrainBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraint<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferExpression<ast[1], $, args> : never : never;
29
- export type constrainBound<constrainableIn, comparator extends Comparator, limit extends LimitLiteral> = distillIn<constrainableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraint<constrainableIn, "exactLength", limit & number> : applyConstraint<constrainableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
29
+ }> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? type.infer<ast[2]> extends infer defaultValue ? (In?: inferExpression<ast[0], $, args>) => Default<defaultValue> : never : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? brandBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : brandBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraintSchema<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferExpression<ast[1], $, args> : never : never;
30
+ export type brandBound<brandableIn, comparator extends Comparator, limit extends LimitLiteral> = distill.In<brandableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraintSchema<brandableIn, "exactLength", limit & number> : applyConstraintSchema<brandableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
30
31
  rule: normalizeLimit<limit>;
31
32
  exclusive: comparator extends ">" | "<" ? true : false;
32
33
  }> : never;
@@ -34,6 +35,6 @@ export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
34
35
  export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
35
36
  export type PostfixOperator = "[]";
36
37
  export type PostfixExpression<operator extends PostfixOperator = PostfixOperator, operand = unknown> = readonly [operand, operator];
37
- export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@";
38
+ export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@" | "=";
38
39
  export type InfixExpression<operator extends InfixOperator = InfixOperator, l = unknown, r = unknown> = [l, operator, r];
39
40
  export {};