arktype 2.0.0-rc.6 → 2.0.0-rc.8

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 (49) hide show
  1. package/out/generic.d.ts +8 -9
  2. package/out/generic.js +3 -5
  3. package/out/index.d.ts +1 -1
  4. package/out/keys.d.ts +5 -3
  5. package/out/keywords/ark.d.ts +6 -1
  6. package/out/keywords/ark.js +1 -0
  7. package/out/keywords/ast.d.ts +27 -17
  8. package/out/keywords/constructors/Array.js +3 -3
  9. package/out/keywords/constructors/FormData.js +5 -5
  10. package/out/keywords/constructors/constructors.d.ts +0 -1
  11. package/out/keywords/number/epoch.js +2 -2
  12. package/out/keywords/number/integer.js +2 -2
  13. package/out/keywords/number/number.js +2 -2
  14. package/out/keywords/string/capitalize.js +2 -2
  15. package/out/keywords/string/creditCard.js +2 -2
  16. package/out/keywords/string/date.js +11 -11
  17. package/out/keywords/string/integer.js +2 -2
  18. package/out/keywords/string/ip.js +2 -2
  19. package/out/keywords/string/json.d.ts +1 -0
  20. package/out/keywords/string/json.js +21 -13
  21. package/out/keywords/string/lower.js +2 -2
  22. package/out/keywords/string/normalize.js +3 -3
  23. package/out/keywords/string/numeric.js +2 -2
  24. package/out/keywords/string/string.d.ts +1 -1
  25. package/out/keywords/string/trim.js +2 -2
  26. package/out/keywords/string/upper.js +2 -2
  27. package/out/keywords/string/url.js +4 -4
  28. package/out/methods/base.d.ts +10 -5
  29. package/out/methods/instantiate.d.ts +2 -1
  30. package/out/methods/object.d.ts +31 -6
  31. package/out/parser/definition.d.ts +4 -5
  32. package/out/parser/objectLiteral.d.ts +4 -5
  33. package/out/parser/objectLiteral.js +4 -4
  34. package/out/parser/semantic/infer.d.ts +4 -3
  35. package/out/parser/semantic/validate.d.ts +1 -1
  36. package/out/parser/string/reduce/dynamic.d.ts +3 -4
  37. package/out/parser/string/reduce/dynamic.js +3 -2
  38. package/out/parser/string/shift/operand/unenclosed.js +6 -2
  39. package/out/parser/string/shift/scanner.d.ts +3 -1
  40. package/out/parser/string/shift/scanner.js +5 -3
  41. package/out/parser/string/string.d.ts +1 -1
  42. package/out/parser/string/string.js +2 -0
  43. package/out/parser/tuple.d.ts +47 -36
  44. package/out/parser/tuple.js +24 -25
  45. package/out/scope.d.ts +22 -25
  46. package/out/scope.js +33 -29
  47. package/out/type.d.ts +10 -9
  48. package/out/type.js +9 -9
  49. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
2
2
  import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
3
+ import type { ArkAmbient } from "../config.ts";
3
4
  import type { inferIntersection } from "../intersect.ts";
4
5
  import type { type } from "../keywords/ark.ts";
5
6
  import type { applyConstraint, Default, distill, inferMorphOut, inferPipes, Optional } from "../keywords/ast.ts";
@@ -16,6 +17,8 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
16
17
  inferIn: distill.In<t>;
17
18
  [inferred]: t;
18
19
  json: Json;
20
+ meta: ArkAmbient.meta;
21
+ precompilation: string | undefined;
19
22
  toJsonSchema(): JsonSchema;
20
23
  description: string;
21
24
  expression: string;
@@ -39,11 +42,13 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
39
42
  or<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<t | r, $>;
40
43
  array(): ArrayType<t[], $>;
41
44
  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;
45
+ equals<const def>(def: type.validate<def, $>): boolean;
46
+ ifEquals<const def>(def: type.validate<def, $>): instantiateType<type.infer<def, $>, $> | undefined;
47
+ extends<const def>(other: type.validate<def, $>): this is instantiateType<type.infer<def, $>, $>;
48
+ ifExtends<const def>(other: type.validate<def, $>): instantiateType<type.infer<def, $>, $> | undefined;
49
+ overlaps<const def>(r: type.validate<def, $>): boolean;
50
+ extract<const def>(r: type.validate<def, $>): instantiateType<Extract<t, type.infer<def, $>>, $>;
51
+ exclude<const def>(r: type.validate<def, $>): instantiateType<Exclude<t, type.infer<def, $>>, $>;
47
52
  distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
48
53
  /** @deprecated */
49
54
  apply: Function["apply"];
@@ -1,6 +1,7 @@
1
1
  import type { anyOrNever, array } from "@ark/util";
2
2
  import type { MorphAst } from "../keywords/ast.ts";
3
3
  import type { ArrayType } from "./array.ts";
4
+ import type { BaseType } from "./base.ts";
4
5
  import type { DateType } from "./date.ts";
5
6
  import type { MorphType } from "./morph.ts";
6
7
  import type { NumberType } from "./number.ts";
@@ -11,6 +12,6 @@ export type instantiateType<t, $> = [
11
12
  Extract<t, MorphAst>
12
13
  ] extends [anyOrNever] ? [
13
14
  t
14
- ] extends [string] ? StringType<t, $> : [t] extends [number] ? NumberType<t, $> : [t] extends [object] ? [
15
+ ] extends [anyOrNever] ? BaseType<t, $> : [t] extends [string] ? StringType<t, $> : [t] extends [number] ? NumberType<t, $> : [t] extends [object] ? [
15
16
  t
16
17
  ] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t, $> : ValidatorType<t, $> : MorphType<t, $>;
@@ -1,5 +1,5 @@
1
- import type { array, ErrorType, merge } from "@ark/util";
2
- import type { arkKeyOf, getArkKey, toArkKey } from "../keys.ts";
1
+ import type { array, ErrorType, inferred, intersectUnion, Key, listable, merge, optionalKeyOf, show } from "@ark/util";
2
+ import type { arkGet, arkKeyOf, toArkKey } from "../keys.ts";
3
3
  import type { type } from "../keywords/ark.ts";
4
4
  import type { ArrayType } from "./array.ts";
5
5
  import type { instantiateType } from "./instantiate.ts";
@@ -11,10 +11,10 @@ interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $
11
11
  }, $> : Type<{
12
12
  readonly [k in keyof t]: t[k];
13
13
  }, $>;
14
- keyof(): instantiateType<keyof t, $>;
15
- get<k1 extends arkKeyOf<t>, r = instantiateType<getArkKey<t, k1>, $>>(k1: k1 | type.cast<k1>): r;
16
- get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, r = instantiateType<getArkKey<getArkKey<t, k1>, k2>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): r;
17
- get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, k3 extends arkKeyOf<getArkKey<getArkKey<t, k1>, k2>>, r = instantiateType<getArkKey<getArkKey<getArkKey<t, k1>, k2>, k3>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): r;
14
+ keyof(): instantiateType<arkKeyOf<t>, $>;
15
+ get<k1 extends arkKeyOf<t>, r = instantiateType<arkGet<t, k1>, $>>(k1: k1 | type.cast<k1>): r;
16
+ get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<arkGet<t, k1>>, r = instantiateType<arkGet<arkGet<t, k1>, k2>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): r;
17
+ get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<arkGet<t, k1>>, k3 extends arkKeyOf<arkGet<arkGet<t, k1>, k2>>, r = instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): r;
18
18
  pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
19
19
  [k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];
20
20
  }, $>;
@@ -28,5 +28,30 @@ interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $
28
28
  partial(): Type<{
29
29
  [k in keyof t]?: t[k];
30
30
  }, $>;
31
+ map<transformed extends listable<MappedTypeEntry<Key, v>>, v = unknown>(flatMapEntry: (entry: typeEntryOf<t, $>) => transformed): Type<constructMapped<t, transformed>, $>;
31
32
  }
33
+ export type MappedTypeEntry<k extends Key = Key, v = unknown> = readonly [
34
+ key: k,
35
+ value: type.cast<v>,
36
+ kind?: "required" | "optional"
37
+ ];
38
+ type TypeEntries = array<MappedTypeEntry>;
39
+ type typeEntryOf<t, $> = {
40
+ [k in keyof t]-?: readonly [
41
+ k,
42
+ instantiateType<t[k] & ({} | null), $>,
43
+ k extends optionalKeyOf<t> ? "optional" : "required"
44
+ ];
45
+ }[keyof t] & unknown;
46
+ type constructMapped<t, transformed extends listable<MappedTypeEntry>> = show<intersectUnion<fromTypeEntries<t, transformed extends TypeEntries ? transformed : [transformed]>>>;
47
+ type fromTypeEntries<t, entries extends TypeEntries> = show<{
48
+ [entry in entries[number] as Extract<applyHomomorphicOptionality<t, entry>, readonly [unknown, unknown, "required"]>[0]]: entry[1][inferred];
49
+ } & {
50
+ [entry in entries[number] as Extract<applyHomomorphicOptionality<t, entry>, readonly [unknown, unknown, "optional"]>[0]]?: entry[1][inferred];
51
+ }>;
52
+ type applyHomomorphicOptionality<t, entry extends MappedTypeEntry> = readonly [
53
+ entry[0],
54
+ entry[1],
55
+ entry[2] extends string ? entry[2] : entry[0] extends optionalKeyOf<t> ? "optional" : "required"
56
+ ];
32
57
  export type { Type as ObjectType };
@@ -1,17 +1,16 @@
1
- import { type BaseRoot } from "@ark/schema";
1
+ import { type BaseParseContext, type BaseRoot } from "@ark/schema";
2
2
  import { type ErrorMessage, type Fn, type Primitive, type anyOrNever, type array, type defined, type equals, type ifEmptyObjectLiteral, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@ark/util";
3
3
  import type { type } from "../keywords/ark.ts";
4
4
  import type { string } from "../keywords/string/string.ts";
5
- import type { ParseContext } from "../scope.ts";
6
5
  import { type inferObjectLiteral, type validateObjectLiteral } from "./objectLiteral.ts";
7
6
  import type { validateString } from "./semantic/validate.ts";
8
7
  import type { BaseCompletions, inferString } from "./string/string.ts";
9
8
  import { type TupleExpression, type inferTuple, type validateTuple } from "./tuple.ts";
10
- export declare const parseObject: (def: object, ctx: ParseContext) => BaseRoot;
9
+ export declare const parseObject: (def: object, ctx: BaseParseContext) => BaseRoot;
11
10
  export type inferDefinition<def, $, args> = [
12
11
  def
13
12
  ] extends [anyOrNever] ? def : def extends type.cast<infer t> ? ifEmptyObjectLiteral<def, object, t> : def extends ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string.matching<string> : def extends object ? inferObjectLiteral<def, $, args> : never;
14
- export type validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [Terminal] ? def : def extends string ? validateString<def, $, args> : def extends array ? validateTuple<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : unknown extends def ? BaseCompletions<$, args> | {} : validateObjectLiteral<def, $, args>;
13
+ export type validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [Terminal] ? def : def extends string ? validateString<def, $, args> : def extends array ? validateTuple<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : unknown extends def ? BaseCompletions<$, args> | {} : RegExp extends def ? def : validateObjectLiteral<def, $, args>;
15
14
  export type validateDeclared<declared, def, $, args> = def extends validateDefinition<def, $, args> ? validateInference<def, declared, $, args> : validateDefinition<def, $, args>;
16
15
  type validateInference<def, declared, $, args> = def extends RegExp | type.cast<unknown> | ThunkCast | TupleExpression ? validateShallowInference<def, declared, $, args> : def extends array ? declared extends array ? {
17
16
  [i in keyof declared]: i extends keyof def ? validateInference<def[i], declared[i], $, args> : declared[i];
@@ -25,7 +24,7 @@ type declarationMismatch<def, declared, $, args> = {
25
24
  declared: declared;
26
25
  inferred: inferDefinition<def, $, args>;
27
26
  };
28
- type Terminal = RegExp | type.cast<unknown> | Fn;
27
+ type Terminal = type.cast<unknown> | Fn;
29
28
  export type ThunkCast<t = unknown> = () => type.cast<t>;
30
29
  type BadDefinitionType = Exclude<Primitive, string>;
31
30
  export declare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => writeBadDefinitionTypeMessage<actual>;
@@ -1,11 +1,10 @@
1
- import { type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
1
+ import { type BaseParseContext, type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
2
2
  import { type anyOrNever, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util";
3
3
  import type { constrain } from "../keywords/ast.ts";
4
- import type { ParseContext } from "../scope.ts";
5
4
  import type { inferDefinition, validateDefinition } from "./definition.ts";
6
5
  import type { astToString } from "./semantic/utils.ts";
7
6
  import type { validateString } from "./semantic/validate.ts";
8
- export declare const parseObjectLiteral: (def: Dict, ctx: ParseContext) => BaseRoot;
7
+ export declare const parseObjectLiteral: (def: Dict, ctx: BaseParseContext) => BaseRoot;
9
8
  export declare const writeInvalidUndeclaredBehaviorMessage: (actual: unknown) => string;
10
9
  export declare const nonLeadingSpreadError = "Spread operator may only be used as the first key in an object";
11
10
  export type inferObjectLiteral<def extends object, $, args> = show<"..." extends keyof def ? merge<inferDefinition<def["..."], $, args>, _inferObjectLiteral<def, $, args>> : _inferObjectLiteral<def, $, args>>;
@@ -24,7 +23,7 @@ export type validateObjectLiteral<def, $, args> = {
24
23
  };
25
24
  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;
26
25
  type optionalKeyFrom<k> = parseKey<k> extends PreparsedKey<"optional", infer inner> ? inner : never;
27
- type PreparsedKey<kind extends ParsedKeyKind = ParsedKeyKind, key extends Key = Key> = {
26
+ export type PreparsedKey<kind extends ParsedKeyKind = ParsedKeyKind, key extends Key = Key> = {
28
27
  kind: kind;
29
28
  key: key;
30
29
  };
@@ -43,7 +42,7 @@ export type ParsedSpreadEntry = {
43
42
  kind: "spread";
44
43
  node: BaseRoot;
45
44
  };
46
- export declare const parseEntry: (key: Key, value: unknown, ctx: ParseContext) => listable<ParsedEntry>;
45
+ export declare const parseEntry: (key: Key, value: unknown, ctx: BaseParseContext) => listable<ParsedEntry>;
47
46
  declare const parseKey: (key: Key) => PreparsedKey;
48
47
  type parseKey<k> = k extends `${infer inner}?` ? inner extends `${infer baseName}${EscapeToken}` ? PreparsedKey.from<{
49
48
  kind: "required";
@@ -28,7 +28,7 @@ export const parseObjectLiteral = (def, ctx) => {
28
28
  structure[entry.kind] = append(structure[entry.kind], entry);
29
29
  }
30
30
  const structureNode = ctx.$.node("structure", structure);
31
- return ctx.$.rootNode({
31
+ return ctx.$.parseSchema({
32
32
  domain: "object",
33
33
  structure: spread?.merge(structureNode) ?? structureNode
34
34
  });
@@ -43,10 +43,10 @@ export const parseEntry = (key, value, ctx) => {
43
43
  return { kind: "undeclared", behavior: value };
44
44
  }
45
45
  if (parsedKey.kind === "...")
46
- return { kind: "spread", node: ctx.$.parse(value, ctx) };
47
- const parsedValue = ctx.$.parse(value, ctx);
46
+ return { kind: "spread", node: ctx.$.parseOwnDefinitionFormat(value, ctx) };
47
+ const parsedValue = ctx.$.parseOwnDefinitionFormat(value, ctx);
48
48
  if (parsedKey.kind === "index") {
49
- const signature = ctx.$.parse(parsedKey.key, ctx);
49
+ const signature = ctx.$.parseOwnDefinitionFormat(parsedKey.key, ctx);
50
50
  const normalized = normalizeIndex(signature, parsedValue, ctx.$);
51
51
  return (normalized.index ?
52
52
  normalized.required ?
@@ -1,8 +1,9 @@
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 { arkKeyOf } from "../../keys.ts";
4
5
  import type { type } from "../../keywords/ark.ts";
5
- import type { Default, LimitLiteral, applyConstraintSchema, distill, normalizeLimit } from "../../keywords/ast.ts";
6
+ import type { Default, LimitLiteral, Optional, applyConstraint, applyConstraintSchema, distill, normalizeLimit } from "../../keywords/ast.ts";
6
7
  import type { Date } from "../../keywords/constructors/Date.ts";
7
8
  import type { UnparsedScope } from "../../scope.ts";
8
9
  import type { inferDefinition } from "../definition.ts";
@@ -26,14 +27,14 @@ export type inferExpression<ast, $, args> = ast extends array ? ast extends Infe
26
27
  [i in keyof argAsts]: inferExpression<argAsts[i], $, args>;
27
28
  }> : inferDefinition<g["bodyDef"], resolveScope<g["$"], $>, {
28
29
  [i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts], resolveScope<g["arg$"], $>, args>;
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
+ }> : 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[1] extends "?" ? applyConstraint<inferExpression<ast[0], $, args>, Optional> : ast[0] extends "keyof" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;
30
31
  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", {
31
32
  rule: normalizeLimit<limit>;
32
33
  exclusive: comparator extends ">" | "<" ? true : false;
33
34
  }> : never;
34
35
  export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
35
36
  export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
36
- export type PostfixOperator = "[]";
37
+ export type PostfixOperator = "[]" | "?";
37
38
  export type PostfixExpression<operator extends PostfixOperator = PostfixOperator, operand = unknown> = readonly [operand, operator];
38
39
  export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@" | "=";
39
40
  export type InfixExpression<operator extends InfixOperator = InfixOperator, l = unknown, r = unknown> = [l, operator, r];
@@ -11,7 +11,7 @@ import type { validateDivisor } from "./divisor.ts";
11
11
  import type { DefAst, GenericInstantiationAst, inferAstRoot, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts";
12
12
  import type { validateKeyof } from "./keyof.ts";
13
13
  import type { astToString } from "./utils.ts";
14
- export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends DefAst ? ast[2] extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<ast[2]>> : undefined : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : operator extends "=" ? validateDefault<l, r & UnitLiteral, $, args> : never : ast extends ["keyof", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericArgs<g["paramsAst"], argAsts, $, args, []> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
14
+ export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends DefAst ? ast[2] extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<ast[2]>> : undefined : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : operator extends "?" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : operator extends "=" ? validateDefault<l, r & UnitLiteral, $, args> : never : ast extends ["keyof", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericArgs<g["paramsAst"], argAsts, $, args, []> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
15
15
  ast: ast;
16
16
  };
17
17
  type writeUnexpectedExpressionMessage<expression extends string> = `Unexpectedly failed to parse the expression resulting from ${expression}`;
@@ -1,7 +1,6 @@
1
- import type { BaseRoot } from "@ark/schema";
1
+ import type { BaseParseContext, BaseRoot } from "@ark/schema";
2
2
  import { type requireKeys } from "@ark/util";
3
3
  import type { LimitLiteral } from "../../../keywords/ast.ts";
4
- import type { ParseContext } from "../../../scope.ts";
5
4
  import type { InfixOperator } from "../../semantic/infer.ts";
6
5
  import type { Scanner } from "../shift/scanner.ts";
7
6
  import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.ts";
@@ -18,8 +17,8 @@ export declare class DynamicState {
18
17
  finalizer: Scanner.FinalizingLookahead | undefined;
19
18
  groups: BranchState[];
20
19
  scanner: Scanner;
21
- ctx: ParseContext;
22
- constructor(scanner: Scanner, ctx: ParseContext);
20
+ ctx: BaseParseContext;
21
+ constructor(scanner: Scanner, ctx: BaseParseContext);
23
22
  error(message: string): never;
24
23
  hasRoot(): this is DynamicStateWithRoot;
25
24
  setRoot(root: BaseRoot): void;
@@ -91,10 +91,11 @@ export class DynamicState {
91
91
  this.assertRangeUnset();
92
92
  this.applyPrefixes();
93
93
  const root = this.root;
94
- this.branches.intersection = this.branches.intersection?.and(root) ?? root;
94
+ this.branches.intersection =
95
+ this.branches.intersection?.rawAnd(root) ?? root;
95
96
  if (token === "|") {
96
97
  this.branches.union =
97
- this.branches.union?.or(this.branches.intersection) ??
98
+ this.branches.union?.rawOr(this.branches.intersection) ??
98
99
  this.branches.intersection;
99
100
  this.branches.intersection = null;
100
101
  }
@@ -24,8 +24,12 @@ const unenclosedToNode = (s, token) => maybeParseReference(s, token) ??
24
24
  writePrefixedPrivateReferenceMessage(token)
25
25
  : writeUnresolvableMessage(token));
26
26
  const maybeParseReference = (s, token) => {
27
- if (s.ctx.args?.[token])
28
- return s.ctx.args[token].internal;
27
+ if (s.ctx.args?.[token]) {
28
+ const arg = s.ctx.args[token];
29
+ if (typeof arg !== "string")
30
+ return arg;
31
+ return s.ctx.$.node("alias", { reference: arg }, { prereduced: true });
32
+ }
29
33
  const resolution = s.ctx.$.maybeResolve(token);
30
34
  if (hasArkKind(resolution, "root"))
31
35
  return resolution;
@@ -34,19 +34,21 @@ export declare class Scanner<lookahead extends string = string> {
34
34
  readonly "%": true;
35
35
  readonly ",": true;
36
36
  readonly ":": true;
37
+ readonly "?": true;
37
38
  };
38
39
  static finalizingLookaheads: {
39
40
  readonly ">": true;
40
41
  readonly ",": true;
41
42
  readonly "": true;
42
43
  readonly "=": true;
44
+ readonly "?": true;
43
45
  };
44
46
  static lookaheadIsTerminator: Scanner.UntilCondition;
45
47
  static lookaheadIsNotWhitespace: Scanner.UntilCondition;
46
48
  static lookaheadIsFinalizing: (lookahead: string, unscanned: string) => lookahead is ">" | "," | "=";
47
49
  }
48
50
  export declare namespace Scanner {
49
- type lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends ">" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends ("" | `${TerminatingChar}${string}`) ? true : false : lookahead extends "=" ? unscanned extends `=${string}` ? false : true : lookahead extends "," ? true : false;
51
+ type lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends ">" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends ("" | `${TerminatingChar}${string}`) ? true : false : lookahead extends "=" ? unscanned extends `=${string}` ? false : true : lookahead extends "," | "?" ? true : false;
50
52
  type UntilCondition = (scanner: Scanner, shifted: string) => boolean;
51
53
  type OnInputEndFn = (scanner: Scanner, shifted: string) => string;
52
54
  type ShiftUntilOptions = {
@@ -74,13 +74,15 @@ export class Scanner {
74
74
  "%": true,
75
75
  ",": true,
76
76
  ":": true,
77
+ "?": true,
77
78
  ...whiteSpaceTokens
78
79
  };
79
80
  static finalizingLookaheads = {
80
81
  ">": true,
81
82
  ",": true,
82
83
  "": true,
83
- "=": true
84
+ "=": true,
85
+ "?": true
84
86
  };
85
87
  static lookaheadIsTerminator = (scanner) => scanner.lookahead in this.terminatingChars;
86
88
  static lookaheadIsNotWhitespace = (scanner) => !(scanner.lookahead in whiteSpaceTokens);
@@ -95,6 +97,6 @@ export class Scanner {
95
97
  // "=" is a finalizer on its own (representing a default value),
96
98
  // but not with a second "=" (an equality comparator)
97
99
  : lookahead === "=" ? unscanned[0] !== "="
98
- // ","" is unambiguously a finalizer
99
- : lookahead === ",";
100
+ // "," and "?" are unambiguously finalizers
101
+ : lookahead === "," || lookahead === "?";
100
102
  }
@@ -25,5 +25,5 @@ export declare const parseUntilFinalizer: (s: DynamicState) => DynamicStateWithR
25
25
  export type parseUntilFinalizer<s extends StaticState, $, args> = s["finalizer"] extends undefined ? parseUntilFinalizer<next<s, $, args>, $, args> : s;
26
26
  declare const next: (s: DynamicState) => void;
27
27
  type next<s extends StaticState, $, args> = s["root"] extends undefined ? parseOperand<s, $, args> : parseOperator<s, $, args>;
28
- export type extractFinalizedResult<s extends StaticState> = s["finalizer"] extends "" ? s["root"] : s["finalizer"] extends ErrorMessage ? s["finalizer"] : s["finalizer"] extends "=" ? parseDefault<s["root"], s["unscanned"]> : state.error<writeUnexpectedCharacterMessage<`${s["finalizer"]}`>>;
28
+ export type extractFinalizedResult<s extends StaticState> = s["finalizer"] extends "" ? s["root"] : s["finalizer"] extends ErrorMessage ? s["finalizer"] : s["finalizer"] extends "?" ? [s["root"], "?"] : s["finalizer"] extends "=" ? parseDefault<s["root"], s["unscanned"]> : state.error<writeUnexpectedCharacterMessage<`${s["finalizer"]}`>>;
29
29
  export {};
@@ -9,6 +9,8 @@ export const fullStringParse = (s) => {
9
9
  }
10
10
  if (s.finalizer === "=")
11
11
  result = parseDefault(s);
12
+ else if (s.finalizer === "?")
13
+ result = result.optional();
12
14
  s.scanner.shiftUntilNonWhitespace();
13
15
  if (s.scanner.lookahead) {
14
16
  // throw a parse error if non-whitespace characters made it here without being parsed
@@ -1,19 +1,18 @@
1
- import { type BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
2
- import { type array, type BuiltinObjectKind, type conform, type Constructor, type Domain, type ErrorMessage, type show } from "@ark/util";
1
+ import { type BaseParseContext, type BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
2
+ import { type anyOrNever, type array, type BuiltinObjectKind, type conform, type Constructor, type Domain, type ErrorMessage, type show } from "@ark/util";
3
3
  import type { inferIntersection } from "../intersect.ts";
4
4
  import type { type } from "../keywords/ark.ts";
5
- import type { Default, distill, inferMorphOut, inferPredicate, Out } from "../keywords/ast.ts";
6
- import type { ParseContext } from "../scope.ts";
5
+ import type { applyConstraint, Default, distill, inferMorphOut, inferPredicate, Optional, OptionalAst, Out } from "../keywords/ast.ts";
7
6
  import type { inferDefinition, validateDefinition } from "./definition.ts";
8
7
  import type { InfixOperator, PostfixExpression } from "./semantic/infer.ts";
9
8
  import { writeMissingRightOperandMessage } from "./string/shift/operand/unenclosed.ts";
10
9
  import type { BaseCompletions } from "./string/string.ts";
11
- export declare const parseTuple: (def: array, ctx: ParseContext) => BaseRoot;
12
- export declare const parseTupleLiteral: (def: array, ctx: ParseContext) => BaseRoot;
10
+ export declare const parseTuple: (def: array, ctx: BaseParseContext) => BaseRoot;
11
+ export declare const parseTupleLiteral: (def: array, ctx: BaseParseContext) => BaseRoot;
13
12
  type InfixExpression = readonly [unknown, InfixOperator, ...unknown[]];
14
13
  export type validateTuple<def extends array, $, args> = def extends IndexZeroExpression ? validatePrefixExpression<def, $, args> : def extends PostfixExpression ? validatePostfixExpression<def, $, args> : def extends InfixExpression ? validateInfixExpression<def, $, args> : def extends (readonly ["", ...unknown[]] | readonly [unknown, "", ...unknown[]]) ? readonly [
15
14
  def[0] extends "" ? BaseCompletions<$, args, IndexZeroOperator | "..."> : def[0],
16
- def[1] extends "" ? BaseCompletions<$, args, IndexOneOperator | "..." | "?"> : def[1]
15
+ def[1] extends "" ? BaseCompletions<$, args, IndexOneOperator | "..."> : def[1]
17
16
  ] : validateTupleLiteral<def, $, args>;
18
17
  export type validateTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? Readonly<s["validated"]> : never;
19
18
  type inferTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? s["inferred"] : never;
@@ -21,55 +20,75 @@ type SequenceParseState = {
21
20
  unscanned: array;
22
21
  inferred: array;
23
22
  validated: array;
23
+ includesOptional: boolean;
24
24
  };
25
25
  type parseSequence<def extends array, $, args> = parseNextElement<{
26
26
  unscanned: def;
27
27
  inferred: [];
28
28
  validated: [];
29
+ includesOptional: false;
29
30
  }, $, args>;
30
31
  type PreparsedElement = {
31
32
  head: unknown;
32
33
  tail: array;
34
+ inferred: unknown;
33
35
  optional: boolean;
34
36
  spread: boolean;
35
37
  };
36
38
  declare namespace PreparsedElement {
37
39
  type from<result extends PreparsedElement> = result;
38
40
  }
39
- type preparseNextElement<s extends SequenceParseState> = s["unscanned"] extends readonly ["...", infer head, ...infer tail] ? tail extends readonly ["?", ...infer postOptionalTail] ? PreparsedElement.from<{
41
+ type preparseNextElement<s extends SequenceParseState, $, args> = s["unscanned"] extends readonly ["...", infer head, ...infer tail] ? inferDefinition<head, $, args> extends infer t ? [
42
+ t
43
+ ] extends [anyOrNever] ? PreparsedElement.from<{
40
44
  head: head;
41
- tail: postOptionalTail;
45
+ tail: tail;
46
+ inferred: t;
47
+ optional: false;
48
+ spread: true;
49
+ }> : [t] extends [OptionalAst<infer base>] ? PreparsedElement.from<{
50
+ head: head;
51
+ tail: tail;
52
+ inferred: base;
42
53
  optional: true;
43
54
  spread: true;
44
55
  }> : PreparsedElement.from<{
45
56
  head: head;
46
57
  tail: tail;
58
+ inferred: t;
47
59
  optional: false;
48
60
  spread: true;
49
- }> : s["unscanned"] extends readonly [infer head, "?", ...infer tail] ? PreparsedElement.from<{
61
+ }> : never : s["unscanned"] extends readonly [infer head, ...infer tail] ? inferDefinition<head, $, args> extends infer t ? [
62
+ t
63
+ ] extends [anyOrNever] ? PreparsedElement.from<{
50
64
  head: head;
51
65
  tail: tail;
66
+ inferred: t;
67
+ optional: false;
68
+ spread: false;
69
+ }> : [t] extends [OptionalAst<infer base>] ? PreparsedElement.from<{
70
+ head: head;
71
+ tail: tail;
72
+ inferred: base;
52
73
  optional: true;
53
74
  spread: false;
54
- }> : s["unscanned"] extends readonly [infer head, ...infer tail] ? PreparsedElement.from<{
75
+ }> : PreparsedElement.from<{
55
76
  head: head;
56
77
  tail: tail;
78
+ inferred: t;
57
79
  optional: false;
58
80
  spread: false;
59
- }> : null;
60
- type parseNextElement<s extends SequenceParseState, $, args> = preparseNextElement<s> extends infer next extends PreparsedElement ? parseNextElement<{
81
+ }> : never : null;
82
+ type parseNextElement<s extends SequenceParseState, $, args> = preparseNextElement<s, $, args> extends infer next extends PreparsedElement ? parseNextElement<{
61
83
  unscanned: next["tail"];
62
84
  inferred: next["spread"] extends true ? [
63
85
  ...s["inferred"],
64
- ...conform<inferDefinition<next["head"], $, args>, array>
65
- ] : next["optional"] extends true ? [
66
- ...s["inferred"],
67
- inferDefinition<next["head"], $, args>?
68
- ] : [...s["inferred"], inferDefinition<next["head"], $, args>];
86
+ ...conform<next["inferred"], array>
87
+ ] : next["optional"] extends true ? [...s["inferred"], next["inferred"]?] : [...s["inferred"], next["inferred"]];
69
88
  validated: [
70
89
  ...s["validated"],
71
90
  ...(next["spread"] extends true ? [
72
- inferDefinition<next["head"], $, args> extends (infer spreadOperand extends array) ? [
91
+ next["inferred"] extends infer spreadOperand extends array ? [
73
92
  number,
74
93
  number
75
94
  ] extends ([
@@ -77,17 +96,9 @@ type parseNextElement<s extends SequenceParseState, $, args> = preparseNextEleme
77
96
  spreadOperand["length"]
78
97
  ]) ? ErrorMessage<multipleVariadicMessage> : "..." : ErrorMessage<writeNonArraySpreadMessage<next["head"]>>
79
98
  ] : []),
80
- [
81
- next["optional"] | next["spread"],
82
- "?"
83
- ] extends ([
84
- false,
85
- s["validated"][number]
86
- ]) ? ErrorMessage<requiredPostOptionalMessage> : validateDefinition<next["head"], $, args>,
87
- ...(next["optional"] extends true ? [
88
- next["spread"] extends true ? ErrorMessage<spreadOptionalMessage> : number extends s["inferred"]["length"] ? ErrorMessage<optionalPostVariadicMessage> : "?"
89
- ] : [])
99
+ next["optional"] extends true ? next["spread"] extends true ? ErrorMessage<spreadOptionalMessage> : number extends s["inferred"]["length"] ? ErrorMessage<optionalPostVariadicMessage> : validateDefinition<next["head"], $, args> : [s["includesOptional"], next["spread"]] extends [true, false] ? ErrorMessage<requiredPostOptionalMessage> : validateDefinition<next["head"], $, args>
90
100
  ];
101
+ includesOptional: s["includesOptional"] | next["optional"] extends (false) ? false : true;
91
102
  }, $, args> : s;
92
103
  export declare const writeNonArraySpreadMessage: <operand extends string>(operand: operand) => writeNonArraySpreadMessage<operand>;
93
104
  type writeNonArraySpreadMessage<operand> = `Spread element must be an array${operand extends string ? ` (was ${operand})` : ""}`;
@@ -100,9 +111,9 @@ type optionalPostVariadicMessage = typeof optionalPostVariadicMessage;
100
111
  export declare const spreadOptionalMessage = "A spread element cannot be optional";
101
112
  type spreadOptionalMessage = typeof optionalPostVariadicMessage;
102
113
  export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
103
- export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def[1] extends "=" ? (In?: inferDefinition<def[0], $, args>) => Default<def[2]> : def extends readonly ["===", ...infer values] ? values[number] : def extends (readonly ["instanceof", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
114
+ export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def[1] extends "=" ? (In?: inferDefinition<def[0], $, args>) => Default<def[2]> : def[1] extends "?" ? applyConstraint<inferDefinition<def[0], $, args>, Optional> : def extends readonly ["===", ...infer values] ? values[number] : def extends (readonly ["instanceof", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
104
115
  export type validatePrefixExpression<def extends IndexZeroExpression, $, args> = def["length"] extends 1 ? readonly [writeMissingRightOperandMessage<def[0]>] : def[0] extends "keyof" ? readonly [def[0], validateDefinition<def[1], $, args>] : def[0] extends "===" ? readonly [def[0], ...unknown[]] : def[0] extends "instanceof" ? readonly [def[0], ...Constructor[]] : never;
105
- export type validatePostfixExpression<def extends PostfixExpression, $, args> = conform<def, readonly [validateDefinition<def[0], $, args>, "[]"]>;
116
+ export type validatePostfixExpression<def extends PostfixExpression, $, args> = conform<def, readonly [validateDefinition<def[0], $, args>, "[]" | "?"]>;
106
117
  export type validateInfixExpression<def extends InfixExpression, $, args> = def["length"] extends 2 ? readonly [def[0], writeMissingRightOperandMessage<def[1]>] : readonly [
107
118
  validateDefinition<def[0], $, args>,
108
119
  def[1],
@@ -115,18 +126,18 @@ export type UnparsedTupleExpressionInput = {
115
126
  export type UnparsedTupleOperator = show<keyof UnparsedTupleExpressionInput>;
116
127
  export declare const parseKeyOfTuple: PrefixParser<"keyof">;
117
128
  export type inferKeyOfExpression<operandDef, $, args> = show<keyof inferDefinition<operandDef, $, args>>;
118
- export type PostfixParser<token extends IndexOneOperator> = (def: IndexOneExpression<token>, ctx: ParseContext) => BaseRoot;
119
- export type PrefixParser<token extends IndexZeroOperator> = (def: IndexZeroExpression<token>, ctx: ParseContext) => BaseRoot;
129
+ export type IndexOneParser<token extends IndexOneOperator> = (def: IndexOneExpression<token>, ctx: BaseParseContext) => BaseRoot;
130
+ export type PrefixParser<token extends IndexZeroOperator> = (def: IndexZeroExpression<token>, ctx: BaseParseContext) => BaseRoot;
120
131
  export type TupleExpression = IndexZeroExpression | IndexOneExpression;
121
132
  export type TupleExpressionOperator = IndexZeroOperator | IndexOneOperator;
122
133
  export type IndexOneOperator = TuplePostfixOperator | TupleInfixOperator;
123
- export type TuplePostfixOperator = "[]";
134
+ export type TuplePostfixOperator = "[]" | "?";
124
135
  export type TupleInfixOperator = "&" | "|" | "=>" | ":" | "@" | "=";
125
136
  export type IndexOneExpression<token extends IndexOneOperator = IndexOneOperator> = readonly [unknown, token, ...unknown[]];
126
- export declare const parseMorphTuple: PostfixParser<"=>">;
137
+ export declare const parseMorphTuple: IndexOneParser<"=>">;
127
138
  export declare const writeMalformedFunctionalExpressionMessage: (operator: ":" | "=>", value: unknown) => string;
128
139
  export type parseMorph<inDef, morph, $, args> = morph extends Morph ? inferMorphOut<morph> extends infer out ? (In: distill.brandable.In<inferDefinition<inDef, $, args>>) => Out<out> : never : never;
129
- export declare const parseNarrowTuple: PostfixParser<":">;
140
+ export declare const parseNarrowTuple: IndexOneParser<":">;
130
141
  export type IndexZeroOperator = "keyof" | "instanceof" | "===";
131
142
  export type IndexZeroExpression<token extends IndexZeroOperator = IndexZeroOperator> = readonly [token, ...unknown[]];
132
143
  export declare const writeInvalidConstructorMessage: <actual extends Domain | BuiltinObjectKind>(actual: actual) => string;