arktype 2.1.17 → 2.1.19

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.
@@ -9,7 +9,7 @@ export type RegexLiteral<source extends string = string> = `/${source}/`;
9
9
  export type DateLiteral<source extends string = string> = `d"${source}"` | `d'${source}'`;
10
10
  export type LimitLiteral = number | DateLiteral;
11
11
  export type normalizeLimit<limit> = limit extends DateLiteral<infer source> ? source : limit extends number | string ? limit : never;
12
- export type distill<t, endpoint extends distill.Endpoint> = finalizeDistillation<t, _distill<t, endpoint, never>>;
12
+ export type distill<t, endpoint extends distill.Endpoint> = finalizeDistillation<t, _distill<t, endpoint>>;
13
13
  export declare namespace distill {
14
14
  type Endpoint = "in" | "out" | "out.introspectable";
15
15
  type In<t> = distill<t, "in">;
@@ -19,33 +19,33 @@ export declare namespace distill {
19
19
  }
20
20
  }
21
21
  type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
22
- type _distill<t, endpoint extends distill.Endpoint, seen> = t extends undefined ? t : [t] extends [anyOrNever | seen] ? t : unknown extends t ? unknown : t extends Brand<infer base> ? endpoint extends "in" ? base : t : t extends TerminallyInferredObject | Primitive ? t : t extends Function ? t extends (...args: never) => anyOrNever ? t : t extends InferredMorph<infer i, infer o> ? distillIo<i, o, endpoint, seen> : t : t extends Default<infer constraint> ? _distill<constraint, endpoint, seen> : t extends array ? distillArray<t, endpoint, seen | t> : isSafelyMappable<t> extends true ? distillMappable<t, endpoint, seen | t> : t;
23
- type distillMappable<o, endpoint extends distill.Endpoint, seen> = endpoint extends "in" ? show<{
24
- [k in keyof o as k extends inferredDefaultKeyOf<o> ? never : k]: _distill<o[k], endpoint, seen>;
22
+ type _distill<t, endpoint extends distill.Endpoint> = t extends undefined ? t : [t] extends [anyOrNever] ? t : unknown extends t ? unknown : t extends Brand<infer base> ? endpoint extends "in" ? base : t : t extends TerminallyInferredObject | Primitive ? t : t extends Function ? t extends (...args: never) => anyOrNever ? t : t extends InferredMorph<infer i, infer o> ? distillIo<i, o, endpoint> : t : t extends Default<infer constraint> ? _distill<constraint, endpoint> : t extends array ? distillArray<t, endpoint> : isSafelyMappable<t> extends true ? distillMappable<t, endpoint> : t;
23
+ type distillMappable<o, endpoint extends distill.Endpoint> = endpoint extends "in" ? show<{
24
+ [k in keyof o as k extends inferredDefaultKeyOf<o> ? never : k]: _distill<o[k], endpoint>;
25
25
  } & {
26
- [k in inferredDefaultKeyOf<o>]?: _distill<o[k], endpoint, seen>;
26
+ [k in inferredDefaultKeyOf<o>]?: _distill<o[k], endpoint>;
27
27
  }> : {
28
- [k in keyof o]: _distill<o[k], endpoint, seen>;
28
+ [k in keyof o]: _distill<o[k], endpoint>;
29
29
  };
30
- type distillIo<i, o extends Out, endpoint extends distill.Endpoint, seen> = endpoint extends "out" ? _distill<o["t"], endpoint, seen> : endpoint extends "in" ? _distill<i, endpoint, seen> : o extends To<infer validatedOut> ? _distill<validatedOut, endpoint, seen> : unknown;
30
+ type distillIo<i, o extends Out, endpoint extends distill.Endpoint> = endpoint extends "out" ? _distill<o["t"], endpoint> : endpoint extends "in" ? _distill<i, endpoint> : o extends To<infer validatedOut> ? _distill<validatedOut, endpoint> : unknown;
31
31
  type unwrapInput<t> = t extends InferredMorph<infer i> ? t extends anyOrNever ? t : i : t;
32
32
  type inferredDefaultKeyOf<o> = keyof o extends infer k ? k extends keyof o ? unwrapInput<o[k]> extends Default<infer t> ? [
33
33
  t
34
34
  ] extends [anyOrNever] ? never : k : never : never : never;
35
- type distillArray<t extends array, endpoint extends distill.Endpoint, seen> = t[number][] extends t ? alignReadonly<_distill<t[number], endpoint, seen>[], t> : distillNonArraykeys<t, alignReadonly<distillArrayFromPrefix<[...t], endpoint, seen, []>, t>, endpoint, seen>;
35
+ type distillArray<t extends array, endpoint extends distill.Endpoint> = t[number][] extends t ? alignReadonly<_distill<t[number], endpoint>[], t> : distillNonArraykeys<t, alignReadonly<distillArrayFromPrefix<[...t], endpoint, []>, t>, endpoint>;
36
36
  type alignReadonly<result extends unknown[], original extends array> = original extends unknown[] ? result : Readonly<result>;
37
- type distillNonArraykeys<originalArray extends array, distilledArray, endpoint extends distill.Endpoint, seen> = keyof originalArray extends keyof distilledArray ? distilledArray : distilledArray & _distill<{
37
+ type distillNonArraykeys<originalArray extends array, distilledArray, endpoint extends distill.Endpoint> = keyof originalArray extends keyof distilledArray ? distilledArray : distilledArray & _distill<{
38
38
  [k in keyof originalArray as k extends keyof distilledArray ? never : k]: originalArray[k];
39
- }, endpoint, seen>;
40
- type distillArrayFromPrefix<t extends array, endpoint extends distill.Endpoint, seen, prefix extends array> = t extends readonly [infer head, ...infer tail] ? distillArrayFromPrefix<tail, endpoint, seen, [
39
+ }, endpoint>;
40
+ type distillArrayFromPrefix<t extends array, endpoint extends distill.Endpoint, prefix extends array> = t extends readonly [infer head, ...infer tail] ? distillArrayFromPrefix<tail, endpoint, [
41
41
  ...prefix,
42
- _distill<head, endpoint, seen>
43
- ]> : [...prefix, ...distillArrayFromPostfix<t, endpoint, seen, []>];
44
- type distillArrayFromPostfix<t extends array, endpoint extends distill.Endpoint, seen, postfix extends array> = t extends readonly [...infer init, infer last] ? distillArrayFromPostfix<init, endpoint, seen, [
45
- _distill<last, endpoint, seen>,
42
+ _distill<head, endpoint>
43
+ ]> : [...prefix, ...distillArrayFromPostfix<t, endpoint, []>];
44
+ type distillArrayFromPostfix<t extends array, endpoint extends distill.Endpoint, postfix extends array> = t extends readonly [...infer init, infer last] ? distillArrayFromPostfix<init, endpoint, [
45
+ _distill<last, endpoint>,
46
46
  ...postfix
47
47
  ]> : [...{
48
- [i in keyof t]: _distill<t[i], endpoint, seen>;
48
+ [i in keyof t]: _distill<t[i], endpoint>;
49
49
  }, ...postfix];
50
50
  type BuiltinTerminalObjectKind = Exclude<arkPrototypes.NonDegenerateName, "Array" | "Function">;
51
51
  /** Objects we don't want to expand during inference like Date or Promise */
@@ -16,7 +16,7 @@ export type inferDefinition<def, $, args> = [
16
16
  export type validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [anyOrNever] ? def : def extends OptionalPropertyDefinition ? ErrorMessage<shallowOptionalMessage> : isDefaultable<def, $, args> extends true ? ErrorMessage<shallowDefaultableMessage> : validateInnerDefinition<def, $, args>;
17
17
  export type validateInnerDefinition<def, $, args> = [
18
18
  def
19
- ] 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>;
19
+ ] extends [Terminal] ? def : def extends string ? validateString<def, $, args> : def extends BadDefinitionType ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : unknown extends def ? BaseCompletions<$, args> | {} : def extends readonly unknown[] ? validateTuple<def, $, args> : validateObjectLiteral<def, $, args>;
20
20
  export declare const parseTuple: (def: array, ctx: BaseParseContext) => BaseRoot;
21
21
  export type validateTuple<def extends array, $, args> = maybeValidateTupleExpression<def, $, args> extends infer result ? result extends null ? validateTupleLiteral<def, $, args> : result : never;
22
22
  export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
@@ -33,7 +33,7 @@ type declarationMismatch<def, declared, $, args> = {
33
33
  declared: declared;
34
34
  inferred: inferDefinition<def, $, args>;
35
35
  };
36
- type Terminal = type.cast<unknown> | Fn;
36
+ type Terminal = type.cast<unknown> | Fn | RegExp;
37
37
  export type ThunkCast<t = unknown> = () => type.cast<t>;
38
38
  type BadDefinitionType = Exclude<Primitive, string>;
39
39
  export declare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => writeBadDefinitionTypeMessage<actual>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
3
  "description": "TypeScript's 1:1 validator, optimized from editor to runtime",
4
- "version": "2.1.17",
4
+ "version": "2.1.19",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -34,8 +34,8 @@
34
34
  "out"
35
35
  ],
36
36
  "dependencies": {
37
- "@ark/util": "0.45.7",
38
- "@ark/schema": "0.45.7"
37
+ "@ark/util": "0.45.9",
38
+ "@ark/schema": "0.45.9"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"