arktype 2.0.0-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/generic.d.ts +21 -12
- package/out/index.d.ts +2 -1
- package/out/index.js +1 -1
- package/out/module.d.ts +3 -3
- package/out/parser/objectLiteral.d.ts +2 -2
- package/out/parser/semantic/infer.d.ts +3 -3
- package/out/parser/semantic/validate.d.ts +2 -2
- package/out/scope.d.ts +8 -7
- package/out/type.d.ts +8 -2
- package/package.json +3 -3
package/out/generic.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GenericParamAst, GenericParamDef,
|
|
2
|
-
import { type array, type Callable, type conform, type ErrorMessage, type
|
|
1
|
+
import type { ConstrainedGenericParamDef, GenericHkt, GenericParamAst, GenericParamDef, GenericProps, GenericRoot, LazyGenericBody } from "@ark/schema";
|
|
2
|
+
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type WhiteSpaceToken } from "@ark/util";
|
|
3
3
|
import type { inferDefinition } from "./parser/definition.js";
|
|
4
4
|
import type { inferAstRoot } from "./parser/semantic/infer.js";
|
|
5
5
|
import type { validateAst } from "./parser/semantic/validate.js";
|
|
@@ -10,21 +10,24 @@ import type { ParseContext } from "./scope.js";
|
|
|
10
10
|
import type { inferTypeRoot, Type, validateTypeRoot } from "./type.js";
|
|
11
11
|
export type ParameterString<params extends string = string> = `<${params}>`;
|
|
12
12
|
export type extractParams<s extends ParameterString> = s extends ParameterString<infer params> ? params : never;
|
|
13
|
-
export type validateParameterString<s extends ParameterString, $> = parseGenericParams<extractParams<s>, $> extends
|
|
14
|
-
export type validateGenericArg<arg, param extends GenericParamAst, $> = inferTypeRoot<arg, $> extends param[1] ? arg :
|
|
13
|
+
export type validateParameterString<s extends ParameterString, $> = parseGenericParams<extractParams<s>, $> extends infer e extends ErrorMessage ? e : s;
|
|
14
|
+
export type validateGenericArg<arg, param extends GenericParamAst, $> = inferTypeRoot<arg, $> extends param[1] ? arg : ErrorType<`Invalid argument for ${param[0]}`, [expected: param[1]]>;
|
|
15
15
|
export type GenericInstantiator<params extends array<GenericParamAst>, def, $, args$> = <const args extends {
|
|
16
16
|
[i in keyof params]: validateTypeRoot<args[i & keyof args], args$>;
|
|
17
17
|
}>(
|
|
18
18
|
/** @ts-expect-error treat as array */
|
|
19
19
|
...args: {
|
|
20
20
|
[i in keyof args]: validateGenericArg<args[i], params[i & keyof params & `${number}`], args$>;
|
|
21
|
-
}) => Type<def extends
|
|
21
|
+
}) => Type<def extends GenericHkt ? GenericHkt.instantiate<def, {
|
|
22
22
|
[i in keyof args]: inferTypeRoot<args[i], args$>;
|
|
23
23
|
}> : inferDefinition<def, $, bindGenericArgs<params, args$, args>>, $>;
|
|
24
24
|
type bindGenericArgs<params extends array<GenericParamAst>, $, args> = {
|
|
25
25
|
[i in keyof params & `${number}` as params[i][0]]: inferTypeRoot<args[i & keyof args], $>;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
type baseGenericResolutions<params extends array<GenericParamAst>, $> = baseGenericConstraints<params> extends infer baseConstraints ? {
|
|
28
|
+
[k in keyof baseConstraints]: Type<baseConstraints[k], $>;
|
|
29
|
+
} : never;
|
|
30
|
+
export type baseGenericConstraints<params extends array<GenericParamAst>> = {
|
|
28
31
|
[i in keyof params & `${number}` as params[i][0]]: params[i][1];
|
|
29
32
|
};
|
|
30
33
|
export interface Generic<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, args$ = $> extends Callable<GenericInstantiator<params, bodyDef, $, args$>>, GenericProps<params, bodyDef, $> {
|
|
@@ -47,19 +50,25 @@ declare const paramsTerminators: {
|
|
|
47
50
|
type ParamsTerminator = keyof typeof paramsTerminators;
|
|
48
51
|
declare const parseName: (scanner: Scanner, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
|
|
49
52
|
type parseName<unscanned extends string, result extends array<GenericParamAst>, $> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, "", result, $>;
|
|
50
|
-
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ?
|
|
53
|
+
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ? ErrorMessage<emptyGenericParameterMessage> : lookahead extends "," ? parseName<nextUnscanned, [...result, [name, unknown]], $> : lookahead extends ":" | WhiteSpaceToken ? _parseOptionalConstraint<unscanned, name, result, $> : never : parseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $> : name extends "" ? result : [...result, [name, unknown]];
|
|
51
54
|
declare const extendsToken = "extends ";
|
|
52
55
|
type ConstrainingToken = ":" | typeof extendsToken;
|
|
53
56
|
declare const _parseOptionalConstraint: (scanner: Scanner, name: string, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
|
|
54
|
-
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${ConstrainingToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (
|
|
57
|
+
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${ConstrainingToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (infer e extends ErrorMessage) ? e : parseName<finalArgState["unscanned"], [
|
|
55
58
|
...result,
|
|
56
59
|
[name, inferAstRoot<finalArgState["root"], $, {}>]
|
|
57
60
|
], $> : never : parseName<Scanner.skipWhitespace<unscanned> extends `,${infer nextUnscanned}` ? nextUnscanned : unscanned, [
|
|
58
61
|
...result,
|
|
59
62
|
[name, unknown]
|
|
60
63
|
], $>;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
type genericParamDefToAst<schema extends GenericParamDef, $> = schema extends string ? [schema, unknown] : schema extends ConstrainedGenericParamDef ? [
|
|
65
|
+
schema[0],
|
|
66
|
+
inferTypeRoot<schema[1], $>
|
|
67
|
+
] : never;
|
|
68
|
+
export type genericParamDefsToAst<schemas extends array<GenericParamDef>, $> = [
|
|
69
|
+
...{
|
|
70
|
+
[i in keyof schemas]: genericParamDefToAst<schemas[i], $>;
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
export type GenericHktParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: paramsDef) => <hkt extends abstract new () => GenericHkt, params extends Array<GenericParamAst> = genericParamDefsToAst<paramsDef, $>>(instantiateDef: LazyGenericBody<baseGenericResolutions<params, $>>, hkt: hkt) => Generic<params, InstanceType<hkt>, $, $>;
|
|
65
74
|
export {};
|
package/out/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { ArkError, ArkErrors
|
|
1
|
+
export { ArkError, ArkErrors, GenericHkt } from "@ark/schema";
|
|
2
2
|
export type { Ark, ArkConfig, Out, constrained, inferred } from "@ark/schema";
|
|
3
3
|
export { ambient, ark, declare, define, generic, match, type } from "./ark.js";
|
|
4
|
+
export type { Generic } from "./generic.js";
|
|
4
5
|
export { Module } from "./module.js";
|
|
5
6
|
export { scope, type Scope, type inferScope, type validateScope } from "./scope.js";
|
|
6
7
|
export { Type, type AnyType, type inferTypeRoot, type validateTypeRoot } from "./type.js";
|
package/out/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ArkError, ArkErrors
|
|
1
|
+
export { ArkError, ArkErrors, GenericHkt } from "@ark/schema";
|
|
2
2
|
export { ambient, ark, declare, define, generic, match, type } from "./ark.js";
|
|
3
3
|
export { Module } from "./module.js";
|
|
4
4
|
export { scope } from "./scope.js";
|
package/out/module.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RootModule, type arkKind, type GenericProps } from "@ark/schema";
|
|
2
|
-
import type { anyOrNever
|
|
3
|
-
import type { Generic
|
|
2
|
+
import type { anyOrNever } from "@ark/util";
|
|
3
|
+
import type { Generic } from "./generic.js";
|
|
4
4
|
import type { Type } from "./type.js";
|
|
5
5
|
type exportScope<$> = {
|
|
6
6
|
[k in keyof $]: $[k] extends {
|
|
7
7
|
[arkKind]: "module";
|
|
8
8
|
} ? [
|
|
9
9
|
$[k]
|
|
10
|
-
] extends [anyOrNever] ? Type<$[k], $> : $[k] : $[k] extends GenericProps<infer params, infer bodyDef, infer args$> ?
|
|
10
|
+
] extends [anyOrNever] ? Type<$[k], $> : $[k] : $[k] extends GenericProps<infer params, infer bodyDef, infer args$> ? Generic<params, bodyDef, $, args$> : Type<$[k], $>;
|
|
11
11
|
};
|
|
12
12
|
export declare const Module: new <$ = {}>(types: exportScope<$>) => Module<$>;
|
|
13
13
|
export type Module<$ = {}> = RootModule<exportScope<$>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BaseRoot, type Default, type IndexNode, type of, type OptionalNode, type RequiredNode, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
|
|
2
|
-
import { type anyOrNever, type Dict, type ErrorMessage, type
|
|
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 { ParseContext } from "../scope.js";
|
|
4
4
|
import type { inferDefinition, validateDefinition } from "./definition.js";
|
|
5
5
|
import type { astToString } from "./semantic/utils.js";
|
|
@@ -17,7 +17,7 @@ type _inferObjectLiteral<def extends object, $, args> = {
|
|
|
17
17
|
-readonly [k in keyof def as optionalKeyFrom<k>]?: inferDefinition<def[k], $, args>;
|
|
18
18
|
};
|
|
19
19
|
export type validateObjectLiteral<def, $, args> = {
|
|
20
|
-
[k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ?
|
|
20
|
+
[k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? ErrorType<message> : inferDefinition<indexDef, $, args> extends (PropertyKey | of<PropertyKey, {}>) ? 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>;
|
|
21
21
|
};
|
|
22
22
|
type validateDefaultableValue<def, k extends keyof def, $, args> = def[k] extends DefaultValueTuple ? validateDefaultValueTuple<def[k], k, $, args> : validateDefinition<def[k], $, args>;
|
|
23
23
|
type DefaultValueTuple<baseDef = unknown, defaultValue = unknown> = readonly [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Date, DateLiteral, Default, GenericProps, LimitLiteral, RegexLiteral, constrain, distillIn, distillOut, inferIntersection, normalizeLimit, string } from "@ark/schema";
|
|
2
|
-
import type { BigintLiteral,
|
|
1
|
+
import type { Date, DateLiteral, Default, GenericHkt, GenericProps, LimitLiteral, RegexLiteral, constrain, distillIn, distillOut, inferIntersection, normalizeLimit, string } from "@ark/schema";
|
|
2
|
+
import type { BigintLiteral, array } from "@ark/util";
|
|
3
3
|
import type { UnparsedScope, resolve, tryInferSubmoduleReference } from "../../scope.js";
|
|
4
4
|
import type { inferDefinition } from "../definition.js";
|
|
5
5
|
import type { Comparator, MinComparator } from "../string/reduce/shared.js";
|
|
@@ -9,7 +9,7 @@ export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;
|
|
|
9
9
|
export type inferAstOut<ast, $, args> = distillOut<inferAstRoot<ast, $, args>>;
|
|
10
10
|
export type inferConstrainableAst<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : ast extends string ? inferTerminal<ast, $, args> : never;
|
|
11
11
|
export type GenericInstantiationAst<generic extends GenericProps = GenericProps, argAsts extends unknown[] = unknown[]> = [generic, "<>", argAsts];
|
|
12
|
-
export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer generic, infer argAsts> ? generic extends
|
|
12
|
+
export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer generic, infer argAsts> ? generic["bodyDef"] extends GenericHkt ? GenericHkt.instantiate<generic["bodyDef"], {
|
|
13
13
|
[i in keyof argAsts]: inferConstrainableAst<argAsts[i], $, args>;
|
|
14
14
|
}> : inferDefinition<generic["bodyDef"], generic["$"]["t"] extends UnparsedScope ? $ : generic["$"]["t"], {
|
|
15
15
|
[i in keyof generic["params"] & `${number}` as generic["names"][i & keyof generic["names"]]]: inferConstrainableAst<argAsts[i & keyof argAsts], $, args>;
|
|
@@ -14,7 +14,7 @@ export type validateAst<ast, $, args> = ast extends string ? validateStringAst<a
|
|
|
14
14
|
ast: ast;
|
|
15
15
|
};
|
|
16
16
|
type writeUnexpectedExpressionMessage<expression extends string> = `Unexpectedly failed to parse the expression resulting from ${expression}`;
|
|
17
|
-
type validateGenericArgs<params extends array<GenericParamAst>, argAsts extends array, $, args, indices extends 1[]> = argAsts extends readonly [infer arg, ...infer argsTail] ? validateAst<arg, $, args> extends
|
|
17
|
+
type validateGenericArgs<params extends array<GenericParamAst>, argAsts extends array, $, args, indices extends 1[]> = argAsts extends readonly [infer arg, ...infer argsTail] ? validateAst<arg, $, args> extends infer e extends ErrorMessage ? e : inferAstRoot<arg, $, args> extends params[indices["length"]][1] ? validateGenericArgs<params, argsTail, $, args, [...indices, 1]> : ErrorMessage<writeUnsatisfiedParameterConstraintMessage<params[indices["length"]][0], typeToString<params[indices["length"]][1]>, astToString<arg>>> : undefined;
|
|
18
18
|
export declare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => writeUnsatisfiableExpressionError<expression>;
|
|
19
19
|
export type writeUnsatisfiableExpressionError<expression extends string> = `${expression} results in an unsatisfiable type`;
|
|
20
20
|
export declare const writePrefixedPrivateReferenceMessage: <def extends PrivateDeclaration>(def: def) => writePrefixedPrivateReferenceMessage<def>;
|
|
@@ -26,5 +26,5 @@ type validateStringAst<def extends string, $> = def extends `${infer n extends n
|
|
|
26
26
|
} ? ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;
|
|
27
27
|
export type maybeExtractAlias<def extends string, $> = def extends keyof $ ? def : `#${def}` extends keyof $ ? `#${def}` : null;
|
|
28
28
|
export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends (infer result extends ErrorMessage) ? result extends Completion<infer text> ? text : result : def;
|
|
29
|
-
type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends
|
|
29
|
+
type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e : validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e : undefined;
|
|
30
30
|
export {};
|
package/out/scope.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InternalBaseScope, type AliasDefEntry, type ArkConfig, type BaseRoot, type BaseScope, type GenericArgResolutions, type GenericParamAst, type GenericParamDef, type GenericProps, type InternalResolutions, type PreparsedNodeResolution, type PrivateDeclaration, type arkKind, type destructuredExportContext, type destructuredImportContext, type exportedNameOf, type writeDuplicateAliasError } from "@ark/schema";
|
|
2
|
-
import { type
|
|
3
|
-
import { parseGenericParams, type Generic, type GenericDeclaration, type GenericHktParser, type ParameterString, type
|
|
2
|
+
import { type ErrorType, type anyOrNever, type array, type nominal, type show } from "@ark/util";
|
|
3
|
+
import { parseGenericParams, type Generic, type GenericDeclaration, type GenericHktParser, type ParameterString, type baseGenericConstraints, type parseValidGenericParams } from "./generic.js";
|
|
4
4
|
import { type MatchParser } from "./match.js";
|
|
5
5
|
import type { Module } from "./module.js";
|
|
6
6
|
import { type inferDefinition, type validateDefinition } from "./parser/definition.js";
|
|
@@ -8,7 +8,7 @@ import type { ParsedDefault } from "./parser/string/shift/operator/default.js";
|
|
|
8
8
|
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type Type, type TypeParser } from "./type.js";
|
|
9
9
|
export type ScopeParser = <const def>(def: validateScope<def>, config?: ArkConfig) => Scope<inferScope<def>>;
|
|
10
10
|
export type validateScope<def> = {
|
|
11
|
-
[k in keyof def]: k extends symbol ? unknown : parseScopeKey<k, def>["params"] extends infer params ? params extends array<GenericParamAst> ? params["length"] extends 0 ? def[k] extends Type | PreparsedResolution ? def[k] : k extends PrivateDeclaration<infer name extends keyof def & string> ?
|
|
11
|
+
[k in keyof def]: k extends symbol ? unknown : parseScopeKey<k, def>["params"] extends infer params ? params extends array<GenericParamAst> ? params["length"] extends 0 ? def[k] extends Type | PreparsedResolution ? def[k] : k extends PrivateDeclaration<infer name extends keyof def & string> ? ErrorType<writeDuplicateAliasError<name>> : validateDefinition<def[k], bootstrapAliases<def>, {}> : validateDefinition<def[k], bootstrapAliases<def>, baseGenericConstraints<params>> : params : never;
|
|
12
12
|
};
|
|
13
13
|
export type inferScope<def> = inferBootstrapped<bootstrapAliases<def>>;
|
|
14
14
|
export type bindThis<def> = {
|
|
@@ -76,11 +76,12 @@ export type ParsedScopeKey = {
|
|
|
76
76
|
name: string;
|
|
77
77
|
params: array<GenericParamDef>;
|
|
78
78
|
};
|
|
79
|
-
export type parseScopeKey<k, def> = k extends `${infer name}<${infer params}>` ? {
|
|
80
|
-
name: name;
|
|
81
|
-
params: parseGenericParams<params, bootstrapAliases<def>>;
|
|
82
|
-
} : {
|
|
79
|
+
export type parseScopeKey<k, def> = k extends `${infer name}<${infer params}>` ? parseGenericScopeKey<name, params, def> : {
|
|
83
80
|
name: k;
|
|
84
81
|
params: [];
|
|
85
82
|
};
|
|
83
|
+
type parseGenericScopeKey<name extends string, params extends string, def> = {
|
|
84
|
+
name: name;
|
|
85
|
+
params: parseGenericParams<params, bootstrapAliases<def>>;
|
|
86
|
+
};
|
|
86
87
|
export {};
|
package/out/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArkErrors, BaseRoot, type BaseMeta, type Disjoint, type DivisorSchema, type ExactLengthSchema, type ExclusiveDateRangeSchema, type ExclusiveNumericRangeSchema, type InclusiveDateRangeSchema, type InclusiveNumericRangeSchema, type Morph, type MorphAst, type NodeSchema, type Out, type PatternSchema, type Predicate, type PrimitiveConstraintKind, type Root, type arkKeyOf, type constrain, type constraintKindOf, type distillIn, type distillOut, type exclusivizeRangeSchema, type getArkKey, type inferIntersection, type inferMorphOut, type inferPipes, type inferPredicate, type toArkKey, type validateChainedAsArgs, type validateChainedConstraint, type validateStructuralOperand } from "@ark/schema";
|
|
2
2
|
import { Callable, type Constructor, type array, type conform, type unset } from "@ark/util";
|
|
3
3
|
import type { type } from "./ark.js";
|
|
4
|
-
import { type Generic, type ParameterString, type
|
|
4
|
+
import { type Generic, type ParameterString, type baseGenericConstraints, type parseValidGenericParams, type validateParameterString } from "./generic.js";
|
|
5
5
|
import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.js";
|
|
6
6
|
import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.js";
|
|
7
7
|
import type { InternalScope, Scope, bindThis } from "./scope.js";
|
|
@@ -10,7 +10,7 @@ export type TypeParserAttachments = Omit<TypeParser, never>;
|
|
|
10
10
|
export interface TypeParser<$ = {}> {
|
|
11
11
|
<const def>(def: validateTypeRoot<def, $>): Type<inferTypeRoot<def, $>, $>;
|
|
12
12
|
<const zero, const one, const rest extends array>(_0: zero extends IndexZeroOperator ? zero : validateTypeRoot<zero, $>, _1: zero extends "keyof" ? validateTypeRoot<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distillIn<inferTypeRoot<zero, $>>>] : one extends "=>" ? [Morph<distillOut<inferTypeRoot<zero, $>>, unknown>] : one extends "@" ? [string | BaseMeta] : [validateTypeRoot<rest[0], $>] : []): Type<inferTypeRoot<[zero, one, ...rest], $>, $>;
|
|
13
|
-
<params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $,
|
|
13
|
+
<params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): Generic<parseValidGenericParams<params, $>, def, $>;
|
|
14
14
|
raw(def: unknown): Type<any, $>;
|
|
15
15
|
errors: typeof ArkErrors;
|
|
16
16
|
}
|
|
@@ -49,6 +49,12 @@ declare class _Type<t = unknown, $ = any> extends Root<t, $> {
|
|
|
49
49
|
pick<const key extends arkKeyOf<t> = never>(this: validateStructuralOperand<"pick", this>, ...keys: array<key | type.cast<key>>): Type<{
|
|
50
50
|
[k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];
|
|
51
51
|
}, $>;
|
|
52
|
+
required(this: validateStructuralOperand<"required", this>): Type<{
|
|
53
|
+
[k in keyof this["inferIn"]]-?: this["inferIn"][k];
|
|
54
|
+
}, $>;
|
|
55
|
+
partial(this: validateStructuralOperand<"partial", this>): Type<{
|
|
56
|
+
[k in keyof this["inferIn"]]?: this["inferIn"][k];
|
|
57
|
+
}, $>;
|
|
52
58
|
get<k1 extends arkKeyOf<t>>(k1: k1 | type.cast<k1>): Type<getArkKey<t, k1>, $>;
|
|
53
59
|
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): Type<getArkKey<getArkKey<t, k1>, k2>, $>;
|
|
54
60
|
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, k3 extends arkKeyOf<getArkKey<getArkKey<t, k1>, k2>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): Type<getArkKey<getArkKey<getArkKey<t, k1>, k2>, k3>, $>;
|
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.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "David Blass",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"out"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ark/util": "0.1.
|
|
29
|
-
"@ark/schema": "0.2.
|
|
28
|
+
"@ark/util": "0.1.2",
|
|
29
|
+
"@ark/schema": "0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|