@sinclair/typebox 0.32.0-dev-16 → 0.32.0-dev-18
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/build/import/compiler/compiler.d.mts +9 -0
- package/build/import/compiler/compiler.mjs +60 -6
- package/build/import/errors/errors.d.mts +3 -0
- package/build/import/errors/errors.mjs +28 -3
- package/build/import/errors/function.d.mts +3 -0
- package/build/import/errors/function.mjs +4 -0
- package/build/import/index.mjs +9 -0
- package/build/import/system/policy.d.mts +10 -0
- package/build/import/system/policy.mjs +13 -0
- package/build/import/system/system.d.mts +3 -0
- package/build/import/system/system.mjs +9 -0
- package/build/import/type/any/any.d.mts +1 -0
- package/build/import/type/any/any.mjs +1 -0
- package/build/import/type/array/array.d.mts +7 -0
- package/build/import/type/array/array.mjs +1 -0
- package/build/import/type/async-iterator/async-iterator.d.mts +1 -0
- package/build/import/type/async-iterator/async-iterator.mjs +1 -0
- package/build/import/type/awaited/awaited.d.mts +7 -6
- package/build/import/type/awaited/awaited.mjs +23 -13
- package/build/import/type/bigint/bigint.d.mts +1 -0
- package/build/import/type/bigint/bigint.mjs +1 -0
- package/build/import/type/boolean/boolean.d.mts +1 -0
- package/build/import/type/boolean/boolean.mjs +1 -0
- package/build/import/type/clone/type.d.mts +2 -0
- package/build/import/type/clone/type.mjs +2 -0
- package/build/import/type/clone/value.d.mts +1 -0
- package/build/import/type/clone/value.mjs +2 -0
- package/build/import/type/composite/composite.d.mts +1 -0
- package/build/import/type/composite/composite.mjs +1 -0
- package/build/import/type/const/const.d.mts +2 -1
- package/build/import/type/const/const.mjs +5 -1
- package/build/import/type/constructor/constructor.d.mts +1 -0
- package/build/import/type/constructor/constructor.mjs +1 -0
- package/build/import/type/constructor-parameters/constructor-parameters.d.mts +1 -0
- package/build/import/type/constructor-parameters/constructor-parameters.mjs +1 -0
- package/build/import/type/date/date.d.mts +6 -0
- package/build/import/type/date/date.mjs +1 -0
- package/build/import/type/deref/deref.d.mts +1 -0
- package/build/import/type/deref/deref.mjs +18 -0
- package/build/import/type/enum/enum.d.mts +1 -0
- package/build/import/type/enum/enum.mjs +1 -0
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +3 -0
- package/build/import/type/exclude/exclude.d.mts +2 -0
- package/build/import/type/exclude/exclude.mjs +3 -0
- package/build/import/type/extends/extends-check.mjs +173 -1
- package/build/import/type/extends/extends-from-mapped-key.mjs +4 -0
- package/build/import/type/extends/extends-from-mapped-result.mjs +3 -0
- package/build/import/type/extends/extends-undefined.d.mts +1 -0
- package/build/import/type/extends/extends-undefined.mjs +3 -0
- package/build/import/type/extends/extends.d.mts +3 -0
- package/build/import/type/extends/extends.mjs +7 -0
- package/build/import/type/extract/extract-from-mapped-result.mjs +3 -0
- package/build/import/type/extract/extract.d.mts +2 -0
- package/build/import/type/extract/extract.mjs +3 -0
- package/build/import/type/function/function.d.mts +1 -0
- package/build/import/type/function/function.mjs +1 -0
- package/build/import/type/guard/type.d.mts +46 -0
- package/build/import/type/guard/type.mjs +84 -1
- package/build/import/type/guard/value.d.mts +14 -0
- package/build/import/type/guard/value.mjs +14 -0
- package/build/import/type/helpers/helpers.d.mts +1 -0
- package/build/import/type/helpers/helpers.mjs +1 -0
- package/build/import/type/indexed/index.d.mts +0 -1
- package/build/import/type/indexed/index.mjs +0 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +10 -3
- package/build/import/type/indexed/indexed-property-keys.d.mts +1 -0
- package/build/import/type/indexed/indexed-property-keys.mjs +9 -0
- package/build/import/type/indexed/indexed.d.mts +40 -4
- package/build/import/type/indexed/indexed.mjs +84 -5
- package/build/import/type/instance-type/instance-type.d.mts +1 -0
- package/build/import/type/instance-type/instance-type.mjs +1 -0
- package/build/import/type/integer/integer.d.mts +1 -0
- package/build/import/type/integer/integer.mjs +1 -0
- package/build/import/type/intersect/intersect-create.mjs +8 -0
- package/build/import/type/intersect/intersect-evaluated.d.mts +1 -0
- package/build/import/type/intersect/intersect-evaluated.mjs +9 -0
- package/build/import/type/intersect/intersect.d.mts +1 -0
- package/build/import/type/intersect/intersect.mjs +5 -0
- package/build/import/type/intrinsic/capitalize.d.mts +1 -0
- package/build/import/type/intrinsic/capitalize.mjs +1 -0
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -0
- package/build/import/type/intrinsic/intrinsic.d.mts +2 -0
- package/build/import/type/intrinsic/intrinsic.mjs +16 -1
- package/build/import/type/intrinsic/lowercase.d.mts +1 -0
- package/build/import/type/intrinsic/lowercase.mjs +1 -0
- package/build/import/type/intrinsic/uncapitalize.d.mts +1 -0
- package/build/import/type/intrinsic/uncapitalize.mjs +1 -0
- package/build/import/type/intrinsic/uppercase.d.mts +1 -0
- package/build/import/type/intrinsic/uppercase.mjs +1 -0
- package/build/import/type/iterator/iterator.d.mts +1 -0
- package/build/import/type/iterator/iterator.mjs +1 -0
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +3 -0
- package/build/import/type/keyof/keyof-property-keys.d.mts +2 -0
- package/build/import/type/keyof/keyof-property-keys.mjs +20 -0
- package/build/import/type/keyof/keyof.d.mts +2 -0
- package/build/import/type/keyof/keyof.mjs +6 -0
- package/build/import/type/literal/literal.d.mts +1 -0
- package/build/import/type/literal/literal.mjs +1 -0
- package/build/import/type/mapped/mapped-key.mjs +1 -0
- package/build/import/type/mapped/mapped-result.mjs +1 -0
- package/build/import/type/mapped/mapped.d.mts +2 -0
- package/build/import/type/mapped/mapped.mjs +19 -1
- package/build/import/type/modifiers/modifiers.mjs +10 -0
- package/build/import/type/never/never.d.mts +1 -0
- package/build/import/type/never/never.mjs +1 -0
- package/build/import/type/not/not.d.mts +1 -0
- package/build/import/type/not/not.mjs +1 -0
- package/build/import/type/null/null.d.mts +1 -0
- package/build/import/type/null/null.mjs +1 -0
- package/build/import/type/number/number.d.mts +1 -0
- package/build/import/type/number/number.mjs +1 -0
- package/build/import/type/object/object.d.mts +5 -0
- package/build/import/type/object/object.mjs +6 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +4 -0
- package/build/import/type/omit/omit.d.mts +3 -0
- package/build/import/type/omit/omit.mjs +12 -0
- package/build/import/type/operators/operators.d.mts +8 -0
- package/build/import/type/operators/operators.mjs +15 -0
- package/build/import/type/optional/optional.d.mts +1 -0
- package/build/import/type/optional/optional.mjs +1 -0
- package/build/import/type/parameters/parameters.d.mts +1 -0
- package/build/import/type/parameters/parameters.mjs +1 -0
- package/build/import/type/partial/partial-from-mapped-result.mjs +3 -0
- package/build/import/type/partial/partial.d.mts +2 -0
- package/build/import/type/partial/partial.mjs +9 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +4 -0
- package/build/import/type/pick/pick.d.mts +3 -0
- package/build/import/type/pick/pick.mjs +7 -0
- package/build/import/type/promise/promise.d.mts +1 -0
- package/build/import/type/promise/promise.mjs +1 -0
- package/build/import/type/readonly/readonly.d.mts +1 -0
- package/build/import/type/readonly/readonly.mjs +1 -0
- package/build/import/type/readonly-optional/readonly-optional.d.mts +1 -0
- package/build/import/type/readonly-optional/readonly-optional.mjs +1 -0
- package/build/import/type/record/record.d.mts +11 -9
- package/build/import/type/record/record.mjs +53 -28
- package/build/import/type/recursive/recursive.d.mts +1 -0
- package/build/import/type/recursive/recursive.mjs +3 -0
- package/build/import/type/ref/ref.d.mts +2 -0
- package/build/import/type/ref/ref.mjs +1 -0
- package/build/import/type/regexp/regexp.d.mts +2 -0
- package/build/import/type/regexp/regexp.mjs +1 -0
- package/build/import/type/registry/format.d.mts +6 -0
- package/build/import/type/registry/format.mjs +7 -0
- package/build/import/type/registry/type.d.mts +6 -0
- package/build/import/type/registry/type.mjs +7 -0
- package/build/import/type/required/required-from-mapped-result.mjs +3 -0
- package/build/import/type/required/required.d.mts +2 -0
- package/build/import/type/required/required.mjs +9 -0
- package/build/import/type/rest/rest.d.mts +1 -0
- package/build/import/type/rest/rest.mjs +5 -0
- package/build/import/type/return-type/return-type.d.mts +1 -0
- package/build/import/type/return-type/return-type.mjs +1 -0
- package/build/import/type/schema/schema.d.mts +7 -0
- package/build/import/type/static/static.d.mts +3 -0
- package/build/import/type/strict/strict.d.mts +1 -0
- package/build/import/type/strict/strict.mjs +1 -0
- package/build/import/type/string/string.d.mts +7 -0
- package/build/import/type/string/string.mjs +1 -0
- package/build/import/type/symbol/symbol.d.mts +1 -0
- package/build/import/type/symbol/symbol.mjs +1 -0
- package/build/import/type/symbols/symbols.d.mts +5 -0
- package/build/import/type/symbols/symbols.mjs +5 -0
- package/build/import/type/template-literal/finite.mjs +10 -0
- package/build/import/type/template-literal/generate.mjs +10 -0
- package/build/import/type/template-literal/parser.d.mts +2 -0
- package/build/import/type/template-literal/parser.mjs +17 -0
- package/build/import/type/template-literal/pattern.mjs +11 -0
- package/build/import/type/template-literal/syntax.d.mts +1 -0
- package/build/import/type/template-literal/syntax.mjs +8 -0
- package/build/import/type/template-literal/template-literal.d.mts +2 -0
- package/build/import/type/template-literal/template-literal.mjs +2 -0
- package/build/import/type/template-literal/union.d.mts +1 -0
- package/build/import/type/template-literal/union.mjs +4 -0
- package/build/import/type/transform/transform.d.mts +1 -0
- package/build/import/type/transform/transform.mjs +9 -0
- package/build/import/type/tuple/tuple.d.mts +1 -0
- package/build/import/type/tuple/tuple.mjs +3 -0
- package/build/import/type/type/index.d.mts +1 -0
- package/build/import/type/type/index.mjs +7 -0
- package/build/import/type/type/javascript.d.mts +19 -0
- package/build/import/type/type/javascript.mjs +18 -0
- package/build/import/type/type/json.d.mts +64 -3
- package/build/import/type/type/json.mjs +55 -1
- package/build/import/type/type/type.mjs +3 -0
- package/build/import/type/uint8array/uint8array.d.mts +1 -0
- package/build/import/type/uint8array/uint8array.mjs +1 -0
- package/build/import/type/undefined/undefined.d.mts +1 -0
- package/build/import/type/undefined/undefined.mjs +1 -0
- package/build/import/type/union/union-evaluated.d.mts +1 -0
- package/build/import/type/union/union-evaluated.mjs +10 -0
- package/build/import/type/union/union.d.mts +1 -0
- package/build/import/type/union/union.mjs +2 -0
- package/build/import/type/unknown/unknown.d.mts +1 -0
- package/build/import/type/unknown/unknown.mjs +1 -0
- package/build/import/type/unsafe/unsafe.d.mts +1 -0
- package/build/import/type/unsafe/unsafe.mjs +1 -0
- package/build/import/type/void/void.d.mts +1 -0
- package/build/import/type/void/void.mjs +1 -0
- package/build/import/value/cast/cast.d.mts +2 -0
- package/build/import/value/cast/cast.mjs +28 -0
- package/build/import/value/check/check.d.mts +2 -0
- package/build/import/value/check/check.mjs +19 -1
- package/build/import/value/clean/clean.d.mts +2 -0
- package/build/import/value/clean/clean.mjs +12 -1
- package/build/import/value/clone/clone.d.mts +1 -0
- package/build/import/value/clone/clone.mjs +7 -0
- package/build/import/value/convert/convert.d.mts +2 -0
- package/build/import/value/convert/convert.mjs +30 -1
- package/build/import/value/create/create.d.mts +2 -0
- package/build/import/value/create/create.mjs +17 -0
- package/build/import/value/default/default.d.mts +2 -0
- package/build/import/value/default/default.mjs +19 -0
- package/build/import/value/delta/delta.mjs +15 -0
- package/build/import/value/deref/deref.d.mts +1 -0
- package/build/import/value/deref/deref.mjs +1 -0
- package/build/import/value/equal/equal.d.mts +1 -0
- package/build/import/value/equal/equal.mjs +7 -0
- package/build/import/value/guard/guard.d.mts +20 -0
- package/build/import/value/guard/guard.mjs +30 -0
- package/build/import/value/hash/hash.d.mts +1 -0
- package/build/import/value/hash/hash.mjs +19 -0
- package/build/import/value/index.mjs +12 -0
- package/build/import/value/mutate/mutate.d.mts +1 -0
- package/build/import/value/mutate/mutate.mjs +11 -0
- package/build/import/value/pointer/pointer.d.mts +5 -0
- package/build/import/value/pointer/pointer.mjs +18 -0
- package/build/import/value/transform/decode.d.mts +5 -0
- package/build/import/value/transform/decode.mjs +23 -0
- package/build/import/value/transform/encode.d.mts +6 -0
- package/build/import/value/transform/encode.mjs +25 -0
- package/build/import/value/transform/has.d.mts +1 -0
- package/build/import/value/transform/has.mjs +16 -0
- package/build/import/value/value/value.d.mts +24 -0
- package/build/import/value/value/value.mjs +15 -0
- package/build/require/compiler/compiler.d.ts +9 -0
- package/build/require/compiler/compiler.js +61 -6
- package/build/require/compiler/index.js +1 -0
- package/build/require/errors/errors.d.ts +3 -0
- package/build/require/errors/errors.js +29 -3
- package/build/require/errors/function.d.ts +3 -0
- package/build/require/errors/function.js +5 -0
- package/build/require/errors/index.js +1 -0
- package/build/require/index.js +10 -0
- package/build/require/system/index.js +1 -0
- package/build/require/system/policy.d.ts +10 -0
- package/build/require/system/policy.js +14 -0
- package/build/require/system/system.d.ts +3 -0
- package/build/require/system/system.js +10 -0
- package/build/require/type/any/any.d.ts +1 -0
- package/build/require/type/any/any.js +2 -0
- package/build/require/type/any/index.js +1 -0
- package/build/require/type/array/array.d.ts +7 -0
- package/build/require/type/array/array.js +2 -0
- package/build/require/type/array/index.js +1 -0
- package/build/require/type/async-iterator/async-iterator.d.ts +1 -0
- package/build/require/type/async-iterator/async-iterator.js +2 -0
- package/build/require/type/async-iterator/index.js +1 -0
- package/build/require/type/awaited/awaited.d.ts +7 -6
- package/build/require/type/awaited/awaited.js +25 -15
- package/build/require/type/awaited/index.js +1 -0
- package/build/require/type/bigint/bigint.d.ts +1 -0
- package/build/require/type/bigint/bigint.js +2 -0
- package/build/require/type/bigint/index.js +1 -0
- package/build/require/type/boolean/boolean.d.ts +1 -0
- package/build/require/type/boolean/boolean.js +2 -0
- package/build/require/type/boolean/index.js +1 -0
- package/build/require/type/clone/index.js +1 -0
- package/build/require/type/clone/type.d.ts +2 -0
- package/build/require/type/clone/type.js +3 -0
- package/build/require/type/clone/value.d.ts +1 -0
- package/build/require/type/clone/value.js +3 -0
- package/build/require/type/composite/composite.d.ts +1 -0
- package/build/require/type/composite/composite.js +2 -0
- package/build/require/type/composite/index.js +1 -0
- package/build/require/type/const/const.d.ts +2 -1
- package/build/require/type/const/const.js +6 -1
- package/build/require/type/const/index.js +1 -0
- package/build/require/type/constructor/constructor.d.ts +1 -0
- package/build/require/type/constructor/constructor.js +2 -0
- package/build/require/type/constructor/index.js +1 -0
- package/build/require/type/constructor-parameters/constructor-parameters.d.ts +1 -0
- package/build/require/type/constructor-parameters/constructor-parameters.js +2 -0
- package/build/require/type/constructor-parameters/index.js +1 -0
- package/build/require/type/date/date.d.ts +6 -0
- package/build/require/type/date/date.js +2 -0
- package/build/require/type/date/index.js +1 -0
- package/build/require/type/deref/deref.d.ts +1 -0
- package/build/require/type/deref/deref.js +19 -0
- package/build/require/type/deref/index.js +1 -0
- package/build/require/type/discard/discard.js +1 -0
- package/build/require/type/discard/index.js +1 -0
- package/build/require/type/enum/enum.d.ts +1 -0
- package/build/require/type/enum/enum.js +2 -0
- package/build/require/type/enum/index.js +1 -0
- package/build/require/type/exclude/exclude-from-mapped-result.js +4 -0
- package/build/require/type/exclude/exclude.d.ts +2 -0
- package/build/require/type/exclude/exclude.js +4 -0
- package/build/require/type/exclude/index.js +1 -0
- package/build/require/type/extends/extends-check.js +174 -1
- package/build/require/type/extends/extends-from-mapped-key.js +5 -0
- package/build/require/type/extends/extends-from-mapped-result.js +4 -0
- package/build/require/type/extends/extends-undefined.d.ts +1 -0
- package/build/require/type/extends/extends-undefined.js +4 -0
- package/build/require/type/extends/extends.d.ts +3 -0
- package/build/require/type/extends/extends.js +8 -0
- package/build/require/type/extends/index.js +1 -0
- package/build/require/type/extract/extract-from-mapped-result.js +4 -0
- package/build/require/type/extract/extract.d.ts +2 -0
- package/build/require/type/extract/extract.js +4 -0
- package/build/require/type/extract/index.js +1 -0
- package/build/require/type/function/function.d.ts +1 -0
- package/build/require/type/function/function.js +2 -0
- package/build/require/type/function/index.js +1 -0
- package/build/require/type/guard/index.js +1 -0
- package/build/require/type/guard/type.d.ts +46 -0
- package/build/require/type/guard/type.js +85 -1
- package/build/require/type/guard/value.d.ts +14 -0
- package/build/require/type/guard/value.js +15 -0
- package/build/require/type/helpers/helpers.d.ts +1 -0
- package/build/require/type/helpers/helpers.js +2 -0
- package/build/require/type/helpers/index.js +1 -0
- package/build/require/type/index.js +1 -0
- package/build/require/type/indexed/index.d.ts +0 -1
- package/build/require/type/indexed/index.js +1 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
- package/build/require/type/indexed/indexed-from-mapped-key.js +11 -3
- package/build/require/type/indexed/indexed-property-keys.d.ts +1 -0
- package/build/require/type/indexed/indexed-property-keys.js +10 -0
- package/build/require/type/indexed/indexed.d.ts +40 -4
- package/build/require/type/indexed/indexed.js +84 -4
- package/build/require/type/instance-type/index.js +1 -0
- package/build/require/type/instance-type/instance-type.d.ts +1 -0
- package/build/require/type/instance-type/instance-type.js +2 -0
- package/build/require/type/integer/index.js +1 -0
- package/build/require/type/integer/integer.d.ts +1 -0
- package/build/require/type/integer/integer.js +2 -0
- package/build/require/type/intersect/index.js +1 -0
- package/build/require/type/intersect/intersect-create.js +9 -0
- package/build/require/type/intersect/intersect-evaluated.d.ts +1 -0
- package/build/require/type/intersect/intersect-evaluated.js +10 -0
- package/build/require/type/intersect/intersect-type.js +1 -0
- package/build/require/type/intersect/intersect.d.ts +1 -0
- package/build/require/type/intersect/intersect.js +6 -0
- package/build/require/type/intrinsic/capitalize.d.ts +1 -0
- package/build/require/type/intrinsic/capitalize.js +2 -0
- package/build/require/type/intrinsic/index.js +1 -0
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +5 -0
- package/build/require/type/intrinsic/intrinsic.d.ts +2 -0
- package/build/require/type/intrinsic/intrinsic.js +17 -1
- package/build/require/type/intrinsic/lowercase.d.ts +1 -0
- package/build/require/type/intrinsic/lowercase.js +2 -0
- package/build/require/type/intrinsic/uncapitalize.d.ts +1 -0
- package/build/require/type/intrinsic/uncapitalize.js +2 -0
- package/build/require/type/intrinsic/uppercase.d.ts +1 -0
- package/build/require/type/intrinsic/uppercase.js +2 -0
- package/build/require/type/iterator/index.js +1 -0
- package/build/require/type/iterator/iterator.d.ts +1 -0
- package/build/require/type/iterator/iterator.js +2 -0
- package/build/require/type/keyof/index.js +1 -0
- package/build/require/type/keyof/keyof-from-mapped-result.js +4 -0
- package/build/require/type/keyof/keyof-property-keys.d.ts +2 -0
- package/build/require/type/keyof/keyof-property-keys.js +21 -0
- package/build/require/type/keyof/keyof.d.ts +2 -0
- package/build/require/type/keyof/keyof.js +7 -0
- package/build/require/type/literal/index.js +1 -0
- package/build/require/type/literal/literal.d.ts +1 -0
- package/build/require/type/literal/literal.js +2 -0
- package/build/require/type/mapped/index.js +1 -0
- package/build/require/type/mapped/mapped-key.js +2 -0
- package/build/require/type/mapped/mapped-result.js +2 -0
- package/build/require/type/mapped/mapped.d.ts +2 -0
- package/build/require/type/mapped/mapped.js +20 -1
- package/build/require/type/modifiers/index.js +1 -0
- package/build/require/type/modifiers/modifiers.js +11 -0
- package/build/require/type/never/index.js +1 -0
- package/build/require/type/never/never.d.ts +1 -0
- package/build/require/type/never/never.js +2 -0
- package/build/require/type/not/index.js +1 -0
- package/build/require/type/not/not.d.ts +1 -0
- package/build/require/type/not/not.js +2 -0
- package/build/require/type/null/index.js +1 -0
- package/build/require/type/null/null.d.ts +1 -0
- package/build/require/type/null/null.js +2 -0
- package/build/require/type/number/index.js +1 -0
- package/build/require/type/number/number.d.ts +1 -0
- package/build/require/type/number/number.js +2 -0
- package/build/require/type/object/index.js +1 -0
- package/build/require/type/object/object.d.ts +5 -0
- package/build/require/type/object/object.js +7 -0
- package/build/require/type/omit/index.js +1 -0
- package/build/require/type/omit/omit-from-mapped-key.js +5 -0
- package/build/require/type/omit/omit.d.ts +3 -0
- package/build/require/type/omit/omit.js +13 -0
- package/build/require/type/operators/index.js +1 -0
- package/build/require/type/operators/operators.d.ts +8 -0
- package/build/require/type/operators/operators.js +16 -0
- package/build/require/type/optional/index.js +1 -0
- package/build/require/type/optional/optional.d.ts +1 -0
- package/build/require/type/optional/optional.js +2 -0
- package/build/require/type/parameters/index.js +1 -0
- package/build/require/type/parameters/parameters.d.ts +1 -0
- package/build/require/type/parameters/parameters.js +2 -0
- package/build/require/type/partial/index.js +1 -0
- package/build/require/type/partial/partial-from-mapped-result.js +4 -0
- package/build/require/type/partial/partial.d.ts +2 -0
- package/build/require/type/partial/partial.js +10 -0
- package/build/require/type/patterns/index.js +1 -0
- package/build/require/type/patterns/patterns.js +1 -0
- package/build/require/type/pick/index.js +1 -0
- package/build/require/type/pick/pick-from-mapped-key.js +5 -0
- package/build/require/type/pick/pick.d.ts +3 -0
- package/build/require/type/pick/pick.js +8 -0
- package/build/require/type/promise/index.js +1 -0
- package/build/require/type/promise/promise.d.ts +1 -0
- package/build/require/type/promise/promise.js +2 -0
- package/build/require/type/readonly/index.js +1 -0
- package/build/require/type/readonly/readonly.d.ts +1 -0
- package/build/require/type/readonly/readonly.js +2 -0
- package/build/require/type/readonly-optional/index.js +1 -0
- package/build/require/type/readonly-optional/readonly-optional.d.ts +1 -0
- package/build/require/type/readonly-optional/readonly-optional.js +2 -0
- package/build/require/type/record/index.js +1 -0
- package/build/require/type/record/record.d.ts +11 -9
- package/build/require/type/record/record.js +54 -28
- package/build/require/type/recursive/index.js +1 -0
- package/build/require/type/recursive/recursive.d.ts +1 -0
- package/build/require/type/recursive/recursive.js +4 -0
- package/build/require/type/ref/index.js +1 -0
- package/build/require/type/ref/ref.d.ts +2 -0
- package/build/require/type/ref/ref.js +2 -0
- package/build/require/type/regexp/index.js +1 -0
- package/build/require/type/regexp/regexp.d.ts +2 -0
- package/build/require/type/regexp/regexp.js +2 -0
- package/build/require/type/registry/format.d.ts +6 -0
- package/build/require/type/registry/format.js +8 -0
- package/build/require/type/registry/index.js +1 -0
- package/build/require/type/registry/type.d.ts +6 -0
- package/build/require/type/registry/type.js +8 -0
- package/build/require/type/required/index.js +1 -0
- package/build/require/type/required/required-from-mapped-result.js +4 -0
- package/build/require/type/required/required.d.ts +2 -0
- package/build/require/type/required/required.js +10 -0
- package/build/require/type/rest/index.js +1 -0
- package/build/require/type/rest/rest.d.ts +1 -0
- package/build/require/type/rest/rest.js +6 -0
- package/build/require/type/return-type/index.js +1 -0
- package/build/require/type/return-type/return-type.d.ts +1 -0
- package/build/require/type/return-type/return-type.js +2 -0
- package/build/require/type/schema/anyschema.js +1 -0
- package/build/require/type/schema/index.js +1 -0
- package/build/require/type/schema/schema.d.ts +7 -0
- package/build/require/type/schema/schema.js +1 -0
- package/build/require/type/static/index.js +1 -0
- package/build/require/type/static/static.d.ts +3 -0
- package/build/require/type/static/static.js +1 -0
- package/build/require/type/strict/index.js +1 -0
- package/build/require/type/strict/strict.d.ts +1 -0
- package/build/require/type/strict/strict.js +2 -0
- package/build/require/type/string/index.js +1 -0
- package/build/require/type/string/string.d.ts +7 -0
- package/build/require/type/string/string.js +2 -0
- package/build/require/type/symbol/index.js +1 -0
- package/build/require/type/symbol/symbol.d.ts +1 -0
- package/build/require/type/symbol/symbol.js +2 -0
- package/build/require/type/symbols/index.js +1 -0
- package/build/require/type/symbols/symbols.d.ts +5 -0
- package/build/require/type/symbols/symbols.js +6 -0
- package/build/require/type/template-literal/finite.js +11 -0
- package/build/require/type/template-literal/generate.js +11 -0
- package/build/require/type/template-literal/index.js +1 -0
- package/build/require/type/template-literal/parser.d.ts +2 -0
- package/build/require/type/template-literal/parser.js +18 -0
- package/build/require/type/template-literal/pattern.js +12 -0
- package/build/require/type/template-literal/syntax.d.ts +1 -0
- package/build/require/type/template-literal/syntax.js +9 -0
- package/build/require/type/template-literal/template-literal.d.ts +2 -0
- package/build/require/type/template-literal/template-literal.js +3 -0
- package/build/require/type/template-literal/union.d.ts +1 -0
- package/build/require/type/template-literal/union.js +5 -0
- package/build/require/type/transform/index.js +1 -0
- package/build/require/type/transform/transform.d.ts +1 -0
- package/build/require/type/transform/transform.js +10 -0
- package/build/require/type/tuple/index.js +1 -0
- package/build/require/type/tuple/tuple.d.ts +1 -0
- package/build/require/type/tuple/tuple.js +4 -0
- package/build/require/type/type/index.d.ts +1 -0
- package/build/require/type/type/index.js +8 -0
- package/build/require/type/type/javascript.d.ts +19 -0
- package/build/require/type/type/javascript.js +19 -0
- package/build/require/type/type/json.d.ts +64 -3
- package/build/require/type/type/json.js +56 -1
- package/build/require/type/type/type.js +4 -0
- package/build/require/type/uint8array/index.js +1 -0
- package/build/require/type/uint8array/uint8array.d.ts +1 -0
- package/build/require/type/uint8array/uint8array.js +2 -0
- package/build/require/type/undefined/index.js +1 -0
- package/build/require/type/undefined/undefined.d.ts +1 -0
- package/build/require/type/undefined/undefined.js +2 -0
- package/build/require/type/union/index.js +1 -0
- package/build/require/type/union/union-create.js +1 -0
- package/build/require/type/union/union-evaluated.d.ts +1 -0
- package/build/require/type/union/union-evaluated.js +11 -0
- package/build/require/type/union/union-type.js +1 -0
- package/build/require/type/union/union.d.ts +1 -0
- package/build/require/type/union/union.js +3 -0
- package/build/require/type/unknown/index.js +1 -0
- package/build/require/type/unknown/unknown.d.ts +1 -0
- package/build/require/type/unknown/unknown.js +2 -0
- package/build/require/type/unsafe/index.js +1 -0
- package/build/require/type/unsafe/unsafe.d.ts +1 -0
- package/build/require/type/unsafe/unsafe.js +2 -0
- package/build/require/type/void/index.js +1 -0
- package/build/require/type/void/void.d.ts +1 -0
- package/build/require/type/void/void.js +2 -0
- package/build/require/value/cast/cast.d.ts +2 -0
- package/build/require/value/cast/cast.js +29 -0
- package/build/require/value/cast/index.js +1 -0
- package/build/require/value/check/check.d.ts +2 -0
- package/build/require/value/check/check.js +20 -1
- package/build/require/value/check/index.js +1 -0
- package/build/require/value/clean/clean.d.ts +2 -0
- package/build/require/value/clean/clean.js +13 -1
- package/build/require/value/clean/index.js +1 -0
- package/build/require/value/clone/clone.d.ts +1 -0
- package/build/require/value/clone/clone.js +8 -0
- package/build/require/value/clone/index.js +1 -0
- package/build/require/value/convert/convert.d.ts +2 -0
- package/build/require/value/convert/convert.js +31 -1
- package/build/require/value/convert/index.js +1 -0
- package/build/require/value/create/create.d.ts +2 -0
- package/build/require/value/create/create.js +18 -0
- package/build/require/value/create/index.js +1 -0
- package/build/require/value/default/default.d.ts +2 -0
- package/build/require/value/default/default.js +20 -0
- package/build/require/value/default/index.js +1 -0
- package/build/require/value/delta/delta.js +16 -0
- package/build/require/value/delta/index.js +1 -0
- package/build/require/value/deref/deref.d.ts +1 -0
- package/build/require/value/deref/deref.js +2 -0
- package/build/require/value/deref/index.js +1 -0
- package/build/require/value/equal/equal.d.ts +1 -0
- package/build/require/value/equal/equal.js +8 -0
- package/build/require/value/equal/index.js +1 -0
- package/build/require/value/guard/guard.d.ts +20 -0
- package/build/require/value/guard/guard.js +31 -0
- package/build/require/value/guard/index.js +1 -0
- package/build/require/value/hash/hash.d.ts +1 -0
- package/build/require/value/hash/hash.js +20 -0
- package/build/require/value/hash/index.js +1 -0
- package/build/require/value/index.js +13 -0
- package/build/require/value/mutate/index.js +1 -0
- package/build/require/value/mutate/mutate.d.ts +1 -0
- package/build/require/value/mutate/mutate.js +12 -0
- package/build/require/value/pointer/index.js +1 -0
- package/build/require/value/pointer/pointer.d.ts +5 -0
- package/build/require/value/pointer/pointer.js +19 -0
- package/build/require/value/transform/decode.d.ts +5 -0
- package/build/require/value/transform/decode.js +24 -0
- package/build/require/value/transform/encode.d.ts +6 -0
- package/build/require/value/transform/encode.js +26 -0
- package/build/require/value/transform/has.d.ts +1 -0
- package/build/require/value/transform/has.js +17 -0
- package/build/require/value/transform/index.js +1 -0
- package/build/require/value/value/index.js +1 -0
- package/build/require/value/value/value.d.ts +24 -0
- package/build/require/value/value/value.js +16 -0
- package/license +3 -1
- package/package.json +1 -1
- package/readme.md +4 -5
- package/build/import/type/indexed/indexed-result.d.mts +0 -33
- package/build/import/type/indexed/indexed-result.mjs +0 -65
- package/build/require/type/indexed/indexed-result.d.ts +0 -33
- package/build/require/type/indexed/indexed-result.js +0 -69
|
@@ -15,12 +15,24 @@ export var ExtendsResult;
|
|
|
15
15
|
ExtendsResult[ExtendsResult["True"] = 1] = "True";
|
|
16
16
|
ExtendsResult[ExtendsResult["False"] = 2] = "False";
|
|
17
17
|
})(ExtendsResult || (ExtendsResult = {}));
|
|
18
|
+
// ------------------------------------------------------------------
|
|
19
|
+
// IntoBooleanResult
|
|
20
|
+
// ------------------------------------------------------------------
|
|
21
|
+
// prettier-ignore
|
|
18
22
|
function IntoBooleanResult(result) {
|
|
19
23
|
return result === ExtendsResult.False ? result : ExtendsResult.True;
|
|
20
24
|
}
|
|
25
|
+
// ------------------------------------------------------------------
|
|
26
|
+
// Throw
|
|
27
|
+
// ------------------------------------------------------------------
|
|
28
|
+
// prettier-ignore
|
|
21
29
|
function Throw(message) {
|
|
22
30
|
throw new ExtendsResolverError(message);
|
|
23
31
|
}
|
|
32
|
+
// ------------------------------------------------------------------
|
|
33
|
+
// StructuralRight
|
|
34
|
+
// ------------------------------------------------------------------
|
|
35
|
+
// prettier-ignore
|
|
24
36
|
function IsStructuralRight(right) {
|
|
25
37
|
return (TypeGuard.TNever(right) ||
|
|
26
38
|
TypeGuard.TIntersect(right) ||
|
|
@@ -28,6 +40,7 @@ function IsStructuralRight(right) {
|
|
|
28
40
|
TypeGuard.TUnknown(right) ||
|
|
29
41
|
TypeGuard.TAny(right));
|
|
30
42
|
}
|
|
43
|
+
// prettier-ignore
|
|
31
44
|
function StructuralRight(left, right) {
|
|
32
45
|
return (TypeGuard.TNever(right) ? TNeverRight(left, right) :
|
|
33
46
|
TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
|
|
@@ -36,9 +49,14 @@ function StructuralRight(left, right) {
|
|
|
36
49
|
TypeGuard.TAny(right) ? TAnyRight(left, right) :
|
|
37
50
|
Throw('StructuralRight'));
|
|
38
51
|
}
|
|
52
|
+
// ------------------------------------------------------------------
|
|
53
|
+
// Any
|
|
54
|
+
// ------------------------------------------------------------------
|
|
55
|
+
// prettier-ignore
|
|
39
56
|
function TAnyRight(left, right) {
|
|
40
57
|
return ExtendsResult.True;
|
|
41
58
|
}
|
|
59
|
+
// prettier-ignore
|
|
42
60
|
function TAny(left, right) {
|
|
43
61
|
return (TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
|
|
44
62
|
(TypeGuard.TUnion(right) && right.anyOf.some((schema) => TypeGuard.TAny(schema) || TypeGuard.TUnknown(schema))) ? ExtendsResult.True :
|
|
@@ -47,23 +65,36 @@ function TAny(left, right) {
|
|
|
47
65
|
TypeGuard.TAny(right) ? ExtendsResult.True :
|
|
48
66
|
ExtendsResult.Union);
|
|
49
67
|
}
|
|
68
|
+
// ------------------------------------------------------------------
|
|
69
|
+
// Array
|
|
70
|
+
// ------------------------------------------------------------------
|
|
71
|
+
// prettier-ignore
|
|
50
72
|
function TArrayRight(left, right) {
|
|
51
73
|
return (TypeGuard.TUnknown(left) ? ExtendsResult.False :
|
|
52
74
|
TypeGuard.TAny(left) ? ExtendsResult.Union :
|
|
53
75
|
TypeGuard.TNever(left) ? ExtendsResult.True :
|
|
54
76
|
ExtendsResult.False);
|
|
55
77
|
}
|
|
78
|
+
// prettier-ignore
|
|
56
79
|
function TArray(left, right) {
|
|
57
80
|
return (TypeGuard.TObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
|
|
58
81
|
IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
59
82
|
!TypeGuard.TArray(right) ? ExtendsResult.False :
|
|
60
83
|
IntoBooleanResult(Visit(left.items, right.items)));
|
|
61
84
|
}
|
|
85
|
+
// ------------------------------------------------------------------
|
|
86
|
+
// AsyncIterator
|
|
87
|
+
// ------------------------------------------------------------------
|
|
88
|
+
// prettier-ignore
|
|
62
89
|
function TAsyncIterator(left, right) {
|
|
63
90
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
64
91
|
!TypeGuard.TAsyncIterator(right) ? ExtendsResult.False :
|
|
65
92
|
IntoBooleanResult(Visit(left.items, right.items)));
|
|
66
93
|
}
|
|
94
|
+
// ------------------------------------------------------------------
|
|
95
|
+
// BigInt
|
|
96
|
+
// ------------------------------------------------------------------
|
|
97
|
+
// prettier-ignore
|
|
67
98
|
function TBigInt(left, right) {
|
|
68
99
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
69
100
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -71,11 +102,16 @@ function TBigInt(left, right) {
|
|
|
71
102
|
TypeGuard.TBigInt(right) ? ExtendsResult.True :
|
|
72
103
|
ExtendsResult.False);
|
|
73
104
|
}
|
|
105
|
+
// ------------------------------------------------------------------
|
|
106
|
+
// Boolean
|
|
107
|
+
// ------------------------------------------------------------------
|
|
108
|
+
// prettier-ignore
|
|
74
109
|
function TBooleanRight(left, right) {
|
|
75
110
|
return (TypeGuard.TLiteralBoolean(left) ? ExtendsResult.True :
|
|
76
111
|
TypeGuard.TBoolean(left) ? ExtendsResult.True :
|
|
77
112
|
ExtendsResult.False);
|
|
78
113
|
}
|
|
114
|
+
// prettier-ignore
|
|
79
115
|
function TBoolean(left, right) {
|
|
80
116
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
81
117
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -83,6 +119,10 @@ function TBoolean(left, right) {
|
|
|
83
119
|
TypeGuard.TBoolean(right) ? ExtendsResult.True :
|
|
84
120
|
ExtendsResult.False);
|
|
85
121
|
}
|
|
122
|
+
// ------------------------------------------------------------------
|
|
123
|
+
// Constructor
|
|
124
|
+
// ------------------------------------------------------------------
|
|
125
|
+
// prettier-ignore
|
|
86
126
|
function TConstructor(left, right) {
|
|
87
127
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
88
128
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -91,6 +131,10 @@ function TConstructor(left, right) {
|
|
|
91
131
|
(!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True)) ? ExtendsResult.False :
|
|
92
132
|
IntoBooleanResult(Visit(left.returns, right.returns)));
|
|
93
133
|
}
|
|
134
|
+
// ------------------------------------------------------------------
|
|
135
|
+
// Date
|
|
136
|
+
// ------------------------------------------------------------------
|
|
137
|
+
// prettier-ignore
|
|
94
138
|
function TDate(left, right) {
|
|
95
139
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
96
140
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -98,6 +142,10 @@ function TDate(left, right) {
|
|
|
98
142
|
TypeGuard.TDate(right) ? ExtendsResult.True :
|
|
99
143
|
ExtendsResult.False);
|
|
100
144
|
}
|
|
145
|
+
// ------------------------------------------------------------------
|
|
146
|
+
// Function
|
|
147
|
+
// ------------------------------------------------------------------
|
|
148
|
+
// prettier-ignore
|
|
101
149
|
function TFunction(left, right) {
|
|
102
150
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
103
151
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -106,11 +154,16 @@ function TFunction(left, right) {
|
|
|
106
154
|
(!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True)) ? ExtendsResult.False :
|
|
107
155
|
IntoBooleanResult(Visit(left.returns, right.returns)));
|
|
108
156
|
}
|
|
157
|
+
// ------------------------------------------------------------------
|
|
158
|
+
// Integer
|
|
159
|
+
// ------------------------------------------------------------------
|
|
160
|
+
// prettier-ignore
|
|
109
161
|
function TIntegerRight(left, right) {
|
|
110
162
|
return (TypeGuard.TLiteral(left) && ValueGuard.IsNumber(left.const) ? ExtendsResult.True :
|
|
111
163
|
TypeGuard.TNumber(left) || TypeGuard.TInteger(left) ? ExtendsResult.True :
|
|
112
164
|
ExtendsResult.False);
|
|
113
165
|
}
|
|
166
|
+
// prettier-ignore
|
|
114
167
|
function TInteger(left, right) {
|
|
115
168
|
return (TypeGuard.TInteger(right) || TypeGuard.TNumber(right) ? ExtendsResult.True :
|
|
116
169
|
IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
@@ -118,21 +171,34 @@ function TInteger(left, right) {
|
|
|
118
171
|
TypeGuard.TRecord(right) ? TRecordRight(left, right) :
|
|
119
172
|
ExtendsResult.False);
|
|
120
173
|
}
|
|
174
|
+
// ------------------------------------------------------------------
|
|
175
|
+
// Intersect
|
|
176
|
+
// ------------------------------------------------------------------
|
|
177
|
+
// prettier-ignore
|
|
121
178
|
function TIntersectRight(left, right) {
|
|
122
179
|
return right.allOf.every((schema) => Visit(left, schema) === ExtendsResult.True)
|
|
123
180
|
? ExtendsResult.True
|
|
124
181
|
: ExtendsResult.False;
|
|
125
182
|
}
|
|
183
|
+
// prettier-ignore
|
|
126
184
|
function TIntersect(left, right) {
|
|
127
185
|
return left.allOf.some((schema) => Visit(schema, right) === ExtendsResult.True)
|
|
128
186
|
? ExtendsResult.True
|
|
129
187
|
: ExtendsResult.False;
|
|
130
188
|
}
|
|
189
|
+
// ------------------------------------------------------------------
|
|
190
|
+
// Iterator
|
|
191
|
+
// ------------------------------------------------------------------
|
|
192
|
+
// prettier-ignore
|
|
131
193
|
function TIterator(left, right) {
|
|
132
194
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
133
195
|
!TypeGuard.TIterator(right) ? ExtendsResult.False :
|
|
134
196
|
IntoBooleanResult(Visit(left.items, right.items)));
|
|
135
197
|
}
|
|
198
|
+
// ------------------------------------------------------------------
|
|
199
|
+
// Literal
|
|
200
|
+
// ------------------------------------------------------------------
|
|
201
|
+
// prettier-ignore
|
|
136
202
|
function TLiteral(left, right) {
|
|
137
203
|
return (TypeGuard.TLiteral(right) && right.const === left.const ? ExtendsResult.True :
|
|
138
204
|
IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
@@ -144,12 +210,21 @@ function TLiteral(left, right) {
|
|
|
144
210
|
TypeGuard.TBoolean(right) ? TBooleanRight(left, right) :
|
|
145
211
|
ExtendsResult.False);
|
|
146
212
|
}
|
|
213
|
+
// ------------------------------------------------------------------
|
|
214
|
+
// Never
|
|
215
|
+
// ------------------------------------------------------------------
|
|
216
|
+
// prettier-ignore
|
|
147
217
|
function TNeverRight(left, right) {
|
|
148
218
|
return ExtendsResult.False;
|
|
149
219
|
}
|
|
220
|
+
// prettier-ignore
|
|
150
221
|
function TNever(left, right) {
|
|
151
222
|
return ExtendsResult.True;
|
|
152
223
|
}
|
|
224
|
+
// ------------------------------------------------------------------
|
|
225
|
+
// Not
|
|
226
|
+
// ------------------------------------------------------------------
|
|
227
|
+
// prettier-ignore
|
|
153
228
|
function UnwrapTNot(schema) {
|
|
154
229
|
let [current, depth] = [schema, 0];
|
|
155
230
|
while (true) {
|
|
@@ -160,11 +235,20 @@ function UnwrapTNot(schema) {
|
|
|
160
235
|
}
|
|
161
236
|
return depth % 2 === 0 ? current : Unknown();
|
|
162
237
|
}
|
|
238
|
+
// prettier-ignore
|
|
163
239
|
function TNot(left, right) {
|
|
240
|
+
// TypeScript has no concept of negated types, and attempts to correctly check the negated
|
|
241
|
+
// type at runtime would put TypeBox at odds with TypeScripts ability to statically infer
|
|
242
|
+
// the type. Instead we unwrap to either unknown or T and continue evaluating.
|
|
243
|
+
// prettier-ignore
|
|
164
244
|
return (TypeGuard.TNot(left) ? Visit(UnwrapTNot(left), right) :
|
|
165
245
|
TypeGuard.TNot(right) ? Visit(left, UnwrapTNot(right)) :
|
|
166
246
|
Throw('Invalid fallthrough for Not'));
|
|
167
247
|
}
|
|
248
|
+
// ------------------------------------------------------------------
|
|
249
|
+
// Null
|
|
250
|
+
// ------------------------------------------------------------------
|
|
251
|
+
// prettier-ignore
|
|
168
252
|
function TNull(left, right) {
|
|
169
253
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
170
254
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -172,11 +256,16 @@ function TNull(left, right) {
|
|
|
172
256
|
TypeGuard.TNull(right) ? ExtendsResult.True :
|
|
173
257
|
ExtendsResult.False);
|
|
174
258
|
}
|
|
259
|
+
// ------------------------------------------------------------------
|
|
260
|
+
// Number
|
|
261
|
+
// ------------------------------------------------------------------
|
|
262
|
+
// prettier-ignore
|
|
175
263
|
function TNumberRight(left, right) {
|
|
176
264
|
return (TypeGuard.TLiteralNumber(left) ? ExtendsResult.True :
|
|
177
265
|
TypeGuard.TNumber(left) || TypeGuard.TInteger(left) ? ExtendsResult.True :
|
|
178
266
|
ExtendsResult.False);
|
|
179
267
|
}
|
|
268
|
+
// prettier-ignore
|
|
180
269
|
function TNumber(left, right) {
|
|
181
270
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
182
271
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -184,52 +273,72 @@ function TNumber(left, right) {
|
|
|
184
273
|
TypeGuard.TInteger(right) || TypeGuard.TNumber(right) ? ExtendsResult.True :
|
|
185
274
|
ExtendsResult.False);
|
|
186
275
|
}
|
|
276
|
+
// ------------------------------------------------------------------
|
|
277
|
+
// Object
|
|
278
|
+
// ------------------------------------------------------------------
|
|
279
|
+
// prettier-ignore
|
|
187
280
|
function IsObjectPropertyCount(schema, count) {
|
|
188
281
|
return Object.getOwnPropertyNames(schema.properties).length === count;
|
|
189
282
|
}
|
|
283
|
+
// prettier-ignore
|
|
190
284
|
function IsObjectStringLike(schema) {
|
|
191
285
|
return IsObjectArrayLike(schema);
|
|
192
286
|
}
|
|
287
|
+
// prettier-ignore
|
|
193
288
|
function IsObjectSymbolLike(schema) {
|
|
194
289
|
return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'description' in schema.properties && TypeGuard.TUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && ((TypeGuard.TString(schema.properties.description.anyOf[0]) &&
|
|
195
290
|
TypeGuard.TUndefined(schema.properties.description.anyOf[1])) || (TypeGuard.TString(schema.properties.description.anyOf[1]) &&
|
|
196
291
|
TypeGuard.TUndefined(schema.properties.description.anyOf[0]))));
|
|
197
292
|
}
|
|
293
|
+
// prettier-ignore
|
|
198
294
|
function IsObjectNumberLike(schema) {
|
|
199
295
|
return IsObjectPropertyCount(schema, 0);
|
|
200
296
|
}
|
|
297
|
+
// prettier-ignore
|
|
201
298
|
function IsObjectBooleanLike(schema) {
|
|
202
299
|
return IsObjectPropertyCount(schema, 0);
|
|
203
300
|
}
|
|
301
|
+
// prettier-ignore
|
|
204
302
|
function IsObjectBigIntLike(schema) {
|
|
205
303
|
return IsObjectPropertyCount(schema, 0);
|
|
206
304
|
}
|
|
305
|
+
// prettier-ignore
|
|
207
306
|
function IsObjectDateLike(schema) {
|
|
208
307
|
return IsObjectPropertyCount(schema, 0);
|
|
209
308
|
}
|
|
309
|
+
// prettier-ignore
|
|
210
310
|
function IsObjectUint8ArrayLike(schema) {
|
|
211
311
|
return IsObjectArrayLike(schema);
|
|
212
312
|
}
|
|
313
|
+
// prettier-ignore
|
|
213
314
|
function IsObjectFunctionLike(schema) {
|
|
214
315
|
const length = Number();
|
|
215
316
|
return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'length' in schema.properties && IntoBooleanResult(Visit(schema.properties['length'], length)) === ExtendsResult.True);
|
|
216
317
|
}
|
|
318
|
+
// prettier-ignore
|
|
217
319
|
function IsObjectConstructorLike(schema) {
|
|
218
320
|
return IsObjectPropertyCount(schema, 0);
|
|
219
321
|
}
|
|
322
|
+
// prettier-ignore
|
|
220
323
|
function IsObjectArrayLike(schema) {
|
|
221
324
|
const length = Number();
|
|
222
325
|
return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'length' in schema.properties && IntoBooleanResult(Visit(schema.properties['length'], length)) === ExtendsResult.True);
|
|
223
326
|
}
|
|
327
|
+
// prettier-ignore
|
|
224
328
|
function IsObjectPromiseLike(schema) {
|
|
225
329
|
const then = FunctionType([Any()], Any());
|
|
226
330
|
return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'then' in schema.properties && IntoBooleanResult(Visit(schema.properties['then'], then)) === ExtendsResult.True);
|
|
227
331
|
}
|
|
332
|
+
// ------------------------------------------------------------------
|
|
333
|
+
// Property
|
|
334
|
+
// ------------------------------------------------------------------
|
|
335
|
+
// prettier-ignore
|
|
228
336
|
function Property(left, right) {
|
|
229
337
|
return (Visit(left, right) === ExtendsResult.False ? ExtendsResult.False :
|
|
230
338
|
TypeGuard.TOptional(left) && !TypeGuard.TOptional(right) ? ExtendsResult.False :
|
|
231
339
|
ExtendsResult.True);
|
|
232
340
|
}
|
|
341
|
+
// prettier-ignore
|
|
233
342
|
function TObjectRight(left, right) {
|
|
234
343
|
return (TypeGuard.TUnknown(left) ? ExtendsResult.False :
|
|
235
344
|
TypeGuard.TAny(left) ? ExtendsResult.Union : (TypeGuard.TNever(left) ||
|
|
@@ -248,6 +357,8 @@ function TObjectRight(left, right) {
|
|
|
248
357
|
(TypeGuard.TConstructor(left) && IsObjectConstructorLike(right)) ||
|
|
249
358
|
(TypeGuard.TFunction(left) && IsObjectFunctionLike(right))) ? ExtendsResult.True :
|
|
250
359
|
(TypeGuard.TRecord(left) && TypeGuard.TString(RecordKey(left))) ? (() => {
|
|
360
|
+
// When expressing a Record with literal key values, the Record is converted into a Object with
|
|
361
|
+
// the Hint assigned as `Record`. This is used to invert the extends logic.
|
|
251
362
|
return right[Hint] === 'Record' ? ExtendsResult.True : ExtendsResult.False;
|
|
252
363
|
})() :
|
|
253
364
|
(TypeGuard.TRecord(left) && TypeGuard.TNumber(RecordKey(left))) ? (() => {
|
|
@@ -255,6 +366,7 @@ function TObjectRight(left, right) {
|
|
|
255
366
|
})() :
|
|
256
367
|
ExtendsResult.False);
|
|
257
368
|
}
|
|
369
|
+
// prettier-ignore
|
|
258
370
|
function TObject(left, right) {
|
|
259
371
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
260
372
|
TypeGuard.TRecord(right) ? TRecordRight(left, right) :
|
|
@@ -274,22 +386,32 @@ function TObject(left, right) {
|
|
|
274
386
|
return ExtendsResult.True;
|
|
275
387
|
})());
|
|
276
388
|
}
|
|
389
|
+
// ------------------------------------------------------------------
|
|
390
|
+
// Promise
|
|
391
|
+
// ------------------------------------------------------------------
|
|
392
|
+
// prettier-ignore
|
|
277
393
|
function TPromise(left, right) {
|
|
278
394
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
279
395
|
TypeGuard.TObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True :
|
|
280
396
|
!TypeGuard.TPromise(right) ? ExtendsResult.False :
|
|
281
397
|
IntoBooleanResult(Visit(left.item, right.item)));
|
|
282
398
|
}
|
|
399
|
+
// ------------------------------------------------------------------
|
|
400
|
+
// Record
|
|
401
|
+
// ------------------------------------------------------------------
|
|
402
|
+
// prettier-ignore
|
|
283
403
|
function RecordKey(schema) {
|
|
284
404
|
return (PatternNumberExact in schema.patternProperties ? Number() :
|
|
285
405
|
PatternStringExact in schema.patternProperties ? String() :
|
|
286
406
|
Throw('Unknown record key pattern'));
|
|
287
407
|
}
|
|
408
|
+
// prettier-ignore
|
|
288
409
|
function RecordValue(schema) {
|
|
289
410
|
return (PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] :
|
|
290
411
|
PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] :
|
|
291
412
|
Throw('Unable to get record value schema'));
|
|
292
413
|
}
|
|
414
|
+
// prettier-ignore
|
|
293
415
|
function TRecordRight(left, right) {
|
|
294
416
|
const [Key, Value] = [RecordKey(right), RecordValue(right)];
|
|
295
417
|
return ((TypeGuard.TLiteralString(left) && TypeGuard.TNumber(Key) && IntoBooleanResult(Visit(left, Value)) === ExtendsResult.True) ? ExtendsResult.True :
|
|
@@ -306,17 +428,23 @@ function TRecordRight(left, right) {
|
|
|
306
428
|
})() :
|
|
307
429
|
ExtendsResult.False);
|
|
308
430
|
}
|
|
431
|
+
// prettier-ignore
|
|
309
432
|
function TRecord(left, right) {
|
|
310
433
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
311
434
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
312
435
|
!TypeGuard.TRecord(right) ? ExtendsResult.False :
|
|
313
436
|
Visit(RecordValue(left), RecordValue(right)));
|
|
314
437
|
}
|
|
438
|
+
// ------------------------------------------------------------------
|
|
439
|
+
// String
|
|
440
|
+
// ------------------------------------------------------------------
|
|
441
|
+
// prettier-ignore
|
|
315
442
|
function TStringRight(left, right) {
|
|
316
443
|
return (TypeGuard.TLiteral(left) && ValueGuard.IsString(left.const) ? ExtendsResult.True :
|
|
317
444
|
TypeGuard.TString(left) ? ExtendsResult.True :
|
|
318
445
|
ExtendsResult.False);
|
|
319
446
|
}
|
|
447
|
+
// prettier-ignore
|
|
320
448
|
function TString(left, right) {
|
|
321
449
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
322
450
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -324,6 +452,10 @@ function TString(left, right) {
|
|
|
324
452
|
TypeGuard.TString(right) ? ExtendsResult.True :
|
|
325
453
|
ExtendsResult.False);
|
|
326
454
|
}
|
|
455
|
+
// ------------------------------------------------------------------
|
|
456
|
+
// Symbol
|
|
457
|
+
// ------------------------------------------------------------------
|
|
458
|
+
// prettier-ignore
|
|
327
459
|
function TSymbol(left, right) {
|
|
328
460
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
329
461
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -331,22 +463,35 @@ function TSymbol(left, right) {
|
|
|
331
463
|
TypeGuard.TSymbol(right) ? ExtendsResult.True :
|
|
332
464
|
ExtendsResult.False);
|
|
333
465
|
}
|
|
466
|
+
// ------------------------------------------------------------------
|
|
467
|
+
// TemplateLiteral
|
|
468
|
+
// ------------------------------------------------------------------
|
|
469
|
+
// prettier-ignore
|
|
334
470
|
function TTemplateLiteral(left, right) {
|
|
471
|
+
// TemplateLiteral types are resolved to either unions for finite expressions or string
|
|
472
|
+
// for infinite expressions. Here we call to TemplateLiteralResolver to resolve for
|
|
473
|
+
// either type and continue evaluating.
|
|
335
474
|
return (TypeGuard.TTemplateLiteral(left) ? Visit(TemplateLiteralToUnion(left), right) :
|
|
336
475
|
TypeGuard.TTemplateLiteral(right) ? Visit(left, TemplateLiteralToUnion(right)) :
|
|
337
476
|
Throw('Invalid fallthrough for TemplateLiteral'));
|
|
338
477
|
}
|
|
478
|
+
// ------------------------------------------------------------------
|
|
479
|
+
// Tuple
|
|
480
|
+
// ------------------------------------------------------------------
|
|
481
|
+
// prettier-ignore
|
|
339
482
|
function IsArrayOfTuple(left, right) {
|
|
340
483
|
return (TypeGuard.TArray(right) &&
|
|
341
484
|
left.items !== undefined &&
|
|
342
485
|
left.items.every((schema) => Visit(schema, right.items) === ExtendsResult.True));
|
|
343
486
|
}
|
|
487
|
+
// prettier-ignore
|
|
344
488
|
function TTupleRight(left, right) {
|
|
345
489
|
return (TypeGuard.TNever(left) ? ExtendsResult.True :
|
|
346
490
|
TypeGuard.TUnknown(left) ? ExtendsResult.False :
|
|
347
491
|
TypeGuard.TAny(left) ? ExtendsResult.Union :
|
|
348
492
|
ExtendsResult.False);
|
|
349
493
|
}
|
|
494
|
+
// prettier-ignore
|
|
350
495
|
function TTuple(left, right) {
|
|
351
496
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
352
497
|
TypeGuard.TObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True :
|
|
@@ -357,6 +502,10 @@ function TTuple(left, right) {
|
|
|
357
502
|
left.items.every((schema, index) => Visit(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True :
|
|
358
503
|
ExtendsResult.False);
|
|
359
504
|
}
|
|
505
|
+
// ------------------------------------------------------------------
|
|
506
|
+
// Uint8Array
|
|
507
|
+
// ------------------------------------------------------------------
|
|
508
|
+
// prettier-ignore
|
|
360
509
|
function TUint8Array(left, right) {
|
|
361
510
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
362
511
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -364,6 +513,10 @@ function TUint8Array(left, right) {
|
|
|
364
513
|
TypeGuard.TUint8Array(right) ? ExtendsResult.True :
|
|
365
514
|
ExtendsResult.False);
|
|
366
515
|
}
|
|
516
|
+
// ------------------------------------------------------------------
|
|
517
|
+
// Undefined
|
|
518
|
+
// ------------------------------------------------------------------
|
|
519
|
+
// prettier-ignore
|
|
367
520
|
function TUndefined(left, right) {
|
|
368
521
|
return (IsStructuralRight(right) ? StructuralRight(left, right) :
|
|
369
522
|
TypeGuard.TObject(right) ? TObjectRight(left, right) :
|
|
@@ -372,19 +525,29 @@ function TUndefined(left, right) {
|
|
|
372
525
|
TypeGuard.TUndefined(right) ? ExtendsResult.True :
|
|
373
526
|
ExtendsResult.False);
|
|
374
527
|
}
|
|
528
|
+
// ------------------------------------------------------------------
|
|
529
|
+
// Union
|
|
530
|
+
// ------------------------------------------------------------------
|
|
531
|
+
// prettier-ignore
|
|
375
532
|
function TUnionRight(left, right) {
|
|
376
533
|
return right.anyOf.some((schema) => Visit(left, schema) === ExtendsResult.True)
|
|
377
534
|
? ExtendsResult.True
|
|
378
535
|
: ExtendsResult.False;
|
|
379
536
|
}
|
|
537
|
+
// prettier-ignore
|
|
380
538
|
function TUnion(left, right) {
|
|
381
539
|
return left.anyOf.every((schema) => Visit(schema, right) === ExtendsResult.True)
|
|
382
540
|
? ExtendsResult.True
|
|
383
541
|
: ExtendsResult.False;
|
|
384
542
|
}
|
|
543
|
+
// ------------------------------------------------------------------
|
|
544
|
+
// Unknown
|
|
545
|
+
// ------------------------------------------------------------------
|
|
546
|
+
// prettier-ignore
|
|
385
547
|
function TUnknownRight(left, right) {
|
|
386
548
|
return ExtendsResult.True;
|
|
387
549
|
}
|
|
550
|
+
// prettier-ignore
|
|
388
551
|
function TUnknown(left, right) {
|
|
389
552
|
return (TypeGuard.TNever(right) ? TNeverRight(left, right) :
|
|
390
553
|
TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
|
|
@@ -400,11 +563,16 @@ function TUnknown(left, right) {
|
|
|
400
563
|
TypeGuard.TUnknown(right) ? ExtendsResult.True :
|
|
401
564
|
ExtendsResult.False);
|
|
402
565
|
}
|
|
566
|
+
// ------------------------------------------------------------------
|
|
567
|
+
// Void
|
|
568
|
+
// ------------------------------------------------------------------
|
|
569
|
+
// prettier-ignore
|
|
403
570
|
function VoidRight(left, right) {
|
|
404
571
|
return (TypeGuard.TUndefined(left) ? ExtendsResult.True :
|
|
405
572
|
TypeGuard.TUndefined(left) ? ExtendsResult.True :
|
|
406
573
|
ExtendsResult.False);
|
|
407
574
|
}
|
|
575
|
+
// prettier-ignore
|
|
408
576
|
function TVoid(left, right) {
|
|
409
577
|
return (TypeGuard.TIntersect(right) ? TIntersectRight(left, right) :
|
|
410
578
|
TypeGuard.TUnion(right) ? TUnionRight(left, right) :
|
|
@@ -414,9 +582,13 @@ function TVoid(left, right) {
|
|
|
414
582
|
TypeGuard.TVoid(right) ? ExtendsResult.True :
|
|
415
583
|
ExtendsResult.False);
|
|
416
584
|
}
|
|
585
|
+
// prettier-ignore
|
|
417
586
|
function Visit(left, right) {
|
|
418
|
-
return (
|
|
587
|
+
return (
|
|
588
|
+
// resolvable
|
|
589
|
+
(TypeGuard.TTemplateLiteral(left) || TypeGuard.TTemplateLiteral(right)) ? TTemplateLiteral(left, right) :
|
|
419
590
|
(TypeGuard.TNot(left) || TypeGuard.TNot(right)) ? TNot(left, right) :
|
|
591
|
+
// standard
|
|
420
592
|
TypeGuard.TAny(left) ? TAny(left, right) :
|
|
421
593
|
TypeGuard.TArray(left) ? TArray(left, right) :
|
|
422
594
|
TypeGuard.TBigInt(left) ? TBigInt(left, right) :
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { MappedResult } from '../mapped/index.mjs';
|
|
2
2
|
import { Literal } from '../literal/index.mjs';
|
|
3
3
|
import { Extends } from './extends.mjs';
|
|
4
|
+
// prettier-ignore
|
|
4
5
|
function FromPropertyKey(K, U, L, R, options) {
|
|
5
6
|
return {
|
|
6
7
|
[K]: Extends(Literal(K), U, L, R, options)
|
|
7
8
|
};
|
|
8
9
|
}
|
|
10
|
+
// prettier-ignore
|
|
9
11
|
function FromPropertyKeys(K, U, L, R, options) {
|
|
10
12
|
const [LK, ...RK] = K;
|
|
11
13
|
return (K.length > 0
|
|
12
14
|
? { ...FromPropertyKey(LK, U, L, R, options), ...FromPropertyKeys(RK, U, L, R, options) }
|
|
13
15
|
: {});
|
|
14
16
|
}
|
|
17
|
+
// prettier-ignore
|
|
15
18
|
function FromMappedKey(K, U, L, R, options) {
|
|
16
19
|
return FromPropertyKeys(K.keys, U, L, R, options);
|
|
17
20
|
}
|
|
21
|
+
// prettier-ignore
|
|
18
22
|
export function ExtendsFromMappedKey(T, U, L, R, options) {
|
|
19
23
|
const P = FromMappedKey(T, U, L, R, options);
|
|
20
24
|
return MappedResult(P);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { MappedResult } from '../mapped/index.mjs';
|
|
2
2
|
import { Extends } from './extends.mjs';
|
|
3
|
+
// prettier-ignore
|
|
3
4
|
function FromProperties(K, U, L, R, options) {
|
|
4
5
|
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
5
6
|
return { ...Acc, [K2]: Extends(K[K2], U, L, R, options) };
|
|
6
7
|
}, {});
|
|
7
8
|
}
|
|
9
|
+
// prettier-ignore
|
|
8
10
|
function FromMappedResult(K, U, L, R, options) {
|
|
9
11
|
return FromProperties(K.properties, U, L, R, options);
|
|
10
12
|
}
|
|
13
|
+
// prettier-ignore
|
|
11
14
|
export function ExtendsFromMappedResult(T, U, L, R, options) {
|
|
12
15
|
const P = FromMappedResult(T, U, L, R, options);
|
|
13
16
|
return MappedResult(P);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Kind } from '../symbols/index.mjs';
|
|
2
|
+
/** Fast undefined check used for properties of type undefined */
|
|
2
3
|
function Intersect(schema) {
|
|
3
4
|
return schema.allOf.every((schema) => ExtendsUndefinedCheck(schema));
|
|
4
5
|
}
|
|
@@ -8,6 +9,8 @@ function Union(schema) {
|
|
|
8
9
|
function Not(schema) {
|
|
9
10
|
return !ExtendsUndefinedCheck(schema.not);
|
|
10
11
|
}
|
|
12
|
+
/** Fast undefined check used for properties of type undefined */
|
|
13
|
+
// prettier-ignore
|
|
11
14
|
export function ExtendsUndefinedCheck(schema) {
|
|
12
15
|
return (schema[Kind] === 'Intersect' ? Intersect(schema) :
|
|
13
16
|
schema[Kind] === 'Union' ? Union(schema) :
|
|
@@ -8,7 +8,10 @@ import { type TExtendsFromMappedResult } from './extends-from-mapped-result.mjs'
|
|
|
8
8
|
type ExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = ((Static<L> extends Static<R> ? T : U) extends infer O extends TSchema ? UnionToTuple<O> extends [infer X extends TSchema, infer Y extends TSchema] ? TUnion<[X, Y]> : O : never);
|
|
9
9
|
declare function ExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(left: L, right: R, trueType: T, falseType: U): ExtendsResolve<L, R, T, U>;
|
|
10
10
|
export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema> = ExtendsResolve<L, R, T, F>;
|
|
11
|
+
/** `[Json]` Creates a Conditional type */
|
|
11
12
|
export declare function Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
|
|
13
|
+
/** `[Json]` Creates a Conditional type */
|
|
12
14
|
export declare function Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedKey<L, R, T, F>;
|
|
15
|
+
/** `[Json]` Creates a Conditional type */
|
|
13
16
|
export declare function Extends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtends<L, R, T, F>;
|
|
14
17
|
export {};
|
|
@@ -3,14 +3,21 @@ import { ExtendsCheck, ExtendsResult } from './extends-check.mjs';
|
|
|
3
3
|
import { CloneType } from '../clone/type.mjs';
|
|
4
4
|
import { ExtendsFromMappedKey } from './extends-from-mapped-key.mjs';
|
|
5
5
|
import { ExtendsFromMappedResult } from './extends-from-mapped-result.mjs';
|
|
6
|
+
// ------------------------------------------------------------------
|
|
7
|
+
// TypeGuard
|
|
8
|
+
// ------------------------------------------------------------------
|
|
9
|
+
// prettier-ignore
|
|
6
10
|
import { TMappedKey as IsMappedKeyType, TMappedResult as IsMappedResultType } from '../guard/type.mjs';
|
|
11
|
+
// prettier-ignore
|
|
7
12
|
function ExtendsResolve(left, right, trueType, falseType) {
|
|
8
13
|
const R = ExtendsCheck(left, right);
|
|
9
14
|
return (R === ExtendsResult.Union ? Union([trueType, falseType]) :
|
|
10
15
|
R === ExtendsResult.True ? trueType :
|
|
11
16
|
falseType);
|
|
12
17
|
}
|
|
18
|
+
/** `[Json]` Creates a Conditional type */
|
|
13
19
|
export function Extends(L, R, T, F, options = {}) {
|
|
20
|
+
// prettier-ignore
|
|
14
21
|
return (IsMappedResultType(L) ? ExtendsFromMappedResult(L, R, T, F, options) :
|
|
15
22
|
IsMappedKeyType(L) ? CloneType(ExtendsFromMappedKey(L, R, T, F, options)) :
|
|
16
23
|
CloneType(ExtendsResolve(L, R, T, F), options));
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { MappedResult } from '../mapped/index.mjs';
|
|
2
2
|
import { Extract } from './extract.mjs';
|
|
3
|
+
// prettier-ignore
|
|
3
4
|
function FromProperties(K, U, options) {
|
|
4
5
|
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
5
6
|
return { ...Acc, [K2]: Extract(K[K2], U, options) };
|
|
6
7
|
}, {});
|
|
7
8
|
}
|
|
9
|
+
// prettier-ignore
|
|
8
10
|
function FromMappedResult(K, U, options) {
|
|
9
11
|
return FromProperties(K.properties, U, options);
|
|
10
12
|
}
|
|
13
|
+
// prettier-ignore
|
|
11
14
|
export function ExtractFromMappedResult(T, U, options) {
|
|
12
15
|
const P = FromMappedResult(T, U, options);
|
|
13
16
|
return MappedResult(P);
|
|
@@ -17,6 +17,8 @@ type FromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple
|
|
|
17
17
|
export type ExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? FromTemplateLiteral<T, U> : T extends TUnion<infer S> ? FromArray<S, U> : T extends U ? T : T);
|
|
18
18
|
export declare function ExtractResolve<L extends TSchema, R extends TSchema>(L: L, R: R): ExtractResolve<L, R>;
|
|
19
19
|
export type TExtract<T extends TSchema, U extends TSchema> = ExtractResolve<T, U>;
|
|
20
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
20
21
|
export declare function Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
22
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
21
23
|
export declare function Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
22
24
|
export {};
|
|
@@ -4,7 +4,9 @@ import { Never } from '../never/index.mjs';
|
|
|
4
4
|
import { ExtendsCheck, ExtendsResult } from '../extends/index.mjs';
|
|
5
5
|
import { CloneType } from '../clone/type.mjs';
|
|
6
6
|
import { ExtractFromMappedResult } from './extract-from-mapped-result.mjs';
|
|
7
|
+
// prettier-ignore
|
|
7
8
|
import { TMappedResult as IsMappedResultType, TTemplateLiteral as IsTemplateLiteralType, TUnion as IsUnionType } from '../guard/type.mjs';
|
|
9
|
+
// prettier-ignore
|
|
8
10
|
export function ExtractResolve(L, R) {
|
|
9
11
|
return (IsTemplateLiteralType(L) ? ExtractResolve(TemplateLiteralToUnion(L), R) :
|
|
10
12
|
IsTemplateLiteralType(R) ? ExtractResolve(L, TemplateLiteralToUnion(R)) :
|
|
@@ -15,6 +17,7 @@ export function ExtractResolve(L, R) {
|
|
|
15
17
|
ExtendsCheck(L, R) !== ExtendsResult.False ? L :
|
|
16
18
|
Never());
|
|
17
19
|
}
|
|
20
|
+
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
|
|
18
21
|
export function Extract(type, union, options = {}) {
|
|
19
22
|
if (IsMappedResultType(type)) {
|
|
20
23
|
return ExtractFromMappedResult(type, union, options);
|
|
@@ -12,5 +12,6 @@ export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema =
|
|
|
12
12
|
parameters: T;
|
|
13
13
|
returns: U;
|
|
14
14
|
}
|
|
15
|
+
/** `[JavaScript]` Creates a Function type */
|
|
15
16
|
export declare function Function<T extends TSchema[], U extends TSchema>(parameters: [...T], returns: U, options?: SchemaOptions): TFunction<T, U>;
|
|
16
17
|
export {};
|