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
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ErrorMessage } from "@arktype/util"
|
|
1
|
+
import type { LimitLiteral, writeUnboundableMessage } from "@arktype/schema"
|
|
2
|
+
import type { ErrorMessage, array } from "@arktype/util"
|
|
3
3
|
import type {
|
|
4
4
|
Comparator,
|
|
5
|
-
InvertedComparators
|
|
6
|
-
LimitLiteral
|
|
5
|
+
InvertedComparators
|
|
7
6
|
} from "../string/reduce/shared.js"
|
|
8
7
|
import type {
|
|
9
8
|
BoundExpressionKind,
|
|
10
|
-
writeInvalidLimitMessage
|
|
11
|
-
writeUnboundableMessage
|
|
9
|
+
writeInvalidLimitMessage
|
|
12
10
|
} from "../string/shift/operator/bounds.js"
|
|
13
|
-
import type {
|
|
11
|
+
import type { inferAstIn } from "./infer.js"
|
|
14
12
|
import type { astToString } from "./utils.js"
|
|
15
13
|
import type { validateAst } from "./validate.js"
|
|
16
14
|
|
|
17
|
-
export type validateRange<
|
|
18
|
-
l
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
args
|
|
23
|
-
> = l extends LimitLiteral
|
|
24
|
-
? validateBound<r, InvertedComparators[comparator], l, "left", $, args>
|
|
25
|
-
: l extends [infer leftAst, Comparator, unknown]
|
|
26
|
-
? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>>
|
|
27
|
-
: validateBound<l, comparator, r & LimitLiteral, "right", $, args>
|
|
15
|
+
export type validateRange<l, comparator extends Comparator, r, $, args> =
|
|
16
|
+
l extends LimitLiteral ?
|
|
17
|
+
validateBound<r, InvertedComparators[comparator], l, "left", $, args>
|
|
18
|
+
: l extends [infer leftAst, Comparator, unknown] ?
|
|
19
|
+
ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>>
|
|
20
|
+
: validateBound<l, comparator, r & LimitLiteral, "right", $, args>
|
|
28
21
|
|
|
29
22
|
export type validateBound<
|
|
30
23
|
boundedAst,
|
|
@@ -33,24 +26,32 @@ export type validateBound<
|
|
|
33
26
|
boundKind extends BoundExpressionKind,
|
|
34
27
|
$,
|
|
35
28
|
args
|
|
36
|
-
> =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
> =
|
|
30
|
+
inferAstIn<boundedAst, $, args> extends infer bounded ?
|
|
31
|
+
isNumericallyBoundable<bounded> extends true ?
|
|
32
|
+
limit extends number ?
|
|
33
|
+
validateAst<boundedAst, $, args>
|
|
34
|
+
: ErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>>
|
|
35
|
+
: bounded extends Date ?
|
|
36
|
+
// allow numeric or date literal as a Date limit
|
|
37
|
+
validateAst<boundedAst, $, args>
|
|
38
|
+
: ErrorMessage<
|
|
45
39
|
writeUnboundableMessage<
|
|
46
40
|
astToString<
|
|
47
|
-
boundKind extends "left"
|
|
48
|
-
|
|
49
|
-
: boundedAst
|
|
41
|
+
boundKind extends "left" ? boundedAst[0 & keyof boundedAst]
|
|
42
|
+
: boundedAst
|
|
50
43
|
>
|
|
51
44
|
>
|
|
52
|
-
|
|
53
|
-
:
|
|
45
|
+
>
|
|
46
|
+
: never
|
|
47
|
+
|
|
48
|
+
// Check each numerically boundable type individually so an expression comprised
|
|
49
|
+
// of mixed bound kinds like (string|number)<5 isn't allowed
|
|
50
|
+
type isNumericallyBoundable<bounded> =
|
|
51
|
+
[bounded] extends [number] ? true
|
|
52
|
+
: [bounded] extends [string] ? true
|
|
53
|
+
: [bounded] extends [array] ? true
|
|
54
|
+
: false
|
|
54
55
|
|
|
55
56
|
export const writeDoubleRightBoundMessage = <root extends string>(
|
|
56
57
|
root: root
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { writeIndivisibleMessage } from "@arktype/schema"
|
|
1
|
+
import type { Schema, writeIndivisibleMessage } from "@arktype/schema"
|
|
2
2
|
import type { ErrorMessage } from "@arktype/util"
|
|
3
|
-
import type {
|
|
4
|
-
import type { astToString } from "./utils.js"
|
|
3
|
+
import type { inferAstIn } from "./infer.js"
|
|
5
4
|
import type { validateAst } from "./validate.js"
|
|
6
5
|
|
|
7
|
-
export type validateDivisor<l, $, args> =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type isDivisible<data> = [data] extends [number] ? true : false
|
|
6
|
+
export type validateDivisor<l, $, args> =
|
|
7
|
+
inferAstIn<l, $, args> extends infer data ?
|
|
8
|
+
[data] extends [number] ?
|
|
9
|
+
validateAst<l, $, args>
|
|
10
|
+
: ErrorMessage<writeIndivisibleMessage<Schema<data>>>
|
|
11
|
+
: never
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Date,
|
|
3
|
+
DateLiteral,
|
|
4
|
+
GenericProps,
|
|
5
|
+
LimitLiteral,
|
|
6
|
+
RegexLiteral,
|
|
7
|
+
constrain,
|
|
8
|
+
distillIn,
|
|
9
|
+
inferIntersection,
|
|
10
|
+
normalizeLimit,
|
|
11
|
+
string
|
|
12
|
+
} from "@arktype/schema"
|
|
13
|
+
import type { BigintLiteral, array } from "@arktype/util"
|
|
14
|
+
import type {
|
|
15
|
+
UnparsedScope,
|
|
16
|
+
resolve,
|
|
17
|
+
tryInferSubmoduleReference
|
|
18
|
+
} from "../../scope.js"
|
|
19
|
+
import type { inferDefinition } from "../definition.js"
|
|
20
|
+
import type { Comparator, MinComparator } from "../string/reduce/shared.js"
|
|
21
|
+
import type { StringLiteral } from "../string/shift/operand/enclosed.js"
|
|
22
|
+
|
|
23
|
+
export type inferAstRoot<ast, $, args> = inferConstrainableAst<ast, $, args>
|
|
24
|
+
|
|
25
|
+
export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>
|
|
26
|
+
|
|
27
|
+
export type inferConstrainableAst<ast, $, args> =
|
|
28
|
+
ast extends array ? inferExpression<ast, $, args>
|
|
29
|
+
: ast extends string ? inferTerminal<ast, $, args>
|
|
30
|
+
: never
|
|
31
|
+
|
|
32
|
+
export type GenericInstantiationAst<
|
|
33
|
+
generic extends GenericProps = GenericProps,
|
|
34
|
+
argAsts extends unknown[] = unknown[]
|
|
35
|
+
> = [generic, "<>", argAsts]
|
|
36
|
+
|
|
37
|
+
export type inferExpression<ast extends array, $, args> =
|
|
38
|
+
ast extends GenericInstantiationAst<infer generic, infer argAsts> ?
|
|
39
|
+
inferDefinition<
|
|
40
|
+
generic["def"],
|
|
41
|
+
generic["$"]["$"] extends UnparsedScope ?
|
|
42
|
+
// If the generic was defined in the current scope, its definition can be
|
|
43
|
+
// resolved using the same scope as that of the input args.
|
|
44
|
+
$
|
|
45
|
+
: // Otherwise, use the scope that was explicitly associated with it.
|
|
46
|
+
generic["$"]["$"],
|
|
47
|
+
{
|
|
48
|
+
// Using keyof g["params"] & number here results in the element types
|
|
49
|
+
// being mixed- another reason TS should not have separate `${number}` and number keys!
|
|
50
|
+
[i in keyof generic["params"] &
|
|
51
|
+
`${number}` as generic["params"][i]]: inferConstrainableAst<
|
|
52
|
+
argAsts[i & keyof argAsts],
|
|
53
|
+
$,
|
|
54
|
+
args
|
|
55
|
+
>
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
: ast[1] extends "[]" ? inferConstrainableAst<ast[0], $, args>[]
|
|
59
|
+
: ast[1] extends "|" ?
|
|
60
|
+
| inferConstrainableAst<ast[0], $, args>
|
|
61
|
+
| inferConstrainableAst<ast[2], $, args>
|
|
62
|
+
: ast[1] extends "&" ?
|
|
63
|
+
inferIntersection<
|
|
64
|
+
inferConstrainableAst<ast[0], $, args>,
|
|
65
|
+
inferConstrainableAst<ast[2], $, args>
|
|
66
|
+
>
|
|
67
|
+
: ast[1] extends Comparator ?
|
|
68
|
+
ast[0] extends LimitLiteral ?
|
|
69
|
+
constrainBound<inferConstrainableAst<ast[2], $, args>, ast[1], ast[0]>
|
|
70
|
+
: constrainBound<inferConstrainableAst<ast[0], $, args>, ast[1], ast[2]>
|
|
71
|
+
: ast[1] extends "%" ?
|
|
72
|
+
constrain<
|
|
73
|
+
inferConstrainableAst<ast[0], $, args>,
|
|
74
|
+
"divisor",
|
|
75
|
+
ast[2] & number
|
|
76
|
+
>
|
|
77
|
+
: ast[0] extends "keyof" ? keyof inferConstrainableAst<ast[1], $, args>
|
|
78
|
+
: never
|
|
79
|
+
|
|
80
|
+
export type constrainBound<
|
|
81
|
+
constrainableIn,
|
|
82
|
+
comparator extends Comparator,
|
|
83
|
+
limit
|
|
84
|
+
> =
|
|
85
|
+
distillIn<constrainableIn> extends infer In ?
|
|
86
|
+
comparator extends "==" ?
|
|
87
|
+
In extends number ? limit
|
|
88
|
+
: In extends Date ? Date.literal<normalizeLimit<limit>>
|
|
89
|
+
: constrain<constrainableIn, "exactLength", limit & number>
|
|
90
|
+
: constrain<
|
|
91
|
+
constrainableIn,
|
|
92
|
+
In extends number ?
|
|
93
|
+
comparator extends MinComparator ?
|
|
94
|
+
"min"
|
|
95
|
+
: "max"
|
|
96
|
+
: In extends string | array ?
|
|
97
|
+
comparator extends MinComparator ?
|
|
98
|
+
"minLength"
|
|
99
|
+
: "maxLength"
|
|
100
|
+
: comparator extends MinComparator ? "after"
|
|
101
|
+
: "before",
|
|
102
|
+
{
|
|
103
|
+
rule: normalizeLimit<limit>
|
|
104
|
+
exclusive: comparator extends ">" | "<" ? true : false
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
: never
|
|
108
|
+
|
|
109
|
+
export type PrefixOperator = "keyof" | "instanceof" | "===" | "node"
|
|
110
|
+
|
|
111
|
+
export type PrefixExpression<
|
|
112
|
+
operator extends PrefixOperator = PrefixOperator,
|
|
113
|
+
operand = unknown
|
|
114
|
+
> = [operator, operand]
|
|
115
|
+
|
|
116
|
+
export type PostfixOperator = "[]"
|
|
117
|
+
|
|
118
|
+
export type PostfixExpression<
|
|
119
|
+
operator extends PostfixOperator = PostfixOperator,
|
|
120
|
+
operand = unknown
|
|
121
|
+
> = readonly [operand, operator]
|
|
122
|
+
|
|
123
|
+
export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@"
|
|
124
|
+
|
|
125
|
+
export type InfixExpression<
|
|
126
|
+
operator extends InfixOperator = InfixOperator,
|
|
127
|
+
l = unknown,
|
|
128
|
+
r = unknown
|
|
129
|
+
> = [l, operator, r]
|
|
130
|
+
|
|
131
|
+
export type inferTerminal<token extends string, $, args> =
|
|
132
|
+
token extends keyof args | keyof $ ? resolve<token, $, args>
|
|
133
|
+
: `#${token}` extends keyof $ ? resolve<`#${token}`, $, args>
|
|
134
|
+
: token extends StringLiteral<infer text> ? text
|
|
135
|
+
: token extends `${infer n extends number}` ? n
|
|
136
|
+
: token extends BigintLiteral<infer b> ? b
|
|
137
|
+
: token extends RegexLiteral<infer source> ? string.matching<source>
|
|
138
|
+
: token extends DateLiteral<infer source> ? Date.literal<source>
|
|
139
|
+
: // doing this last allows us to infer never if it isn't valid rather than check
|
|
140
|
+
// if it's a valid submodule reference ahead of time
|
|
141
|
+
tryInferSubmoduleReference<$, token>
|
package/parser/semantic/utils.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Stringifiable } from "@arktype/util"
|
|
2
2
|
import type { Comparator } from "../string/reduce/shared.js"
|
|
3
|
-
import type { InfixExpression, PostfixExpression } from "./
|
|
3
|
+
import type { InfixExpression, PostfixExpression } from "./infer.js"
|
|
4
4
|
|
|
5
|
-
export type astToString<ast> =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
:
|
|
14
|
-
: ast extends
|
|
15
|
-
? operator extends "&" | "|" | "%" | Comparator
|
|
16
|
-
? `${groupAst<l>}${operator}${groupAst<r>}`
|
|
17
|
-
: never
|
|
18
|
-
: ast extends Stringifiable
|
|
19
|
-
? `${ast extends bigint ? `${ast}n` : ast}`
|
|
5
|
+
export type astToString<ast> =
|
|
6
|
+
ast extends PostfixExpression<infer operator, infer operand> ?
|
|
7
|
+
operator extends "[]" ?
|
|
8
|
+
`${astToString<operand>}[]`
|
|
9
|
+
: never
|
|
10
|
+
: ast extends InfixExpression<infer operator, infer l, infer r> ?
|
|
11
|
+
operator extends "&" | "|" | "%" | Comparator ?
|
|
12
|
+
`${astToString<l>} ${operator} ${astToString<r>}`
|
|
13
|
+
: never
|
|
14
|
+
: ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}`
|
|
20
15
|
: "..."
|
|
21
|
-
|
|
22
|
-
type groupAst<ast> = ast extends List
|
|
23
|
-
? ast[1] extends "[]"
|
|
24
|
-
? astToStringRecurse<ast>
|
|
25
|
-
: `(${astToStringRecurse<ast>})`
|
|
26
|
-
: astToStringRecurse<ast>
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
arkKind,
|
|
3
|
+
GenericProps,
|
|
4
|
+
PrivateDeclaration,
|
|
5
|
+
writeMissingSubmoduleAccessMessage
|
|
6
|
+
} from "@arktype/schema"
|
|
2
7
|
import type {
|
|
3
8
|
BigintLiteral,
|
|
9
|
+
charsAfterFirst,
|
|
4
10
|
Completion,
|
|
5
11
|
ErrorMessage,
|
|
6
|
-
NumberLiteral,
|
|
7
12
|
writeMalformedNumericLiteralMessage
|
|
8
13
|
} from "@arktype/util"
|
|
9
|
-
import type { Module } from "../../scope.js"
|
|
10
|
-
import type { GenericProps } from "../../type.js"
|
|
11
14
|
import type { Comparator } from "../string/reduce/shared.js"
|
|
12
15
|
import type { writeInvalidGenericArgsMessage } from "../string/shift/operand/genericArgs.js"
|
|
13
|
-
import type { writeMissingSubmoduleAccessMessage } from "../string/shift/operand/unenclosed.js"
|
|
14
16
|
import type { parseString } from "../string/string.js"
|
|
15
17
|
import type { validateRange } from "./bounds.js"
|
|
16
18
|
import type { validateDivisor } from "./divisor.js"
|
|
@@ -18,40 +20,36 @@ import type {
|
|
|
18
20
|
GenericInstantiationAst,
|
|
19
21
|
InfixExpression,
|
|
20
22
|
PostfixExpression
|
|
21
|
-
} from "./
|
|
23
|
+
} from "./infer.js"
|
|
22
24
|
import type { astToString } from "./utils.js"
|
|
23
25
|
|
|
24
|
-
export type validateAst<ast, $, args> =
|
|
25
|
-
? validateStringAst<ast, $>
|
|
26
|
-
: ast extends PostfixExpression<infer operator, infer operand>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
:
|
|
30
|
-
: ast extends InfixExpression<infer operator, infer l, infer r>
|
|
31
|
-
|
|
32
|
-
?
|
|
33
|
-
: operator extends
|
|
34
|
-
? validateRange<l, operator, r, $, args>
|
|
35
|
-
: operator extends "%"
|
|
36
|
-
? validateDivisor<l, $, args>
|
|
26
|
+
export type validateAst<ast, $, args> =
|
|
27
|
+
ast extends string ? validateStringAst<ast, $>
|
|
28
|
+
: ast extends PostfixExpression<infer operator, infer operand> ?
|
|
29
|
+
operator extends "[]" ?
|
|
30
|
+
validateAst<operand, $, args>
|
|
31
|
+
: never
|
|
32
|
+
: ast extends InfixExpression<infer operator, infer l, infer r> ?
|
|
33
|
+
operator extends "&" | "|" ? validateInfix<ast, $, args>
|
|
34
|
+
: operator extends Comparator ? validateRange<l, operator, r, $, args>
|
|
35
|
+
: operator extends "%" ? validateDivisor<l, $, args>
|
|
37
36
|
: undefined
|
|
38
|
-
: ast extends readonly ["keyof", infer operand]
|
|
39
|
-
|
|
40
|
-
: ast extends GenericInstantiationAst
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
: ast extends readonly ["keyof", infer operand] ?
|
|
38
|
+
validateAst<operand, $, args>
|
|
39
|
+
: ast extends GenericInstantiationAst ? validateGenericArgs<ast[2], $, args>
|
|
40
|
+
: ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
|
|
41
|
+
ast: ast
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
type writeUnexpectedExpressionMessage<expression extends string> =
|
|
45
45
|
`Unexpectedly failed to parse the expression resulting from ${expression}`
|
|
46
46
|
|
|
47
|
-
type validateGenericArgs<argAsts extends unknown[], $, args> =
|
|
48
|
-
infer head,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
: validateGenericArgs<tail, $, args>
|
|
54
|
-
: undefined
|
|
47
|
+
type validateGenericArgs<argAsts extends unknown[], $, args> =
|
|
48
|
+
argAsts extends [infer head, ...infer tail] ?
|
|
49
|
+
validateAst<head, $, args> extends ErrorMessage<infer message> ?
|
|
50
|
+
ErrorMessage<message>
|
|
51
|
+
: validateGenericArgs<tail, $, args>
|
|
52
|
+
: undefined
|
|
55
53
|
|
|
56
54
|
export const writeUnsatisfiableExpressionError = <expression extends string>(
|
|
57
55
|
expression: expression
|
|
@@ -61,49 +59,60 @@ export const writeUnsatisfiableExpressionError = <expression extends string>(
|
|
|
61
59
|
export type writeUnsatisfiableExpressionError<expression extends string> =
|
|
62
60
|
`${expression} results in an unsatisfiable type`
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
export const writePrefixedPrivateReferenceMessage = <
|
|
63
|
+
def extends PrivateDeclaration
|
|
64
|
+
>(
|
|
65
|
+
def: def
|
|
66
|
+
): writePrefixedPrivateReferenceMessage<def> =>
|
|
67
|
+
`Private type references should not include '#'. Use '${def.slice(1) as charsAfterFirst<def>}' instead.`
|
|
68
|
+
|
|
69
|
+
export type writePrefixedPrivateReferenceMessage<
|
|
70
|
+
def extends PrivateDeclaration
|
|
71
|
+
> =
|
|
72
|
+
`Private type references should not include '#'. Use '${charsAfterFirst<def>}' instead.`
|
|
73
|
+
|
|
74
|
+
type validateStringAst<def extends string, $> =
|
|
75
|
+
def extends `${infer n extends number}` ?
|
|
76
|
+
number extends n ?
|
|
77
|
+
ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">>
|
|
78
|
+
: undefined
|
|
79
|
+
: def extends BigintLiteral<infer b> ?
|
|
80
|
+
bigint extends b ?
|
|
81
|
+
ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">>
|
|
82
|
+
: undefined
|
|
83
|
+
: maybeExtractAlias<def, $> extends infer alias extends keyof $ ?
|
|
84
|
+
$[alias] extends null ?
|
|
85
|
+
// handle any/never
|
|
86
|
+
def
|
|
87
|
+
: def extends PrivateDeclaration ?
|
|
88
|
+
ErrorMessage<writePrefixedPrivateReferenceMessage<def>>
|
|
78
89
|
: // these problems would've been caught during a fullStringParse, but it's most
|
|
79
90
|
// efficient to check for them here in case the string was naively parsed
|
|
80
|
-
$[
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
:
|
|
85
|
-
|
|
86
|
-
: undefined
|
|
87
|
-
: def extends ErrorMessage
|
|
88
|
-
? def
|
|
91
|
+
$[alias] extends GenericProps ?
|
|
92
|
+
ErrorMessage<writeInvalidGenericArgsMessage<def, $[alias]["params"], []>>
|
|
93
|
+
: $[alias] extends { [arkKind]: "module" } ?
|
|
94
|
+
ErrorMessage<writeMissingSubmoduleAccessMessage<def>>
|
|
95
|
+
: undefined
|
|
96
|
+
: def extends ErrorMessage ? def
|
|
89
97
|
: undefined
|
|
90
98
|
|
|
91
|
-
export type
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
> extends infer result extends ErrorMessage
|
|
96
|
-
? result extends Completion<infer text>
|
|
97
|
-
? text
|
|
98
|
-
: result
|
|
99
|
-
: def
|
|
99
|
+
export type maybeExtractAlias<def extends string, $> =
|
|
100
|
+
def extends keyof $ ? def
|
|
101
|
+
: `#${def}` extends keyof $ ? `#${def}`
|
|
102
|
+
: null
|
|
100
103
|
|
|
101
|
-
type
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
export type validateString<def extends string, $, args> =
|
|
105
|
+
validateAst<parseString<def, $, args>, $, args> extends (
|
|
106
|
+
infer result extends ErrorMessage
|
|
107
|
+
) ?
|
|
108
|
+
result extends Completion<infer text> ?
|
|
109
|
+
text
|
|
110
|
+
: result
|
|
111
|
+
: def
|
|
112
|
+
|
|
113
|
+
type validateInfix<ast extends InfixExpression, $, args> =
|
|
114
|
+
validateAst<ast[0], $, args> extends ErrorMessage<infer message> ?
|
|
115
|
+
ErrorMessage<message>
|
|
116
|
+
: validateAst<ast[2], $, args> extends ErrorMessage<infer message> ?
|
|
117
|
+
ErrorMessage<message>
|
|
118
|
+
: undefined
|