arktype 2.0.0-dev.4 → 2.0.0-dev.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.
- package/__tests__/array.test.ts +176 -236
- package/__tests__/badDefinitionType.test.ts +10 -3
- package/__tests__/basis.test.ts +6 -2
- package/__tests__/bounds.test.ts +282 -352
- package/__tests__/cast.test.ts +7 -2
- package/__tests__/completions.test.ts +8 -3
- package/__tests__/config.test.ts +16 -8
- package/__tests__/cyclic.test.ts +141 -137
- package/__tests__/dateLiteral.test.ts +8 -4
- package/__tests__/declared.test.ts +2 -2
- package/__tests__/discrimination.test.ts +1 -1
- package/__tests__/divisor.test.ts +45 -25
- package/__tests__/enclosed.test.ts +39 -25
- package/__tests__/examples.test.ts +56 -56
- package/__tests__/expressions.test.ts +184 -112
- package/__tests__/generic.test.ts +307 -288
- package/__tests__/group.test.ts +67 -54
- package/__tests__/imports.test.ts +44 -37
- package/__tests__/instanceof.test.ts +17 -15
- package/__tests__/intersection.test.ts +50 -46
- package/__tests__/keyTraversal.test.ts +6 -3
- package/__tests__/keyof.test.ts +68 -52
- package/__tests__/keywords.test.ts +149 -136
- package/__tests__/literal.test.ts +38 -15
- package/__tests__/match.test.ts +234 -224
- package/__tests__/morph.test.ts +300 -269
- package/__tests__/narrow.test.ts +46 -42
- package/__tests__/objectLiteral.test.ts +228 -210
- package/__tests__/realWorld.test.ts +63 -0
- package/__tests__/regex.test.ts +17 -7
- package/__tests__/scope.bench.ts +1 -1
- package/__tests__/scope.test.ts +65 -18
- package/__tests__/serialization.test.ts +19 -0
- package/__tests__/string.test.ts +11 -7
- package/__tests__/submodule.test.ts +26 -39
- package/__tests__/this.test.ts +83 -57
- package/__tests__/thunk.test.ts +13 -7
- package/__tests__/traverse.test.ts +50 -37
- package/__tests__/tsGenerics.test.ts +12 -12
- package/__tests__/type.test.ts +38 -0
- package/__tests__/typeReference.test.ts +7 -7
- package/__tests__/unenclosed.test.ts +116 -100
- package/__tests__/union.test.ts +171 -104
- package/ark.ts +18 -65
- package/generic.ts +67 -0
- package/main.ts +6 -18
- package/match.ts +53 -67
- package/module.ts +15 -0
- package/out/ark.d.ts +12 -36
- package/out/ark.d.ts.map +1 -1
- package/out/ark.js +9 -17
- package/out/ark.js.map +1 -1
- package/out/base.d.ts +205 -0
- package/out/base.d.ts.map +1 -0
- package/out/base.js +320 -0
- package/out/base.js.map +1 -0
- package/out/builtins/builtins.d.ts +23 -0
- package/out/builtins/builtins.d.ts.map +1 -0
- package/out/builtins/builtins.js +15 -0
- package/out/builtins/builtins.js.map +1 -0
- package/out/builtins/jsObjects.d.ts +19 -0
- package/out/builtins/jsObjects.d.ts.map +1 -0
- package/out/builtins/jsObjects.js +18 -0
- package/out/builtins/jsObjects.js.map +1 -0
- package/out/builtins/parsing.d.ts +16 -0
- package/out/builtins/parsing.d.ts.map +1 -0
- package/out/builtins/parsing.js +62 -0
- package/out/builtins/parsing.js.map +1 -0
- package/out/builtins/tsGenerics.d.ts +2 -0
- package/out/builtins/tsGenerics.d.ts.map +1 -0
- package/out/builtins/tsGenerics.js +26 -0
- package/out/builtins/tsGenerics.js.map +1 -0
- package/out/builtins/tsKeywords.d.ts +23 -0
- package/out/builtins/tsKeywords.d.ts.map +1 -0
- package/out/builtins/tsKeywords.js +23 -0
- package/out/builtins/tsKeywords.js.map +1 -0
- package/out/builtins/utils/creditCard.d.ts +3 -0
- package/out/builtins/utils/creditCard.d.ts.map +1 -0
- package/out/builtins/utils/creditCard.js +35 -0
- package/out/builtins/utils/creditCard.js.map +1 -0
- package/out/builtins/utils/date.d.ts +41 -0
- package/out/builtins/utils/date.d.ts.map +1 -0
- package/out/builtins/utils/date.js +56 -0
- package/out/builtins/utils/date.js.map +1 -0
- package/out/builtins/validation.d.ts +19 -0
- package/out/builtins/validation.d.ts.map +1 -0
- package/out/builtins/validation.js +74 -0
- package/out/builtins/validation.js.map +1 -0
- package/out/config.d.ts +9 -0
- package/out/config.d.ts.map +1 -0
- package/out/config.js +18 -0
- package/out/config.js.map +1 -0
- package/out/constraints/ast.d.ts +287 -0
- package/out/constraints/ast.d.ts.map +1 -0
- package/out/constraints/ast.js +2 -0
- package/out/constraints/ast.js.map +1 -0
- package/out/constraints/constraint.d.ts +200 -0
- package/out/constraints/constraint.d.ts.map +1 -0
- package/out/constraints/constraint.js +25 -0
- package/out/constraints/constraint.js.map +1 -0
- package/out/constraints/predicate.d.ts +64 -0
- package/out/constraints/predicate.d.ts.map +1 -0
- package/out/constraints/predicate.js +52 -0
- package/out/constraints/predicate.js.map +1 -0
- package/out/constraints/props/index.d.ts +42 -0
- package/out/constraints/props/index.d.ts.map +1 -0
- package/out/constraints/props/index.js +56 -0
- package/out/constraints/props/index.js.map +1 -0
- package/out/constraints/props/optional.d.ts +37 -0
- package/out/constraints/props/optional.d.ts.map +1 -0
- package/out/constraints/props/optional.js +56 -0
- package/out/constraints/props/optional.js.map +1 -0
- package/out/constraints/props/prop.d.ts +49 -0
- package/out/constraints/props/prop.d.ts.map +1 -0
- package/out/constraints/props/prop.js +106 -0
- package/out/constraints/props/prop.js.map +1 -0
- package/out/constraints/props/props.d.ts +37 -0
- package/out/constraints/props/props.d.ts.map +1 -0
- package/out/constraints/props/props.js +121 -0
- package/out/constraints/props/props.js.map +1 -0
- package/out/constraints/props/required.d.ts +46 -0
- package/out/constraints/props/required.d.ts.map +1 -0
- package/out/constraints/props/required.js +81 -0
- package/out/constraints/props/required.js.map +1 -0
- package/out/constraints/props/sequence.d.ts +82 -0
- package/out/constraints/props/sequence.d.ts.map +1 -0
- package/out/constraints/props/sequence.js +376 -0
- package/out/constraints/props/sequence.js.map +1 -0
- package/out/constraints/props/shared.d.ts +3 -0
- package/out/constraints/props/shared.d.ts.map +1 -0
- package/out/constraints/props/shared.js +4 -0
- package/out/constraints/props/shared.js.map +1 -0
- package/out/constraints/refinements/after.d.ts +33 -0
- package/out/constraints/refinements/after.d.ts.map +1 -0
- package/out/constraints/refinements/after.js +36 -0
- package/out/constraints/refinements/after.js.map +1 -0
- package/out/constraints/refinements/before.d.ts +33 -0
- package/out/constraints/refinements/before.d.ts.map +1 -0
- package/out/constraints/refinements/before.js +43 -0
- package/out/constraints/refinements/before.js.map +1 -0
- package/out/constraints/refinements/divisor.d.ts +52 -0
- package/out/constraints/refinements/divisor.d.ts.map +1 -0
- package/out/constraints/refinements/divisor.js +52 -0
- package/out/constraints/refinements/divisor.js.map +1 -0
- package/out/constraints/refinements/exactLength.d.ts +45 -0
- package/out/constraints/refinements/exactLength.d.ts.map +1 -0
- package/out/constraints/refinements/exactLength.js +52 -0
- package/out/constraints/refinements/exactLength.js.map +1 -0
- package/out/constraints/refinements/kinds.d.ts +29 -0
- package/out/constraints/refinements/kinds.d.ts.map +1 -0
- package/out/constraints/refinements/kinds.js +17 -0
- package/out/constraints/refinements/kinds.js.map +1 -0
- package/out/constraints/refinements/length.d.ts +48 -0
- package/out/constraints/refinements/length.d.ts.map +1 -0
- package/out/constraints/refinements/length.js +53 -0
- package/out/constraints/refinements/length.js.map +1 -0
- package/out/constraints/refinements/max.d.ts +31 -0
- package/out/constraints/refinements/max.d.ts.map +1 -0
- package/out/constraints/refinements/max.js +35 -0
- package/out/constraints/refinements/max.js.map +1 -0
- package/out/constraints/refinements/maxLength.d.ts +32 -0
- package/out/constraints/refinements/maxLength.d.ts.map +1 -0
- package/out/constraints/refinements/maxLength.js +36 -0
- package/out/constraints/refinements/maxLength.js.map +1 -0
- package/out/constraints/refinements/min.d.ts +31 -0
- package/out/constraints/refinements/min.d.ts.map +1 -0
- package/out/constraints/refinements/min.js +28 -0
- package/out/constraints/refinements/min.js.map +1 -0
- package/out/constraints/refinements/minLength.d.ts +32 -0
- package/out/constraints/refinements/minLength.d.ts.map +1 -0
- package/out/constraints/refinements/minLength.js +33 -0
- package/out/constraints/refinements/minLength.js.map +1 -0
- package/out/constraints/refinements/range.d.ts +119 -0
- package/out/constraints/refinements/range.d.ts.map +1 -0
- package/out/constraints/refinements/range.js +89 -0
- package/out/constraints/refinements/range.js.map +1 -0
- package/out/constraints/refinements/regex.d.ts +47 -0
- package/out/constraints/refinements/regex.d.ts.map +1 -0
- package/out/constraints/refinements/regex.js +37 -0
- package/out/constraints/refinements/regex.js.map +1 -0
- package/out/constraints/refinements/shared.d.ts +20 -0
- package/out/constraints/refinements/shared.d.ts.map +1 -0
- package/out/constraints/refinements/shared.js +10 -0
- package/out/constraints/refinements/shared.js.map +1 -0
- package/out/generic.d.ts +22 -0
- package/out/generic.d.ts.map +1 -0
- package/out/generic.js +23 -0
- package/out/generic.js.map +1 -0
- package/out/inference.d.ts +137 -0
- package/out/inference.d.ts.map +1 -0
- package/out/inference.js +73 -0
- package/out/inference.js.map +1 -0
- package/out/keywords/ark.d.ts +70 -0
- package/out/keywords/ark.d.ts.map +1 -0
- package/out/keywords/ark.js +29 -0
- package/out/keywords/ark.js.map +1 -0
- package/out/keywords/internal.d.ts +13 -0
- package/out/keywords/internal.d.ts.map +1 -0
- package/out/keywords/internal.js +13 -0
- package/out/keywords/internal.js.map +1 -0
- package/out/keywords/jsObject.d.ts +20 -0
- package/out/keywords/jsObject.d.ts.map +1 -0
- package/out/keywords/jsObject.js +18 -0
- package/out/keywords/jsObject.js.map +1 -0
- package/out/keywords/parsing.d.ts +17 -0
- package/out/keywords/parsing.d.ts.map +1 -0
- package/out/keywords/parsing.js +64 -0
- package/out/keywords/parsing.js.map +1 -0
- package/out/keywords/root.d.ts +7 -0
- package/out/keywords/root.d.ts.map +1 -0
- package/out/keywords/root.js +4 -0
- package/out/keywords/root.js.map +1 -0
- package/out/keywords/tsGenerics.d.ts +2 -0
- package/out/keywords/tsGenerics.d.ts.map +1 -0
- package/out/keywords/tsGenerics.js +26 -0
- package/out/keywords/tsGenerics.js.map +1 -0
- package/out/keywords/tsPrimitive.d.ts +24 -0
- package/out/keywords/tsPrimitive.d.ts.map +1 -0
- package/out/keywords/tsPrimitive.js +25 -0
- package/out/keywords/tsPrimitive.js.map +1 -0
- package/out/keywords/utils/creditCard.d.ts +11 -0
- package/out/keywords/utils/creditCard.d.ts.map +1 -0
- package/out/keywords/utils/creditCard.js +35 -0
- package/out/keywords/utils/creditCard.js.map +1 -0
- package/out/keywords/utils/date.d.ts +45 -0
- package/out/keywords/utils/date.d.ts.map +1 -0
- package/out/keywords/utils/date.js +56 -0
- package/out/keywords/utils/date.js.map +1 -0
- package/out/keywords/validation.d.ts +20 -0
- package/out/keywords/validation.d.ts.map +1 -0
- package/out/keywords/validation.js +80 -0
- package/out/keywords/validation.js.map +1 -0
- package/out/kinds.d.ts +102 -0
- package/out/kinds.d.ts.map +1 -0
- package/out/kinds.js +29 -0
- package/out/kinds.js.map +1 -0
- package/out/main.d.ts +6 -6
- package/out/main.d.ts.map +1 -1
- package/out/main.js +4 -3
- package/out/main.js.map +1 -1
- package/out/match.d.ts +18 -23
- package/out/match.d.ts.map +1 -1
- package/out/match.js +3 -4
- package/out/match.js.map +1 -1
- package/out/module.d.ts +11 -0
- package/out/module.d.ts.map +1 -0
- package/out/module.js +4 -0
- package/out/module.js.map +1 -0
- package/out/parse.d.ts +29 -0
- package/out/parse.d.ts.map +1 -0
- package/out/parse.js +161 -0
- package/out/parse.js.map +1 -0
- package/out/parser/definition.d.ts +9 -12
- package/out/parser/definition.d.ts.map +1 -1
- package/out/parser/definition.js +10 -12
- package/out/parser/definition.js.map +1 -1
- package/out/parser/generic.d.ts +3 -4
- package/out/parser/generic.d.ts.map +1 -1
- package/out/parser/generic.js +6 -8
- package/out/parser/generic.js.map +1 -1
- package/out/parser/objectLiteral.d.ts +44 -12
- package/out/parser/objectLiteral.d.ts.map +1 -1
- package/out/parser/objectLiteral.js +43 -36
- package/out/parser/objectLiteral.js.map +1 -1
- package/out/parser/semantic/bounds.d.ts +9 -6
- package/out/parser/semantic/bounds.d.ts.map +1 -1
- package/out/parser/semantic/bounds.js.map +1 -1
- package/out/parser/semantic/divisor.d.ts +5 -6
- package/out/parser/semantic/divisor.d.ts.map +1 -1
- package/out/parser/semantic/infer.d.ts +25 -0
- package/out/parser/semantic/infer.d.ts.map +1 -0
- package/out/parser/semantic/infer.js +2 -0
- package/out/parser/semantic/infer.js.map +1 -0
- package/out/parser/semantic/utils.d.ts +3 -6
- package/out/parser/semantic/utils.d.ts.map +1 -1
- package/out/parser/semantic/validate.d.ts +14 -12
- package/out/parser/semantic/validate.d.ts.map +1 -1
- package/out/parser/semantic/validate.js +1 -0
- package/out/parser/semantic/validate.js.map +1 -1
- package/out/parser/string/reduce/dynamic.d.ts +13 -12
- package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
- package/out/parser/string/reduce/dynamic.js +27 -17
- package/out/parser/string/reduce/dynamic.js.map +1 -1
- package/out/parser/string/reduce/shared.d.ts +1 -2
- package/out/parser/string/reduce/shared.d.ts.map +1 -1
- package/out/parser/string/reduce/shared.js.map +1 -1
- package/out/parser/string/reduce/static.d.ts +26 -22
- package/out/parser/string/reduce/static.d.ts.map +1 -1
- package/out/parser/string/shift/operand/date.d.ts +2 -1
- package/out/parser/string/shift/operand/date.d.ts.map +1 -1
- package/out/parser/string/shift/operand/date.js +2 -2
- package/out/parser/string/shift/operand/date.js.map +1 -1
- package/out/parser/string/shift/operand/enclosed.d.ts +2 -2
- package/out/parser/string/shift/operand/enclosed.d.ts.map +1 -1
- package/out/parser/string/shift/operand/enclosed.js +6 -4
- package/out/parser/string/shift/operand/enclosed.js.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts +9 -9
- package/out/parser/string/shift/operand/genericArgs.d.ts.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.js +6 -8
- package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
- package/out/parser/string/shift/operand/operand.d.ts +3 -3
- package/out/parser/string/shift/operand/operand.d.ts.map +1 -1
- package/out/parser/string/shift/operand/operand.js +8 -11
- package/out/parser/string/shift/operand/operand.js.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts +13 -20
- package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.js +21 -26
- package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
- package/out/parser/string/shift/operator/bounds.d.ts +15 -12
- package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
- package/out/parser/string/shift/operator/bounds.js +42 -48
- package/out/parser/string/shift/operator/bounds.js.map +1 -1
- package/out/parser/string/shift/operator/divisor.d.ts +1 -2
- package/out/parser/string/shift/operator/divisor.d.ts.map +1 -1
- package/out/parser/string/shift/operator/divisor.js.map +1 -1
- package/out/parser/string/shift/operator/operator.d.ts +1 -1
- package/out/parser/string/shift/operator/operator.d.ts.map +1 -1
- package/out/parser/string/shift/operator/operator.js +12 -18
- package/out/parser/string/shift/operator/operator.js.map +1 -1
- package/out/parser/string/shift/scanner.d.ts +2 -1
- package/out/parser/string/shift/scanner.d.ts.map +1 -1
- package/out/parser/string/shift/scanner.js +12 -11
- package/out/parser/string/shift/scanner.js.map +1 -1
- package/out/parser/string/string.d.ts +8 -5
- package/out/parser/string/string.d.ts.map +1 -1
- package/out/parser/string/string.js.map +1 -1
- package/out/parser/tuple.d.ts +96 -37
- package/out/parser/tuple.d.ts.map +1 -1
- package/out/parser/tuple.js +61 -66
- package/out/parser/tuple.js.map +1 -1
- package/out/schema.d.ts +175 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +73 -0
- package/out/schema.js.map +1 -0
- package/out/schemaScope.d.ts +180 -0
- package/out/schemaScope.d.ts.map +1 -0
- package/out/schemaScope.js +235 -0
- package/out/schemaScope.js.map +1 -0
- package/out/scope.d.ts +42 -114
- package/out/scope.d.ts.map +1 -1
- package/out/scope.js +51 -181
- package/out/scope.js.map +1 -1
- package/out/shared/compile.d.ts +22 -0
- package/out/shared/compile.d.ts.map +1 -0
- package/out/shared/compile.js +79 -0
- package/out/shared/compile.js.map +1 -0
- package/out/shared/context.d.ts +54 -0
- package/out/shared/context.d.ts.map +1 -0
- package/out/shared/context.js +53 -0
- package/out/shared/context.js.map +1 -0
- package/out/shared/declare.d.ts +69 -0
- package/out/shared/declare.d.ts.map +1 -0
- package/out/shared/declare.js +2 -0
- package/out/shared/declare.js.map +1 -0
- package/out/shared/disjoint.d.ts +91 -0
- package/out/shared/disjoint.d.ts.map +1 -0
- package/out/shared/disjoint.js +110 -0
- package/out/shared/disjoint.js.map +1 -0
- package/out/shared/errors.d.ts +99 -0
- package/out/shared/errors.d.ts.map +1 -0
- package/out/shared/errors.js +108 -0
- package/out/shared/errors.js.map +1 -0
- package/out/shared/implement.d.ts +363 -0
- package/out/shared/implement.d.ts.map +1 -0
- package/out/shared/implement.js +68 -0
- package/out/shared/implement.js.map +1 -0
- package/out/shared/inference.d.ts +6 -0
- package/out/shared/inference.d.ts.map +1 -0
- package/out/shared/inference.js +5 -0
- package/out/shared/inference.js.map +1 -0
- package/out/shared/intersections.d.ts +60 -0
- package/out/shared/intersections.d.ts.map +1 -0
- package/out/shared/intersections.js +2 -0
- package/out/shared/intersections.js.map +1 -0
- package/out/shared/traversal.d.ts +62 -0
- package/out/shared/traversal.d.ts.map +1 -0
- package/out/shared/traversal.js +97 -0
- package/out/shared/traversal.js.map +1 -0
- package/out/shared/utils.d.ts +24 -0
- package/out/shared/utils.d.ts.map +1 -0
- package/out/shared/utils.js +15 -0
- package/out/shared/utils.js.map +1 -0
- package/out/type.d.ts +23 -59
- package/out/type.d.ts.map +1 -1
- package/out/type.js +2 -137
- package/out/type.js.map +1 -1
- package/out/types/basis.d.ts +47 -0
- package/out/types/basis.d.ts.map +1 -0
- package/out/types/basis.js +15 -0
- package/out/types/basis.js.map +1 -0
- package/out/types/discriminate.d.ts +34 -0
- package/out/types/discriminate.d.ts.map +1 -0
- package/out/types/discriminate.js +120 -0
- package/out/types/discriminate.js.map +1 -0
- package/out/types/domain.d.ts +57 -0
- package/out/types/domain.d.ts.map +1 -0
- package/out/types/domain.js +41 -0
- package/out/types/domain.js.map +1 -0
- package/out/types/intersection.d.ts +127 -0
- package/out/types/intersection.d.ts.map +1 -0
- package/out/types/intersection.js +379 -0
- package/out/types/intersection.js.map +1 -0
- package/out/types/morph.d.ts +157 -0
- package/out/types/morph.d.ts.map +1 -0
- package/out/types/morph.js +99 -0
- package/out/types/morph.js.map +1 -0
- package/out/types/proto.d.ts +51 -0
- package/out/types/proto.d.ts.map +1 -0
- package/out/types/proto.js +60 -0
- package/out/types/proto.js.map +1 -0
- package/out/types/type.d.ts +143 -0
- package/out/types/type.d.ts.map +1 -0
- package/out/types/type.js +123 -0
- package/out/types/type.js.map +1 -0
- package/out/types/union.d.ts +71 -0
- package/out/types/union.d.ts.map +1 -0
- package/out/types/union.js +379 -0
- package/out/types/union.js.map +1 -0
- package/out/types/unit.d.ts +45 -0
- package/out/types/unit.d.ts.map +1 -0
- package/out/types/unit.js +56 -0
- package/out/types/unit.js.map +1 -0
- package/out/util.d.ts +30 -18
- package/out/util.d.ts.map +1 -1
- package/out/util.js +8 -7
- package/out/util.js.map +1 -1
- package/package.json +7 -3
- package/parser/definition.ts +73 -89
- package/parser/generic.ts +35 -36
- package/parser/objectLiteral.ts +143 -117
- package/parser/semantic/bounds.ts +33 -32
- package/parser/semantic/divisor.ts +8 -10
- package/parser/semantic/infer.ts +141 -0
- package/parser/semantic/utils.ts +12 -23
- package/parser/semantic/validate.ts +82 -73
- package/parser/string/reduce/dynamic.ts +61 -46
- package/parser/string/reduce/shared.ts +1 -3
- package/parser/string/reduce/static.ts +65 -67
- package/parser/string/shift/operand/date.ts +12 -8
- package/parser/string/shift/operand/enclosed.ts +22 -17
- package/parser/string/shift/operand/genericArgs.ts +46 -45
- package/parser/string/shift/operand/operand.ts +32 -38
- package/parser/string/shift/operand/unenclosed.ts +106 -147
- package/parser/string/shift/operator/bounds.ts +114 -106
- package/parser/string/shift/operator/divisor.ts +12 -14
- package/parser/string/shift/operator/operator.ts +35 -46
- package/parser/string/shift/scanner.ts +49 -46
- package/parser/string/string.ts +28 -32
- package/parser/tuple.ts +288 -308
- package/scope.ts +183 -425
- package/type.ts +82 -281
- package/__tests__/astUtils.test.ts +0 -17
- package/__tests__/jsdoc.test.ts +0 -64
- package/__tests__/nodeDefinitions.test.ts +0 -190
- package/__tests__/typeMethods.test.ts +0 -69
- package/out/arkConfig.d.ts +0 -2
- package/out/arkConfig.d.ts.map +0 -1
- package/out/arkConfig.js +0 -10
- package/out/arkConfig.js.map +0 -1
- package/out/parser/semantic/intersections.d.ts +0 -14
- package/out/parser/semantic/intersections.d.ts.map +0 -1
- package/out/parser/semantic/intersections.js +0 -2
- package/out/parser/semantic/intersections.js.map +0 -1
- package/out/parser/semantic/semantic.d.ts +0 -32
- package/out/parser/semantic/semantic.d.ts.map +0 -1
- package/out/parser/semantic/semantic.js +0 -2
- package/out/parser/semantic/semantic.js.map +0 -1
- package/out/parser/shared.d.ts +0 -62
- package/out/parser/shared.d.ts.map +0 -1
- package/out/parser/shared.js +0 -56
- package/out/parser/shared.js.map +0 -1
- package/out/test.d.ts +0 -2
- package/out/test.d.ts.map +0 -1
- package/out/test.js +0 -7
- package/out/test.js.map +0 -1
- package/out/tsconfig.build.tsbuildinfo +0 -1
- package/parser/semantic/semantic.ts +0 -143
- package/parser/shared.ts +0 -170
- package/util.ts +0 -36
package/out/parser/tuple.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { append,
|
|
3
|
-
import { writeUnsatisfiableExpressionError } from "./semantic/validate.js";
|
|
4
|
-
import { configureShallowDescendants, parseEntryValue } from "./shared.js";
|
|
1
|
+
import { jsObjects, makeRootAndArrayPropertiesMutable, tsKeywords } from "@arktype/schema";
|
|
2
|
+
import { append, objectKindOrDomainOf, throwParseError } from "@arktype/util";
|
|
5
3
|
import { writeMissingRightOperandMessage } from "./string/shift/operand/unenclosed.js";
|
|
6
4
|
export const parseTuple = (def, ctx) => maybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx);
|
|
7
5
|
export const parseTupleLiteral = (def, ctx) => {
|
|
8
6
|
let sequences = [{}];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
7
|
+
let i = 0;
|
|
8
|
+
while (i < def.length) {
|
|
9
|
+
let spread = false;
|
|
10
|
+
let optional = false;
|
|
11
|
+
if (def[i] === "..." && i < def.length - 1) {
|
|
12
|
+
spread = true;
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
const element = ctx.$.parse(def[i], ctx);
|
|
16
|
+
i++;
|
|
17
|
+
if (def[i] === "?") {
|
|
18
|
+
if (spread) {
|
|
15
19
|
return throwParseError(spreadOptionalMessage);
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
optional = true;
|
|
22
|
+
i++;
|
|
23
|
+
}
|
|
24
|
+
if (spread) {
|
|
25
|
+
if (!element.extends(jsObjects.Array)) {
|
|
26
|
+
return throwParseError(writeNonArraySpreadMessage(element.expression));
|
|
19
27
|
}
|
|
20
28
|
// a spread must be distributed over branches e.g.:
|
|
21
29
|
// def: [string, ...(number[] | [true, false])]
|
|
@@ -25,19 +33,18 @@ export const parseTupleLiteral = (def, ctx) => {
|
|
|
25
33
|
element.branches.map((branch) => appendSpreadBranch(makeRootAndArrayPropertiesMutable(base), branch)));
|
|
26
34
|
}
|
|
27
35
|
else {
|
|
28
|
-
sequences = sequences.map((base) => appendElement(base,
|
|
36
|
+
sequences = sequences.map((base) => appendElement(base, optional ? "optional" : "required", element));
|
|
29
37
|
}
|
|
30
|
-
ctx.path.pop();
|
|
31
38
|
}
|
|
32
|
-
return schema(
|
|
33
|
-
|
|
39
|
+
return ctx.$.raw.schema(sequences.map((sequence) => ({
|
|
40
|
+
proto: Array,
|
|
34
41
|
sequence
|
|
35
42
|
})));
|
|
36
43
|
};
|
|
37
44
|
const appendElement = (base, kind, element) => {
|
|
38
45
|
switch (kind) {
|
|
39
46
|
case "required":
|
|
40
|
-
if (base.
|
|
47
|
+
if (base.optional)
|
|
41
48
|
// e.g. [string?, number]
|
|
42
49
|
return throwParseError(requiredPostOptionalMessage);
|
|
43
50
|
if (base.variadic) {
|
|
@@ -54,7 +61,7 @@ const appendElement = (base, kind, element) => {
|
|
|
54
61
|
// e.g. [...string[], number?]
|
|
55
62
|
return throwParseError(optionalPostVariadicMessage);
|
|
56
63
|
// e.g. [string, number?]
|
|
57
|
-
base.
|
|
64
|
+
base.optional = append(base.optional, element);
|
|
58
65
|
return base;
|
|
59
66
|
case "variadic":
|
|
60
67
|
// e.g. [...string[], number, ...string[]]
|
|
@@ -70,7 +77,7 @@ const appendElement = (base, kind, element) => {
|
|
|
70
77
|
}
|
|
71
78
|
else {
|
|
72
79
|
// e.g. [string, ...number[]]
|
|
73
|
-
base.variadic = element;
|
|
80
|
+
base.variadic = element.raw;
|
|
74
81
|
}
|
|
75
82
|
return base;
|
|
76
83
|
}
|
|
@@ -79,77 +86,63 @@ const appendSpreadBranch = (base, branch) => {
|
|
|
79
86
|
const spread = branch.firstReferenceOfKind("sequence");
|
|
80
87
|
if (!spread) {
|
|
81
88
|
// the only array with no sequence reference is unknown[]
|
|
82
|
-
return appendElement(base, "variadic",
|
|
89
|
+
return appendElement(base, "variadic", tsKeywords.unknown);
|
|
83
90
|
}
|
|
84
91
|
spread.prefix.forEach((node) => appendElement(base, "required", node));
|
|
85
|
-
spread.
|
|
92
|
+
spread.optional.forEach((node) => appendElement(base, "optional", node));
|
|
86
93
|
spread.variadic && appendElement(base, "variadic", spread.variadic);
|
|
87
94
|
spread.postfix.forEach((node) => appendElement(base, "required", node));
|
|
88
95
|
return base;
|
|
89
96
|
};
|
|
90
|
-
const parseSpreadable = (elementDef) => {
|
|
91
|
-
if (typeof elementDef === "string" && elementDef.startsWith("...")) {
|
|
92
|
-
// variadic string definition like "...string[]"
|
|
93
|
-
return { ...parseEntryValue(elementDef.slice(3)), spread: true };
|
|
94
|
-
}
|
|
95
|
-
if (isArray(elementDef) &&
|
|
96
|
-
elementDef.length === 2 &&
|
|
97
|
-
elementDef[0] === "...") {
|
|
98
|
-
// variadic tuple expression like ["...", { a: "1" }]
|
|
99
|
-
return { ...parseEntryValue(elementDef[1]), spread: true };
|
|
100
|
-
}
|
|
101
|
-
return parseEntryValue(elementDef);
|
|
102
|
-
};
|
|
103
97
|
const maybeParseTupleExpression = (def, ctx) => {
|
|
104
|
-
const tupleExpressionResult =
|
|
105
|
-
? indexOneParsers[def[1]](def, ctx)
|
|
106
|
-
: isIndexZeroExpression(def)
|
|
107
|
-
? prefixParsers[def[0]](def, ctx)
|
|
98
|
+
const tupleExpressionResult = isIndexZeroExpression(def) ? prefixParsers[def[0]](def, ctx)
|
|
99
|
+
: isIndexOneExpression(def) ? indexOneParsers[def[1]](def, ctx)
|
|
108
100
|
: undefined;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
return tupleExpressionResult;
|
|
102
|
+
// TODO: remove
|
|
103
|
+
// return tupleExpressionResult.isNever()
|
|
104
|
+
// ? throwParseError(
|
|
105
|
+
// writeUnsatisfiableExpressionError(
|
|
106
|
+
// def
|
|
107
|
+
// .map((def) =>
|
|
108
|
+
// typeof def === "string" ? def : printable(def)
|
|
109
|
+
// )
|
|
110
|
+
// .join(" ")
|
|
111
|
+
// )
|
|
112
|
+
// )
|
|
113
|
+
// : tupleExpressionResult
|
|
116
114
|
};
|
|
117
115
|
export const writeNonArraySpreadMessage = (operand) => `Spread element must be an array (was ${operand})`;
|
|
118
|
-
export const multipleVariadicMesage =
|
|
119
|
-
export const requiredPostOptionalMessage =
|
|
120
|
-
export const optionalPostVariadicMessage =
|
|
121
|
-
export const spreadOptionalMessage =
|
|
122
|
-
export const parseKeyOfTuple = (def, ctx) => ctx
|
|
116
|
+
export const multipleVariadicMesage = "A tuple may have at most one variadic element";
|
|
117
|
+
export const requiredPostOptionalMessage = "A required element may not follow an optional element";
|
|
118
|
+
export const optionalPostVariadicMessage = "An optional element may not follow a variadic element";
|
|
119
|
+
export const spreadOptionalMessage = "A spread element cannot be optional";
|
|
120
|
+
export const parseKeyOfTuple = (def, ctx) => ctx.$.parse(def[1], ctx).keyof();
|
|
123
121
|
const parseBranchTuple = (def, ctx) => {
|
|
124
122
|
if (def[2] === undefined) {
|
|
125
123
|
return throwParseError(writeMissingRightOperandMessage(def[1], ""));
|
|
126
124
|
}
|
|
127
|
-
const l = ctx
|
|
128
|
-
const r = ctx
|
|
125
|
+
const l = ctx.$.parse(def[0], ctx);
|
|
126
|
+
const r = ctx.$.parse(def[2], ctx);
|
|
129
127
|
return def[1] === "&" ? l.and(r) : l.or(r);
|
|
130
128
|
};
|
|
131
|
-
const parseArrayTuple = (def, ctx) => ctx
|
|
129
|
+
const parseArrayTuple = (def, ctx) => ctx.$.parse(def[0], ctx).array();
|
|
132
130
|
const isIndexOneExpression = (def) => indexOneParsers[def[1]] !== undefined;
|
|
133
131
|
export const parseMorphTuple = (def, ctx) => {
|
|
134
132
|
if (typeof def[2] !== "function") {
|
|
135
133
|
return throwParseError(writeMalformedFunctionalExpressionMessage("=>", def[2]));
|
|
136
134
|
}
|
|
137
135
|
// TODO: nested morphs?
|
|
138
|
-
return
|
|
139
|
-
in: ctx.scope.parse(def[0], ctx),
|
|
140
|
-
morph: def[2]
|
|
141
|
-
});
|
|
136
|
+
return ctx.$.parse(def[0], ctx).morph(def[2]);
|
|
142
137
|
};
|
|
143
138
|
export const writeMalformedFunctionalExpressionMessage = (operator, value) => `${operator === ":" ? "Narrow" : "Morph"} expression requires a function following '${operator}' (was ${typeof value})`;
|
|
144
139
|
export const parseNarrowTuple = (def, ctx) => {
|
|
145
140
|
if (typeof def[2] !== "function") {
|
|
146
141
|
return throwParseError(writeMalformedFunctionalExpressionMessage(":", def[2]));
|
|
147
142
|
}
|
|
148
|
-
return ctx.
|
|
149
|
-
.parse(def[0], ctx)
|
|
150
|
-
.constrain("predicate", def[2]);
|
|
143
|
+
return ctx.$.parse(def[0], ctx).constrain("predicate", def[2]);
|
|
151
144
|
};
|
|
152
|
-
const parseAttributeTuple = (def, ctx) =>
|
|
145
|
+
const parseAttributeTuple = (def, ctx) => ctx.$.parse(def[0], ctx).configureShallowDescendants(def[2]);
|
|
153
146
|
const indexOneParsers = {
|
|
154
147
|
"|": parseBranchTuple,
|
|
155
148
|
"&": parseBranchTuple,
|
|
@@ -160,18 +153,20 @@ const indexOneParsers = {
|
|
|
160
153
|
};
|
|
161
154
|
const prefixParsers = {
|
|
162
155
|
keyof: parseKeyOfTuple,
|
|
163
|
-
instanceof: (def) => {
|
|
156
|
+
instanceof: (def, ctx) => {
|
|
164
157
|
if (typeof def[1] !== "function") {
|
|
165
158
|
return throwParseError(writeInvalidConstructorMessage(objectKindOrDomainOf(def[1])));
|
|
166
159
|
}
|
|
167
160
|
const branches = def
|
|
168
161
|
.slice(1)
|
|
169
|
-
.map((ctor) => typeof ctor === "function"
|
|
170
|
-
|
|
162
|
+
.map((ctor) => typeof ctor === "function" ?
|
|
163
|
+
ctx.$.node("proto", { proto: ctor })
|
|
171
164
|
: throwParseError(writeInvalidConstructorMessage(objectKindOrDomainOf(ctor))));
|
|
172
|
-
return
|
|
165
|
+
return branches.length === 1 ?
|
|
166
|
+
branches[0]
|
|
167
|
+
: ctx.$.node("union", { branches });
|
|
173
168
|
},
|
|
174
|
-
"===": (def) =>
|
|
169
|
+
"===": (def, ctx) => ctx.$.units(def.slice(1))
|
|
175
170
|
};
|
|
176
171
|
const isIndexZeroExpression = (def) => prefixParsers[def[0]] !== undefined;
|
|
177
172
|
export const writeInvalidConstructorMessage = (actual) => `Expected a constructor following 'instanceof' operator (was ${actual})`;
|
package/out/parser/tuple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../parser/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../parser/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EAeN,SAAS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AAC,MAAM,8BAA8B,GAAG,CAG7C,MAAc,EACb,EAAE,CACH,+DAA+D,MAAM,GAAY,CAAA"}
|
package/out/schema.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Constructor,
|
|
3
|
+
ErrorMessage,
|
|
4
|
+
NonEnumerableDomain,
|
|
5
|
+
array,
|
|
6
|
+
conform,
|
|
7
|
+
describe,
|
|
8
|
+
inferDomain,
|
|
9
|
+
instanceOf,
|
|
10
|
+
isAny
|
|
11
|
+
} from "@arktype/util"
|
|
12
|
+
import type { Node, TypeSchema, UnknownNode } from "./base.js"
|
|
13
|
+
import type { Prerequisite, Schema, reducibleKindOf } from "./kinds.js"
|
|
14
|
+
import type { SchemaParseOptions } from "./parse.js"
|
|
15
|
+
import type { BasisKind, ConstraintKind, NodeKind } from "./shared/implement.js"
|
|
16
|
+
import type { DomainNode, DomainSchema } from "./types/domain.js"
|
|
17
|
+
import type {
|
|
18
|
+
IntersectionNode,
|
|
19
|
+
IntersectionSchema
|
|
20
|
+
} from "./types/intersection.js"
|
|
21
|
+
import type {
|
|
22
|
+
Morph,
|
|
23
|
+
MorphChildDefinition,
|
|
24
|
+
MorphChildKind,
|
|
25
|
+
MorphNode,
|
|
26
|
+
MorphSchema,
|
|
27
|
+
Out,
|
|
28
|
+
inferMorphOut
|
|
29
|
+
} from "./types/morph.js"
|
|
30
|
+
import type { ProtoNode, ProtoSchema } from "./types/proto.js"
|
|
31
|
+
import type {
|
|
32
|
+
NormalizedUnionSchema,
|
|
33
|
+
UnionChildNode,
|
|
34
|
+
UnionNode,
|
|
35
|
+
UnionSchema
|
|
36
|
+
} from "./types/union.js"
|
|
37
|
+
import type { UnitNode, UnitSchema } from "./types/unit.js"
|
|
38
|
+
export type SchemaParser<$> = <const schema>(
|
|
39
|
+
schema: validateSchema<schema, $>
|
|
40
|
+
) => ["schema", schema]
|
|
41
|
+
export type NodeParser<$> = {
|
|
42
|
+
<kind extends NodeKind, const schema extends Schema<kind>>(
|
|
43
|
+
kind: kind,
|
|
44
|
+
schema: schema,
|
|
45
|
+
opts?: SchemaParseOptions
|
|
46
|
+
): Node<reducibleKindOf<kind>, instantiateSchema<schema, $>["infer"], $>
|
|
47
|
+
<const schema extends TypeSchema>(
|
|
48
|
+
schema: schema,
|
|
49
|
+
opts?: SchemaParseOptions
|
|
50
|
+
): instantiateSchema<schema, $>
|
|
51
|
+
}
|
|
52
|
+
export type validateSchema<schema, $> = schema extends UnknownNode
|
|
53
|
+
? schema
|
|
54
|
+
: schema extends array
|
|
55
|
+
? {
|
|
56
|
+
[i in keyof schema]: validateSchemaBranch<schema[i], $>
|
|
57
|
+
}
|
|
58
|
+
: schema extends NormalizedUnionSchema<infer branches>
|
|
59
|
+
? conform<
|
|
60
|
+
schema,
|
|
61
|
+
NormalizedUnionSchema & {
|
|
62
|
+
branches: {
|
|
63
|
+
[i in keyof branches]: validateSchemaBranch<
|
|
64
|
+
branches[i],
|
|
65
|
+
$
|
|
66
|
+
>
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
>
|
|
70
|
+
: validateSchemaBranch<schema, $>
|
|
71
|
+
export type instantiateSchema<schema, $> = schema extends UnionSchema<
|
|
72
|
+
infer branches
|
|
73
|
+
>
|
|
74
|
+
? branches["length"] extends 0
|
|
75
|
+
? UnionNode<never, "union">
|
|
76
|
+
: branches["length"] extends 1
|
|
77
|
+
? instantiateSchemaBranch<branches[0], $>
|
|
78
|
+
: Node<
|
|
79
|
+
reducibleKindOf<"union">,
|
|
80
|
+
instantiateSchemaBranch<branches[number], $>["infer"]
|
|
81
|
+
>
|
|
82
|
+
: instantiateSchemaBranch<schema, $>
|
|
83
|
+
type validateSchemaBranch<schema, $> = schema extends UnknownNode
|
|
84
|
+
? schema
|
|
85
|
+
: keyof schema & ("morph" | "in" | "out") extends never
|
|
86
|
+
? validateMorphChild<schema, $>
|
|
87
|
+
: validateMorphSchema<schema, $>
|
|
88
|
+
type instantiateSchemaBranch<schema, $> = schema extends UnknownNode
|
|
89
|
+
? schema
|
|
90
|
+
: schema extends MorphSchema
|
|
91
|
+
? instantiateMorphSchema<schema, $>
|
|
92
|
+
: schema extends MorphChildDefinition
|
|
93
|
+
? instantiateMorphChild<schema, $>
|
|
94
|
+
: UnionChildNode
|
|
95
|
+
type NonIntersectableBasisSchema =
|
|
96
|
+
| NonEnumerableDomain
|
|
97
|
+
| Constructor
|
|
98
|
+
| UnitSchema
|
|
99
|
+
type validateMorphChild<schema, $> = [schema] extends [
|
|
100
|
+
NonIntersectableBasisSchema
|
|
101
|
+
]
|
|
102
|
+
? schema
|
|
103
|
+
: validateIntersectionSchema<schema, $>
|
|
104
|
+
type instantiateMorphChild<schema, $> =
|
|
105
|
+
schema extends NonIntersectableBasisSchema
|
|
106
|
+
? instantiateBasis<schema, $>
|
|
107
|
+
: schema extends IntersectionSchema
|
|
108
|
+
? instantiateIntersectionSchema<schema, $>
|
|
109
|
+
: Node<MorphChildKind>
|
|
110
|
+
type validateMorphSchema<def, $> = {
|
|
111
|
+
[k in keyof def]: k extends "in" | "out"
|
|
112
|
+
? validateMorphChild<def[k], $>
|
|
113
|
+
: k extends keyof MorphSchema
|
|
114
|
+
? MorphSchema[k]
|
|
115
|
+
: `'${k & string}' is not a valid morph schema key`
|
|
116
|
+
}
|
|
117
|
+
type instantiateMorphSchema<schema, $> = schema extends MorphSchema
|
|
118
|
+
? MorphNode<
|
|
119
|
+
(
|
|
120
|
+
In: schema["in"] extends {}
|
|
121
|
+
? instantiateMorphChild<schema["in"], $>["infer"]
|
|
122
|
+
: unknown
|
|
123
|
+
) => schema["out"] extends {}
|
|
124
|
+
? Out<instantiateMorphChild<schema["out"], $>["infer"]>
|
|
125
|
+
: schema["morphs"] extends
|
|
126
|
+
| Morph<any, infer o>
|
|
127
|
+
| readonly [...unknown[], Morph<any, infer o>]
|
|
128
|
+
? Out<inferMorphOut<o>>
|
|
129
|
+
: never
|
|
130
|
+
>
|
|
131
|
+
: never
|
|
132
|
+
type exactBasisMessageOnError<schema, expected> = {
|
|
133
|
+
[k in keyof schema]: k extends keyof expected
|
|
134
|
+
? conform<schema[k], expected[k]>
|
|
135
|
+
: ErrorMessage<
|
|
136
|
+
k extends ConstraintKind
|
|
137
|
+
? `${k} has a prerequisite of ${describe<Prerequisite<k>>}`
|
|
138
|
+
: `'${k & string}' is not on an intersection schema`
|
|
139
|
+
>
|
|
140
|
+
}
|
|
141
|
+
export type validateIntersectionSchema<schema, $> = exactBasisMessageOnError<
|
|
142
|
+
schema,
|
|
143
|
+
IntersectionSchema<inferBasisOf<schema, $>>
|
|
144
|
+
>
|
|
145
|
+
type inferBasisOf<schema, $> = "proto" extends keyof schema
|
|
146
|
+
? instantiateBasis<conform<schema["proto"], ProtoSchema>, $>["infer"]
|
|
147
|
+
: "domain" extends keyof schema
|
|
148
|
+
? instantiateBasis<conform<schema["domain"], DomainSchema>, $>["infer"]
|
|
149
|
+
: unknown
|
|
150
|
+
export type instantiateIntersectionSchema<schema, $> = keyof schema &
|
|
151
|
+
ConstraintKind extends never
|
|
152
|
+
? "proto" extends keyof schema
|
|
153
|
+
? ProtoNode<inferBasisOf<schema, $>, $>
|
|
154
|
+
: "domain" extends keyof schema
|
|
155
|
+
? DomainNode<inferBasisOf<schema, $>, $>
|
|
156
|
+
: IntersectionNode
|
|
157
|
+
: IntersectionNode<inferBasisOf<schema, $>, $>
|
|
158
|
+
export type instantiateBasis<
|
|
159
|
+
schema extends Schema<BasisKind>,
|
|
160
|
+
$
|
|
161
|
+
> = isAny<schema> extends true
|
|
162
|
+
? any
|
|
163
|
+
: schema extends NonEnumerableDomain
|
|
164
|
+
? DomainNode<inferDomain<schema>, $>
|
|
165
|
+
: schema extends Constructor<infer instance>
|
|
166
|
+
? ProtoNode<instance, $>
|
|
167
|
+
: schema extends DomainSchema<infer domain>
|
|
168
|
+
? DomainNode<inferDomain<domain>, $>
|
|
169
|
+
: schema extends ProtoSchema<infer proto>
|
|
170
|
+
? ProtoNode<instanceOf<proto>, $>
|
|
171
|
+
: schema extends UnitSchema<infer is>
|
|
172
|
+
? UnitNode<is, $>
|
|
173
|
+
: never
|
|
174
|
+
export {}
|
|
175
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACX,KAAK,EACL,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,WAAW,EACX,GAAG,EACH,aAAa,EACb,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,KAAK,EACX,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,WAAW,EACX,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE3D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC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,CAAC,MAAM,QAAQ,CAAC,GAC1C,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,GACtB,MAAM,SAAS,YAAY,CAAC,MAAM,MAAM,CAAC,GACzC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAClC,MAAM,SAAS,WAAW,CAAC,MAAM,KAAK,CAAC,GACvC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAC/B,MAAM,SAAS,UAAU,CAAC,MAAM,EAAE,CAAC,GACnC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,GACf,KAAK,CAAA"}
|
package/out/schema.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
// export type inferPropsInput<input extends PropsInput> =
|
|
3
|
+
// input extends PropsInputTuple<infer named, infer indexed>
|
|
4
|
+
// ? inferIndexed<indexed, inferNamedProps<named, indexed>>
|
|
5
|
+
// : input extends NamedPropsInput
|
|
6
|
+
// ? inferNamedProps<input, []>
|
|
7
|
+
// : never
|
|
8
|
+
// type inferIndexed<
|
|
9
|
+
// indexed extends readonly IndexedPropInput[],
|
|
10
|
+
// result = unknown
|
|
11
|
+
// > = indexed extends readonly [
|
|
12
|
+
// infer entry extends IndexedPropInput,
|
|
13
|
+
// ...infer tail extends IndexedPropInput[]
|
|
14
|
+
// ]
|
|
15
|
+
// ? inferIndexed<
|
|
16
|
+
// tail,
|
|
17
|
+
// entry["key"] extends { readonly regex: VariadicIndexMatcherLiteral }
|
|
18
|
+
// ? result extends List
|
|
19
|
+
// ? [...result, ...inferTypeInput<entry["value"]>[]]
|
|
20
|
+
// : never
|
|
21
|
+
// : entry["key"] extends {
|
|
22
|
+
// readonly regex: NonVariadicIndexMatcherLiteral
|
|
23
|
+
// }
|
|
24
|
+
// ? inferTypeInput<entry["value"]>[]
|
|
25
|
+
// : Record<
|
|
26
|
+
// Extract<inferTypeInput<entry["key"]>, PropertyKey>,
|
|
27
|
+
// inferTypeInput<entry["value"]>
|
|
28
|
+
// >
|
|
29
|
+
// >
|
|
30
|
+
// : result
|
|
31
|
+
// type inferNamedProps<
|
|
32
|
+
// named extends NamedPropsInput,
|
|
33
|
+
// indexed extends readonly IndexedPropInput[]
|
|
34
|
+
// > = [named, indexed[0]["key"]] extends
|
|
35
|
+
// | [TupleLengthProps, unknown]
|
|
36
|
+
// | [unknown, { readonly regex: VariadicIndexMatcherLiteral }]
|
|
37
|
+
// ? inferNonVariadicTupleProps<named> &
|
|
38
|
+
// inferObjectLiteralProps<Omit<named, "length" | NumberLiteral | number>>
|
|
39
|
+
// : inferObjectLiteralProps<named>
|
|
40
|
+
// type inferObjectLiteralProps<named extends NamedPropsInput> = {} extends named
|
|
41
|
+
// ? unknown
|
|
42
|
+
// : evaluate<
|
|
43
|
+
// {
|
|
44
|
+
// [k in requiredKeyOf<named>]: inferPropValue<named[k]["value"]>
|
|
45
|
+
// } & {
|
|
46
|
+
// [k in optionalKeyOf<named>]?: inferPropValue<named[k]["value"]>
|
|
47
|
+
// }
|
|
48
|
+
// >
|
|
49
|
+
// type inferPropValue<value extends PropValueInput> = value extends Thunk<
|
|
50
|
+
// infer ret
|
|
51
|
+
// >
|
|
52
|
+
// ? inferResolvedPropValue<ret>
|
|
53
|
+
// : inferResolvedPropValue<value>
|
|
54
|
+
// type inferResolvedPropValue<value> = value extends TypeNode<infer t>
|
|
55
|
+
// ? t
|
|
56
|
+
// : inferTypeInput<Extract<value, TypeInput>>
|
|
57
|
+
// type stringifiedNumericKeyOf<t> = `${Extract<keyof t, number | NumberLiteral>}`
|
|
58
|
+
// type inferNonVariadicTupleProps<
|
|
59
|
+
// named extends NamedPropsInput,
|
|
60
|
+
// result extends unknown[] = []
|
|
61
|
+
// > = `${result["length"]}` extends stringifiedNumericKeyOf<named>
|
|
62
|
+
// ? inferNonVariadicTupleProps<
|
|
63
|
+
// named,
|
|
64
|
+
// [...result, inferPropValue<named[`${result["length"]}`]["value"]>]
|
|
65
|
+
// >
|
|
66
|
+
// : result
|
|
67
|
+
// type TupleLengthProps<length extends number = number> = {
|
|
68
|
+
// readonly length: {
|
|
69
|
+
// readonly prerequisite: true
|
|
70
|
+
// readonly value: { readonly basis: readonly ["===", length] }
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":";AAwLA,0DAA0D;AAC1D,6DAA6D;AAC7D,6DAA6D;AAC7D,oCAAoC;AACpC,iCAAiC;AACjC,YAAY;AAEZ,qBAAqB;AACrB,gDAAgD;AAChD,oBAAoB;AACpB,iCAAiC;AACjC,yCAAyC;AACzC,4CAA4C;AAC5C,IAAI;AACJ,mBAAmB;AACnB,WAAW;AACX,0EAA0E;AAC1E,4BAA4B;AAC5B,0DAA0D;AAC1D,eAAe;AACf,+BAA+B;AAC/B,uDAAuD;AACvD,UAAU;AACV,yCAAyC;AACzC,gBAAgB;AAChB,4DAA4D;AAC5D,uCAAuC;AACvC,UAAU;AACV,OAAO;AACP,YAAY;AAEZ,wBAAwB;AACxB,kCAAkC;AAClC,+CAA+C;AAC/C,yCAAyC;AACzC,iCAAiC;AACjC,gEAAgE;AAChE,yCAAyC;AACzC,6EAA6E;AAC7E,oCAAoC;AAEpC,iFAAiF;AACjF,aAAa;AACb,eAAe;AACf,OAAO;AACP,qEAAqE;AACrE,WAAW;AACX,sEAAsE;AACtE,OAAO;AACP,OAAO;AAEP,2EAA2E;AAC3E,aAAa;AACb,IAAI;AACJ,iCAAiC;AACjC,mCAAmC;AAEnC,uEAAuE;AACvE,OAAO;AACP,+CAA+C;AAE/C,kFAAkF;AAElF,mCAAmC;AACnC,kCAAkC;AAClC,iCAAiC;AACjC,mEAAmE;AACnE,iCAAiC;AACjC,YAAY;AACZ,wEAAwE;AACxE,OAAO;AACP,YAAY;AAEZ,4DAA4D;AAC5D,sBAAsB;AACtB,gCAAgC;AAChC,iEAAiE;AACjE,KAAK;AACL,IAAI"}
|