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