type-plus 4.8.2 → 4.10.0
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/LICENSE +1 -1
- package/README.md +19 -18
- package/cjs/ComposableTypes.d.ts +1 -0
- package/cjs/ComposableTypes.d.ts.map +1 -0
- package/cjs/JSONTypes.d.ts +1 -0
- package/cjs/JSONTypes.d.ts.map +1 -0
- package/cjs/JSONTypes.js.map +1 -1
- package/cjs/PrimitiveTypes.d.ts +1 -0
- package/cjs/PrimitiveTypes.d.ts.map +1 -0
- package/cjs/UnionKeys.d.ts +1 -0
- package/cjs/UnionKeys.d.ts.map +1 -0
- package/cjs/array/CommonPropKeys.d.ts +2 -1
- package/cjs/array/CommonPropKeys.d.ts.map +1 -0
- package/cjs/array/Concat.d.ts +1 -0
- package/cjs/array/Concat.d.ts.map +1 -0
- package/cjs/array/CreateTuple.d.ts +2 -1
- package/cjs/array/CreateTuple.d.ts.map +1 -0
- package/cjs/array/Filter.d.ts +1 -0
- package/cjs/array/Filter.d.ts.map +1 -0
- package/cjs/array/FindFirst.d.ts +1 -0
- package/cjs/array/FindFirst.d.ts.map +1 -0
- package/cjs/array/FindLast.d.ts +1 -0
- package/cjs/array/FindLast.d.ts.map +1 -0
- package/cjs/array/Head.d.ts +1 -0
- package/cjs/array/Head.d.ts.map +1 -0
- package/cjs/array/IntersectOfProps.d.ts +3 -2
- package/cjs/array/IntersectOfProps.d.ts.map +1 -0
- package/cjs/array/IsArray.d.ts +1 -0
- package/cjs/array/IsArray.d.ts.map +1 -0
- package/cjs/array/Last.d.ts +1 -0
- package/cjs/array/Last.d.ts.map +1 -0
- package/cjs/array/PadLeft.d.ts +4 -3
- package/cjs/array/PadLeft.d.ts.map +1 -0
- package/cjs/array/Reverse.d.ts +1 -0
- package/cjs/array/Reverse.d.ts.map +1 -0
- package/cjs/array/Some.d.ts +4 -3
- package/cjs/array/Some.d.ts.map +1 -0
- package/cjs/array/Tail.d.ts +2 -1
- package/cjs/array/Tail.d.ts.map +1 -0
- package/cjs/array/UnionOfProps.d.ts +3 -2
- package/cjs/array/UnionOfProps.d.ts.map +1 -0
- package/cjs/array/UnionOfValues.d.ts +1 -0
- package/cjs/array/UnionOfValues.d.ts.map +1 -0
- package/cjs/array/drop.d.ts +3 -2
- package/cjs/array/drop.d.ts.map +1 -0
- package/cjs/array/drop.js.map +1 -1
- package/cjs/array/index.d.ts +20 -19
- package/cjs/array/index.d.ts.map +1 -0
- package/cjs/array/index.js +3 -3
- package/cjs/array/index.js.map +1 -1
- package/cjs/array/literalArray.d.ts +2 -1
- package/cjs/array/literalArray.d.ts.map +1 -0
- package/cjs/array/reduceWhile.d.ts +1 -0
- package/cjs/array/reduceWhile.d.ts.map +1 -0
- package/cjs/assertion/assertType.d.ts +3 -2
- package/cjs/assertion/assertType.d.ts.map +1 -0
- package/cjs/assertion/assertType.js +3 -3
- package/cjs/assertion/assertType.js.map +1 -1
- package/cjs/assertion/index.d.ts +2 -1
- package/cjs/assertion/index.d.ts.map +1 -0
- package/cjs/assertion/index.js +1 -1
- package/cjs/assertion/index.js.map +1 -1
- package/cjs/class/AnyConstructor.d.ts +1 -0
- package/cjs/class/AnyConstructor.d.ts.map +1 -0
- package/cjs/class/index.d.ts +3 -2
- package/cjs/class/index.d.ts.map +1 -0
- package/cjs/class/index.js +1 -1
- package/cjs/class/index.js.map +1 -1
- package/cjs/class/isConstructor.d.ts +2 -1
- package/cjs/class/isConstructor.d.ts.map +1 -0
- package/cjs/function/AnyFunction.d.ts +1 -0
- package/cjs/function/AnyFunction.d.ts.map +1 -0
- package/cjs/function/index.d.ts +2 -1
- package/cjs/function/index.d.ts.map +1 -0
- package/cjs/functional/ChainFn.d.ts +1 -0
- package/cjs/functional/ChainFn.d.ts.map +1 -0
- package/cjs/functional/compose.d.ts +3 -2
- package/cjs/functional/compose.d.ts.map +1 -0
- package/cjs/functional/compose.js.map +1 -1
- package/cjs/functional/index.d.ts +3 -2
- package/cjs/functional/index.d.ts.map +1 -0
- package/cjs/functional/index.js +1 -1
- package/cjs/functional/index.js.map +1 -1
- package/cjs/index.d.ts +18 -17
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +14 -14
- package/cjs/index.js.map +1 -1
- package/cjs/math/Abs.d.ts +2 -1
- package/cjs/math/Abs.d.ts.map +1 -0
- package/cjs/math/Add.d.ts +7 -6
- package/cjs/math/Add.d.ts.map +1 -0
- package/cjs/math/Digit.d.ts +7 -4
- package/cjs/math/Digit.d.ts.map +1 -0
- package/cjs/math/GreaterThan.d.ts +10 -9
- package/cjs/math/GreaterThan.d.ts.map +1 -0
- package/cjs/math/IsPositive.d.ts +1 -0
- package/cjs/math/IsPositive.d.ts.map +1 -0
- package/cjs/math/IsWhole.d.ts +1 -0
- package/cjs/math/IsWhole.d.ts.map +1 -0
- package/cjs/math/Max.d.ts +4 -10
- package/cjs/math/Max.d.ts.map +1 -0
- package/cjs/math/Subtract.d.ts +7 -6
- package/cjs/math/Subtract.d.ts.map +1 -0
- package/cjs/math/index.d.ts +9 -8
- package/cjs/math/index.d.ts.map +1 -0
- package/cjs/nodejs/index.d.ts +2 -1
- package/cjs/nodejs/index.d.ts.map +1 -0
- package/cjs/nodejs/index.js +1 -1
- package/cjs/nodejs/index.js.map +1 -1
- package/cjs/nodejs/isNodeError.d.ts +1 -0
- package/cjs/nodejs/isNodeError.d.ts.map +1 -0
- package/cjs/nominal-types/Brand.d.ts +3 -2
- package/cjs/nominal-types/Brand.d.ts.map +1 -0
- package/cjs/nominal-types/Brand.js +2 -2
- package/cjs/nominal-types/Brand.js.map +1 -1
- package/cjs/nominal-types/Flavor.d.ts +3 -2
- package/cjs/nominal-types/Flavor.d.ts.map +1 -0
- package/cjs/nominal-types/Flavor.js +2 -2
- package/cjs/nominal-types/Flavor.js.map +1 -1
- package/cjs/nominal-types/index.d.ts +4 -3
- package/cjs/nominal-types/index.d.ts.map +1 -0
- package/cjs/nominal-types/index.js +3 -3
- package/cjs/nominal-types/index.js.map +1 -1
- package/cjs/nominal-types/nominalMatch.d.ts +3 -2
- package/cjs/nominal-types/nominalMatch.d.ts.map +1 -0
- package/cjs/nominal-types/nominalMatch.js +2 -2
- package/cjs/nominal-types/nominalMatch.js.map +1 -1
- package/cjs/nominal-types/types.d.ts +1 -0
- package/cjs/nominal-types/types.d.ts.map +1 -0
- package/cjs/object/ANotB.d.ts +5 -4
- package/cjs/object/ANotB.d.ts.map +1 -0
- package/cjs/object/AnyRecord.d.ts +1 -0
- package/cjs/object/AnyRecord.d.ts.map +1 -0
- package/cjs/object/ExcludePropType.d.ts +1 -0
- package/cjs/object/ExcludePropType.d.ts.map +1 -0
- package/cjs/object/IsDisjoint.d.ts +4 -3
- package/cjs/object/IsDisjoint.d.ts.map +1 -0
- package/cjs/object/IsRecord.d.ts +1 -0
- package/cjs/object/IsRecord.d.ts.map +1 -0
- package/cjs/object/KeyTypes.d.ts +1 -0
- package/cjs/object/KeyTypes.d.ts.map +1 -0
- package/cjs/object/KeyofOptional.d.ts +1 -0
- package/cjs/object/KeyofOptional.d.ts.map +1 -0
- package/cjs/object/KeysWithDiffType.d.ts +4 -3
- package/cjs/object/KeysWithDiffType.d.ts.map +1 -0
- package/cjs/object/KnownKeys.d.ts +2 -1
- package/cjs/object/KnownKeys.d.ts.map +1 -0
- package/cjs/object/OptionalKeys.d.ts +2 -1
- package/cjs/object/OptionalKeys.d.ts.map +1 -0
- package/cjs/object/Partial.d.ts +4 -3
- package/cjs/object/Partial.d.ts.map +1 -0
- package/cjs/object/RecursiveIntersect.d.ts +2 -1
- package/cjs/object/RecursiveIntersect.d.ts.map +1 -0
- package/cjs/object/RecursivePartial.d.ts +2 -1
- package/cjs/object/RecursivePartial.d.ts.map +1 -0
- package/cjs/object/RecursiveRequired.d.ts +2 -1
- package/cjs/object/RecursiveRequired.d.ts.map +1 -0
- package/cjs/object/Required.d.ts +1 -0
- package/cjs/object/Required.d.ts.map +1 -0
- package/cjs/object/RequiredKeys.d.ts +3 -2
- package/cjs/object/RequiredKeys.d.ts.map +1 -0
- package/cjs/object/SpreadRecord.d.ts +2 -1
- package/cjs/object/SpreadRecord.d.ts.map +1 -0
- package/cjs/object/ValueOf.d.ts +1 -0
- package/cjs/object/ValueOf.d.ts.map +1 -0
- package/cjs/object/everyKey.d.ts +2 -1
- package/cjs/object/everyKey.d.ts.map +1 -0
- package/cjs/object/facade.d.ts +2 -1
- package/cjs/object/facade.d.ts.map +1 -0
- package/cjs/object/filterKey.d.ts +2 -1
- package/cjs/object/filterKey.d.ts.map +1 -0
- package/cjs/object/findKey.d.ts +2 -1
- package/cjs/object/findKey.d.ts.map +1 -0
- package/cjs/object/forEachKey.d.ts +2 -1
- package/cjs/object/forEachKey.d.ts.map +1 -0
- package/cjs/object/getField.d.ts +2 -1
- package/cjs/object/getField.d.ts.map +1 -0
- package/cjs/object/hasKey.d.ts +2 -1
- package/cjs/object/hasKey.d.ts.map +1 -0
- package/cjs/object/hasProperty.d.ts +2 -1
- package/cjs/object/hasProperty.d.ts.map +1 -0
- package/cjs/object/index.d.ts +37 -36
- package/cjs/object/index.d.ts.map +1 -0
- package/cjs/object/index.js +18 -18
- package/cjs/object/index.js.map +1 -1
- package/cjs/object/mapKey.d.ts +2 -1
- package/cjs/object/mapKey.d.ts.map +1 -0
- package/cjs/object/mapProperties.d.ts +3 -2
- package/cjs/object/mapProperties.d.ts.map +1 -0
- package/cjs/object/mapProperties.js +2 -2
- package/cjs/object/mapProperties.js.map +1 -1
- package/cjs/object/omit.d.ts +4 -3
- package/cjs/object/omit.d.ts.map +1 -0
- package/cjs/object/omit.js +2 -2
- package/cjs/object/omit.js.map +1 -1
- package/cjs/object/pick.d.ts +3 -2
- package/cjs/object/pick.d.ts.map +1 -0
- package/cjs/object/pick.js +2 -2
- package/cjs/object/pick.js.map +1 -1
- package/cjs/object/record.d.ts +3 -2
- package/cjs/object/record.d.ts.map +1 -0
- package/cjs/object/record.js +1 -1
- package/cjs/object/record.js.map +1 -1
- package/cjs/object/reduceKey.d.ts +2 -1
- package/cjs/object/reduceKey.d.ts.map +1 -0
- package/cjs/object/replaceProperty.d.ts +2 -1
- package/cjs/object/replaceProperty.d.ts.map +1 -0
- package/cjs/object/someKey.d.ts +2 -1
- package/cjs/object/someKey.d.ts.map +1 -0
- package/cjs/object/split.d.ts +3 -2
- package/cjs/object/split.d.ts.map +1 -0
- package/cjs/object/split.js +3 -3
- package/cjs/object/split.js.map +1 -1
- package/cjs/object/typeOverrideIncompatible.d.ts +2 -1
- package/cjs/object/typeOverrideIncompatible.d.ts.map +1 -0
- package/cjs/predicates/CanAssign.d.ts +3 -2
- package/cjs/predicates/CanAssign.d.ts.map +1 -0
- package/cjs/predicates/Equal.d.ts +1 -0
- package/cjs/predicates/Equal.d.ts.map +1 -0
- package/cjs/predicates/Extends.d.ts +1 -0
- package/cjs/predicates/Extends.d.ts.map +1 -0
- package/cjs/predicates/If.d.ts +1 -0
- package/cjs/predicates/If.d.ts.map +1 -0
- package/cjs/predicates/IsEmptyObject.d.ts +1 -0
- package/cjs/predicates/IsEmptyObject.d.ts.map +1 -0
- package/cjs/predicates/index.d.ts +9 -8
- package/cjs/predicates/index.d.ts.map +1 -0
- package/cjs/predicates/index.js +2 -2
- package/cjs/predicates/index.js.map +1 -1
- package/cjs/predicates/isType.d.ts +3 -2
- package/cjs/predicates/isType.d.ts.map +1 -0
- package/cjs/predicates/isType.js +2 -2
- package/cjs/predicates/isType.js.map +1 -1
- package/cjs/predicates/logical.d.ts +1 -0
- package/cjs/predicates/logical.d.ts.map +1 -0
- package/cjs/promise/PromiseValue.d.ts +1 -0
- package/cjs/promise/PromiseValue.d.ts.map +1 -0
- package/cjs/promise/PromiseValueMerge.d.ts +2 -1
- package/cjs/promise/PromiseValueMerge.d.ts.map +1 -0
- package/cjs/promise/index.d.ts +5 -4
- package/cjs/promise/index.d.ts.map +1 -0
- package/cjs/promise/index.js +2 -2
- package/cjs/promise/index.js.map +1 -1
- package/cjs/promise/isPromise.d.ts +1 -0
- package/cjs/promise/isPromise.d.ts.map +1 -0
- package/cjs/promise/mapSeries.d.ts +1 -0
- package/cjs/promise/mapSeries.d.ts.map +1 -0
- package/cjs/testing/index.d.ts +2 -1
- package/cjs/testing/index.d.ts.map +1 -0
- package/cjs/testing/index.js +1 -1
- package/cjs/testing/index.js.map +1 -1
- package/cjs/testing/stub.d.ts +3 -2
- package/cjs/testing/stub.d.ts.map +1 -0
- package/cjs/utils/NonNull.d.ts +1 -0
- package/cjs/utils/NonNull.d.ts.map +1 -0
- package/cjs/utils/NonUndefined.d.ts +1 -0
- package/cjs/utils/NonUndefined.d.ts.map +1 -0
- package/cjs/utils/Widen.d.ts +1 -0
- package/cjs/utils/Widen.d.ts.map +1 -0
- package/cjs/utils/as.d.ts +1 -0
- package/cjs/utils/as.d.ts.map +1 -0
- package/cjs/utils/index.d.ts +5 -4
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +1 -1
- package/cjs/utils/index.js.map +1 -1
- package/esm/ComposableTypes.d.ts +3 -0
- package/esm/ComposableTypes.d.ts.map +1 -0
- package/esm/JSONTypes.d.ts +12 -0
- package/esm/JSONTypes.d.ts.map +1 -0
- package/esm/JSONTypes.js.map +1 -1
- package/esm/PrimitiveTypes.d.ts +2 -0
- package/esm/PrimitiveTypes.d.ts.map +1 -0
- package/esm/UnionKeys.d.ts +2 -0
- package/esm/UnionKeys.d.ts.map +1 -0
- package/esm/array/CommonPropKeys.d.ts +4 -0
- package/esm/array/CommonPropKeys.d.ts.map +1 -0
- package/esm/array/Concat.d.ts +2 -0
- package/esm/array/Concat.d.ts.map +1 -0
- package/esm/array/CreateTuple.d.ts +3 -0
- package/esm/array/CreateTuple.d.ts.map +1 -0
- package/esm/array/Filter.d.ts +3 -0
- package/esm/array/Filter.d.ts.map +1 -0
- package/esm/array/FindFirst.d.ts +3 -0
- package/esm/array/FindFirst.d.ts.map +1 -0
- package/esm/array/FindLast.d.ts +2 -0
- package/esm/array/FindLast.d.ts.map +1 -0
- package/esm/array/Head.d.ts +2 -0
- package/esm/array/Head.d.ts.map +1 -0
- package/esm/array/IntersectOfProps.d.ts +5 -0
- package/esm/array/IntersectOfProps.d.ts.map +1 -0
- package/esm/array/IsArray.d.ts +2 -0
- package/esm/array/IsArray.d.ts.map +1 -0
- package/esm/array/Last.d.ts +2 -0
- package/esm/array/Last.d.ts.map +1 -0
- package/esm/array/PadLeft.d.ts +5 -0
- package/esm/array/PadLeft.d.ts.map +1 -0
- package/esm/array/Reverse.d.ts +2 -0
- package/esm/array/Reverse.d.ts.map +1 -0
- package/esm/array/Some.d.ts +8 -0
- package/esm/array/Some.d.ts.map +1 -0
- package/esm/array/Tail.d.ts +3 -0
- package/esm/array/Tail.d.ts.map +1 -0
- package/esm/array/UnionOfProps.d.ts +5 -0
- package/esm/array/UnionOfProps.d.ts.map +1 -0
- package/esm/array/UnionOfValues.d.ts +3 -0
- package/esm/array/UnionOfValues.d.ts.map +1 -0
- package/esm/array/drop.d.ts +13 -0
- package/esm/array/drop.d.ts.map +1 -0
- package/esm/array/drop.js.map +1 -1
- package/esm/array/index.d.ts +20 -0
- package/esm/array/index.d.ts.map +1 -0
- package/esm/array/index.js +3 -3
- package/esm/array/index.js.map +1 -1
- package/esm/array/literalArray.d.ts +3 -0
- package/esm/array/literalArray.d.ts.map +1 -0
- package/esm/array/reduceWhile.d.ts +2 -0
- package/esm/array/reduceWhile.d.ts.map +1 -0
- package/esm/assertion/assertType.d.ts +29 -0
- package/esm/assertion/assertType.d.ts.map +1 -0
- package/esm/assertion/assertType.js +1 -1
- package/esm/assertion/assertType.js.map +1 -1
- package/esm/assertion/index.d.ts +2 -0
- package/esm/assertion/index.d.ts.map +1 -0
- package/esm/assertion/index.js +1 -1
- package/esm/assertion/index.js.map +1 -1
- package/esm/class/AnyConstructor.d.ts +2 -0
- package/esm/class/AnyConstructor.d.ts.map +1 -0
- package/esm/class/index.d.ts +3 -0
- package/esm/class/index.d.ts.map +1 -0
- package/esm/class/index.js +1 -1
- package/esm/class/index.js.map +1 -1
- package/esm/class/isConstructor.d.ts +3 -0
- package/esm/class/isConstructor.d.ts.map +1 -0
- package/esm/function/AnyFunction.d.ts +2 -0
- package/esm/function/AnyFunction.d.ts.map +1 -0
- package/esm/function/index.d.ts +2 -0
- package/esm/function/index.d.ts.map +1 -0
- package/esm/functional/ChainFn.d.ts +3 -0
- package/esm/functional/ChainFn.d.ts.map +1 -0
- package/esm/functional/compose.d.ts +4 -0
- package/esm/functional/compose.d.ts.map +1 -0
- package/esm/functional/compose.js.map +1 -1
- package/esm/functional/index.d.ts +3 -0
- package/esm/functional/index.d.ts.map +1 -0
- package/esm/functional/index.js +1 -1
- package/esm/functional/index.js.map +1 -1
- package/esm/index.d.ts +19 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +14 -14
- package/esm/index.js.map +1 -1
- package/esm/math/Abs.d.ts +3 -0
- package/esm/math/Abs.d.ts.map +1 -0
- package/esm/math/Add.d.ts +16 -0
- package/esm/math/Add.d.ts.map +1 -0
- package/esm/math/Digit.d.ts +97 -0
- package/esm/math/Digit.d.ts.map +1 -0
- package/esm/math/GreaterThan.d.ts +12 -0
- package/esm/math/GreaterThan.d.ts.map +1 -0
- package/esm/math/IsPositive.d.ts +2 -0
- package/esm/math/IsPositive.d.ts.map +1 -0
- package/esm/math/IsWhole.d.ts +2 -0
- package/esm/math/IsWhole.d.ts.map +1 -0
- package/esm/math/Max.d.ts +4 -0
- package/esm/math/Max.d.ts.map +1 -0
- package/esm/math/Subtract.d.ts +13 -0
- package/esm/math/Subtract.d.ts.map +1 -0
- package/esm/math/index.d.ts +9 -0
- package/esm/math/index.d.ts.map +1 -0
- package/esm/nodejs/index.d.ts +2 -0
- package/esm/nodejs/index.d.ts.map +1 -0
- package/esm/nodejs/index.js +1 -1
- package/esm/nodejs/index.js.map +1 -1
- package/esm/nodejs/isNodeError.d.ts +26 -0
- package/esm/nodejs/isNodeError.d.ts.map +1 -0
- package/esm/nominal-types/Brand.d.ts +11 -0
- package/esm/nominal-types/Brand.d.ts.map +1 -0
- package/esm/nominal-types/Brand.js +1 -1
- package/esm/nominal-types/Brand.js.map +1 -1
- package/esm/nominal-types/Flavor.d.ts +8 -0
- package/esm/nominal-types/Flavor.d.ts.map +1 -0
- package/esm/nominal-types/Flavor.js +1 -1
- package/esm/nominal-types/Flavor.js.map +1 -1
- package/esm/nominal-types/index.d.ts +4 -0
- package/esm/nominal-types/index.d.ts.map +1 -0
- package/esm/nominal-types/index.js +3 -3
- package/esm/nominal-types/index.js.map +1 -1
- package/esm/nominal-types/nominalMatch.d.ts +5 -0
- package/esm/nominal-types/nominalMatch.d.ts.map +1 -0
- package/esm/nominal-types/nominalMatch.js +1 -1
- package/esm/nominal-types/nominalMatch.js.map +1 -1
- package/esm/nominal-types/types.d.ts +3 -0
- package/esm/nominal-types/types.d.ts.map +1 -0
- package/esm/object/ANotB.d.ts +14 -0
- package/esm/object/ANotB.d.ts.map +1 -0
- package/esm/object/AnyRecord.d.ts +2 -0
- package/esm/object/AnyRecord.d.ts.map +1 -0
- package/esm/object/ExcludePropType.d.ts +4 -0
- package/esm/object/ExcludePropType.d.ts.map +1 -0
- package/esm/object/IsDisjoint.d.ts +5 -0
- package/esm/object/IsDisjoint.d.ts.map +1 -0
- package/esm/object/IsRecord.d.ts +2 -0
- package/esm/object/IsRecord.d.ts.map +1 -0
- package/esm/object/KeyTypes.d.ts +2 -0
- package/esm/object/KeyTypes.d.ts.map +1 -0
- package/esm/object/KeyofOptional.d.ts +3 -0
- package/esm/object/KeyofOptional.d.ts.map +1 -0
- package/esm/object/KeysWithDiffType.d.ts +7 -0
- package/esm/object/KeysWithDiffType.d.ts.map +1 -0
- package/esm/object/KnownKeys.d.ts +7 -0
- package/esm/object/KnownKeys.d.ts.map +1 -0
- package/esm/object/OptionalKeys.d.ts +8 -0
- package/esm/object/OptionalKeys.d.ts.map +1 -0
- package/esm/object/Partial.d.ts +7 -0
- package/esm/object/Partial.d.ts.map +1 -0
- package/esm/object/RecursiveIntersect.d.ts +5 -0
- package/esm/object/RecursiveIntersect.d.ts.map +1 -0
- package/esm/object/RecursivePartial.d.ts +5 -0
- package/esm/object/RecursivePartial.d.ts.map +1 -0
- package/esm/object/RecursiveRequired.d.ts +5 -0
- package/esm/object/RecursiveRequired.d.ts.map +1 -0
- package/esm/object/Required.d.ts +3 -0
- package/esm/object/Required.d.ts.map +1 -0
- package/esm/object/RequiredKeys.d.ts +7 -0
- package/esm/object/RequiredKeys.d.ts.map +1 -0
- package/esm/object/SpreadRecord.d.ts +3 -0
- package/esm/object/SpreadRecord.d.ts.map +1 -0
- package/esm/object/ValueOf.d.ts +2 -0
- package/esm/object/ValueOf.d.ts.map +1 -0
- package/esm/object/everyKey.d.ts +3 -0
- package/esm/object/everyKey.d.ts.map +1 -0
- package/esm/object/facade.d.ts +14 -0
- package/esm/object/facade.d.ts.map +1 -0
- package/esm/object/filterKey.d.ts +3 -0
- package/esm/object/filterKey.d.ts.map +1 -0
- package/esm/object/findKey.d.ts +3 -0
- package/esm/object/findKey.d.ts.map +1 -0
- package/esm/object/forEachKey.d.ts +3 -0
- package/esm/object/forEachKey.d.ts.map +1 -0
- package/esm/object/getField.d.ts +4 -0
- package/esm/object/getField.d.ts.map +1 -0
- package/esm/object/hasKey.d.ts +4 -0
- package/esm/object/hasKey.d.ts.map +1 -0
- package/esm/object/hasProperty.d.ts +3 -0
- package/esm/object/hasProperty.d.ts.map +1 -0
- package/esm/object/index.d.ts +37 -0
- package/esm/object/index.d.ts.map +1 -0
- package/esm/object/index.js +18 -18
- package/esm/object/index.js.map +1 -1
- package/esm/object/mapKey.d.ts +3 -0
- package/esm/object/mapKey.d.ts.map +1 -0
- package/esm/object/mapProperties.d.ts +6 -0
- package/esm/object/mapProperties.d.ts.map +1 -0
- package/esm/object/mapProperties.js +1 -1
- package/esm/object/mapProperties.js.map +1 -1
- package/esm/object/omit.d.ts +18 -0
- package/esm/object/omit.d.ts.map +1 -0
- package/esm/object/omit.js +1 -1
- package/esm/object/omit.js.map +1 -1
- package/esm/object/pick.d.ts +21 -0
- package/esm/object/pick.d.ts.map +1 -0
- package/esm/object/pick.js +1 -1
- package/esm/object/pick.js.map +1 -1
- package/esm/object/record.d.ts +4 -0
- package/esm/object/record.d.ts.map +1 -0
- package/esm/object/record.js +1 -1
- package/esm/object/record.js.map +1 -1
- package/esm/object/reduceKey.d.ts +4 -0
- package/esm/object/reduceKey.d.ts.map +1 -0
- package/esm/object/replaceProperty.d.ts +6 -0
- package/esm/object/replaceProperty.d.ts.map +1 -0
- package/esm/object/someKey.d.ts +3 -0
- package/esm/object/someKey.d.ts.map +1 -0
- package/esm/object/split.d.ts +82 -0
- package/esm/object/split.d.ts.map +1 -0
- package/esm/object/split.js +1 -1
- package/esm/object/split.js.map +1 -1
- package/esm/object/typeOverrideIncompatible.d.ts +3 -0
- package/esm/object/typeOverrideIncompatible.d.ts.map +1 -0
- package/esm/predicates/CanAssign.d.ts +7 -0
- package/esm/predicates/CanAssign.d.ts.map +1 -0
- package/esm/predicates/Equal.d.ts +5 -0
- package/esm/predicates/Equal.d.ts.map +1 -0
- package/esm/predicates/Extends.d.ts +5 -0
- package/esm/predicates/Extends.d.ts.map +1 -0
- package/esm/predicates/If.d.ts +2 -0
- package/esm/predicates/If.d.ts.map +1 -0
- package/esm/predicates/IsEmptyObject.d.ts +2 -0
- package/esm/predicates/IsEmptyObject.d.ts.map +1 -0
- package/esm/predicates/index.d.ts +12 -0
- package/esm/predicates/index.d.ts.map +1 -0
- package/esm/predicates/index.js +2 -2
- package/esm/predicates/index.js.map +1 -1
- package/esm/predicates/isType.d.ts +11 -0
- package/esm/predicates/isType.d.ts.map +1 -0
- package/esm/predicates/isType.js +1 -1
- package/esm/predicates/isType.js.map +1 -1
- package/esm/predicates/logical.d.ts +5 -0
- package/esm/predicates/logical.d.ts.map +1 -0
- package/esm/promise/PromiseValue.d.ts +2 -0
- package/esm/promise/PromiseValue.d.ts.map +1 -0
- package/esm/promise/PromiseValueMerge.d.ts +3 -0
- package/esm/promise/PromiseValueMerge.d.ts.map +1 -0
- package/esm/promise/index.d.ts +5 -0
- package/esm/promise/index.d.ts.map +1 -0
- package/esm/promise/index.js +2 -2
- package/esm/promise/index.js.map +1 -1
- package/esm/promise/isPromise.d.ts +2 -0
- package/esm/promise/isPromise.d.ts.map +1 -0
- package/esm/promise/mapSeries.d.ts +2 -0
- package/esm/promise/mapSeries.d.ts.map +1 -0
- package/esm/testing/index.d.ts +2 -0
- package/esm/testing/index.d.ts.map +1 -0
- package/esm/testing/index.js +1 -1
- package/esm/testing/index.js.map +1 -1
- package/esm/testing/stub.d.ts +10 -0
- package/esm/testing/stub.d.ts.map +1 -0
- package/esm/utils/NonNull.d.ts +2 -0
- package/esm/utils/NonNull.d.ts.map +1 -0
- package/esm/utils/NonUndefined.d.ts +2 -0
- package/esm/utils/NonUndefined.d.ts.map +1 -0
- package/esm/utils/Widen.d.ts +2 -0
- package/esm/utils/Widen.d.ts.map +1 -0
- package/esm/utils/as.d.ts +7 -0
- package/esm/utils/as.d.ts.map +1 -0
- package/esm/utils/index.d.ts +5 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +1 -1
- package/esm/utils/index.js.map +1 -1
- package/package.json +47 -42
- package/ts/JSONTypes.ts +17 -18
- package/ts/array/CommonPropKeys.ts +18 -18
- package/ts/array/CreateTuple.ts +1 -1
- package/ts/array/IntersectOfProps.ts +20 -20
- package/ts/array/PadLeft.ts +3 -3
- package/ts/array/Some.ts +3 -3
- package/ts/array/Tail.ts +1 -1
- package/ts/array/UnionOfProps.ts +18 -18
- package/ts/array/drop.ts +3 -3
- package/ts/array/index.ts +19 -19
- package/ts/array/literalArray.ts +1 -1
- package/ts/assertion/assertType.ts +105 -105
- package/ts/assertion/index.ts +1 -1
- package/ts/binary/_binary.ts +1 -1
- package/ts/binary/index.ts +2 -2
- package/ts/class/index.ts +2 -2
- package/ts/class/isConstructor.ts +1 -1
- package/ts/function/index.ts +1 -1
- package/ts/functional/Maybe.ts +19 -19
- package/ts/functional/compose.ts +4 -3
- package/ts/functional/index.ts +3 -3
- package/ts/index.ts +19 -19
- package/ts/math/Abs.ts +1 -1
- package/ts/math/Add.ts +6 -6
- package/ts/math/Digit.ts +6 -4
- package/ts/math/GreaterThan.ts +16 -17
- package/ts/math/Max.ts +6 -30
- package/ts/math/Subtract.ts +6 -6
- package/ts/math/index.ts +8 -8
- package/ts/nodejs/index.ts +1 -1
- package/ts/nominal-types/Brand.ts +2 -2
- package/ts/nominal-types/Flavor.ts +32 -32
- package/ts/nominal-types/index.ts +3 -3
- package/ts/nominal-types/nominalMatch.ts +3 -3
- package/ts/object/ANotB.ts +21 -21
- package/ts/object/IsDisjoint.ts +12 -12
- package/ts/object/KeysWithDiffType.ts +3 -3
- package/ts/object/KnownKeys.ts +1 -1
- package/ts/object/OptionalKeys.ts +1 -1
- package/ts/object/Partial.ts +3 -3
- package/ts/object/RecursiveIntersect.ts +1 -1
- package/ts/object/RecursivePartial.ts +1 -1
- package/ts/object/RecursiveRequired.ts +1 -1
- package/ts/object/RequiredKeys.ts +2 -2
- package/ts/object/SpreadRecord.ts +6 -6
- package/ts/object/everyKey.ts +1 -1
- package/ts/object/facade.ts +39 -39
- package/ts/object/filterKey.ts +1 -1
- package/ts/object/findKey.ts +1 -1
- package/ts/object/forEachKey.ts +1 -1
- package/ts/object/getField.ts +1 -1
- package/ts/object/hasKey.ts +7 -7
- package/ts/object/hasProperty.ts +1 -1
- package/ts/object/index.ts +36 -36
- package/ts/object/mapKey.ts +1 -1
- package/ts/object/mapProperties.ts +3 -3
- package/ts/object/omit.ts +36 -36
- package/ts/object/pick.ts +35 -35
- package/ts/object/record.ts +5 -4
- package/ts/object/reduceKey.ts +1 -1
- package/ts/object/replaceProperty.ts +1 -1
- package/ts/object/someKey.ts +1 -1
- package/ts/object/split.ts +5 -4
- package/ts/object/typeOverrideIncompatible.ts +10 -10
- package/ts/predicates/CanAssign.ts +2 -2
- package/ts/predicates/index.ts +8 -8
- package/ts/predicates/isType.ts +30 -30
- package/ts/promise/PromiseValueMerge.ts +1 -1
- package/ts/promise/index.ts +4 -4
- package/ts/testing/index.ts +1 -1
- package/ts/testing/stub.ts +2 -2
- package/ts/utils/index.ts +4 -4
- package/ts/ComposableTypes.spec.ts +0 -29
- package/ts/JSONTypes.spec.ts +0 -43
- package/ts/array/CommonPropKeys.spec.ts +0 -20
- package/ts/array/Concat.spec.ts +0 -21
- package/ts/array/CreateTuple.spec.ts +0 -46
- package/ts/array/DropFirst.spec.ts +0 -21
- package/ts/array/DropLast.spec.ts +0 -21
- package/ts/array/DropMatch.spec.ts +0 -234
- package/ts/array/Filter.spec.ts +0 -107
- package/ts/array/FindFirst.spec.ts +0 -27
- package/ts/array/FindLast.spec.ts +0 -27
- package/ts/array/Head.spec.ts +0 -21
- package/ts/array/IntersectOfProps.spec.ts +0 -14
- package/ts/array/Last.spec.ts +0 -32
- package/ts/array/PadLeft.spec.ts +0 -26
- package/ts/array/Reverse.spec.ts +0 -17
- package/ts/array/Some.spec.ts +0 -79
- package/ts/array/Tail.spec.ts +0 -32
- package/ts/array/UnionOfProps.spec.ts +0 -14
- package/ts/array/UnionOfValues.spec.ts +0 -11
- package/ts/array/literalArray.spec.ts +0 -7
- package/ts/array/reduceWhile.spec.ts +0 -27
- package/ts/assertion/assertType.spec.ts +0 -507
- package/ts/binary/index.spec.ts +0 -28
- package/ts/class/AnyConstructor.spec.ts +0 -13
- package/ts/class/isConstructor.spec.ts +0 -35
- package/ts/function/AnyFunction.spec.ts +0 -21
- package/ts/functional/ChainFn.spec.ts +0 -7
- package/ts/functional/Maybe.spec.ts +0 -42
- package/ts/functional/compose.spec.ts +0 -32
- package/ts/index.spec.ts +0 -7
- package/ts/math/Abs.spec.ts +0 -14
- package/ts/math/Add.spec.ts +0 -82
- package/ts/math/Digit.spec.ts +0 -184
- package/ts/math/GreaterThan.spec.ts +0 -43
- package/ts/math/IsPositive.spec.ts +0 -15
- package/ts/math/IsWhole.spec.ts +0 -19
- package/ts/math/Max.spec.ts +0 -35
- package/ts/math/Subtract.spec.ts +0 -40
- package/ts/nodejs/isNodeError.spec.ts +0 -11
- package/ts/nominal-types/Brand.spec.ts +0 -43
- package/ts/nominal-types/Flavor.spec.ts +0 -51
- package/ts/nominal-types/nominalMatch.spec.ts +0 -54
- package/ts/object/ANotB.spec.ts +0 -78
- package/ts/object/ExcludePropType.spec.ts +0 -13
- package/ts/object/IsDisjoint.spec.ts +0 -25
- package/ts/object/IsRecord.spec.ts +0 -22
- package/ts/object/KeyTypes.spec.ts +0 -9
- package/ts/object/KeyofOptional.spec.ts +0 -8
- package/ts/object/KeysWithDiffType.spec.ts +0 -21
- package/ts/object/KnownKeys.spec.ts +0 -39
- package/ts/object/OptionalKeys.spec.ts +0 -23
- package/ts/object/Partial.spec.ts +0 -49
- package/ts/object/RecursiveIntersect.spec.ts +0 -39
- package/ts/object/RecursiveRequired.spec.ts +0 -57
- package/ts/object/Required.spec.ts +0 -29
- package/ts/object/RequiredKeys.spec.ts +0 -24
- package/ts/object/SpreadRecord.spec.ts +0 -14
- package/ts/object/ValueOf.spec.ts +0 -36
- package/ts/object/everyKey.spec.ts +0 -11
- package/ts/object/facade.spec.ts +0 -22
- package/ts/object/filterKey.spec.ts +0 -8
- package/ts/object/findKey.spec.ts +0 -8
- package/ts/object/forEachKey.spec.ts +0 -9
- package/ts/object/getField.spec.ts +0 -21
- package/ts/object/hasKey.spec.ts +0 -29
- package/ts/object/hasProperty.spec.ts +0 -15
- package/ts/object/mapKey.spec.ts +0 -8
- package/ts/object/mapProperties.spec.ts +0 -27
- package/ts/object/omit.spec.ts +0 -104
- package/ts/object/pick.spec.ts +0 -66
- package/ts/object/record.spec.ts +0 -54
- package/ts/object/reduceKey.spec.ts +0 -18
- package/ts/object/replaceProperty.spec.ts +0 -16
- package/ts/object/run.ts +0 -0
- package/ts/object/someKey.spec.ts +0 -6
- package/ts/object/split.spec.ts +0 -119
- package/ts/object/typeOverrideIncompatible.spec.ts +0 -24
- package/ts/predicates/CanAssign.spec.ts +0 -57
- package/ts/predicates/Equal.spec.ts +0 -71
- package/ts/predicates/If.spec.ts +0 -14
- package/ts/predicates/IsEmptyObject.spec.ts +0 -15
- package/ts/predicates/index.spec.ts +0 -73
- package/ts/predicates/isType.spec.ts +0 -106
- package/ts/predicates/logical.spec.ts +0 -59
- package/ts/promise/PromiseValue.spec.ts +0 -6
- package/ts/promise/PromiseValueMerge.spec.ts +0 -7
- package/ts/promise/isPromise.spec.ts +0 -26
- package/ts/promise/mapSeries.spec.ts +0 -12
- package/ts/testing/stub.spec.ts +0 -58
- package/ts/type-checker/.eslintrc.json +0 -5
- package/ts/type-checker/AnyType.ts +0 -13
- package/ts/type-checker/Boolean.ts +0 -34
- package/ts/type-checker/Tuple.spec.ts +0 -15
- package/ts/type-checker/Tuple.ts +0 -14
- package/ts/type-checker/buildTypes.spec.ts +0 -28
- package/ts/type-checker/index.ts +0 -0
- package/ts/type-checker/typeChecker.spec.ts +0 -14
- package/ts/type-checker/typeChecker.ts +0 -52
- package/ts/type-checker/types.ts +0 -19
- package/ts/types/.eslintrc.json +0 -5
- package/ts/types/AllType.ts +0 -31
- package/ts/types/Any.ts +0 -7
- package/ts/types/Array.ts +0 -43
- package/ts/types/BigInt.ts +0 -36
- package/ts/types/Boolean.ts +0 -36
- package/ts/types/Generate.ts +0 -48
- package/ts/types/Null.ts +0 -14
- package/ts/types/Number.ts +0 -56
- package/ts/types/Object.ts +0 -53
- package/ts/types/Record.ts +0 -25
- package/ts/types/String.ts +0 -56
- package/ts/types/Symbol.ts +0 -19
- package/ts/types/Tuple.ts +0 -50
- package/ts/types/Undefined.ts +0 -8
- package/ts/types/Union.ts +0 -46
- package/ts/types/Unknown.ts +0 -9
- package/ts/types/analyze.spec.ts +0 -979
- package/ts/types/analyze.ts +0 -170
- package/ts/types/check.spec.ts +0 -12
- package/ts/types/check.ts +0 -26
- package/ts/types/conform.spec.ts +0 -7
- package/ts/types/conform.ts +0 -27
- package/ts/types/getPlainAnalysisReport.spec.ts +0 -354
- package/ts/types/getPlainAnalysisReport.ts +0 -115
- package/ts/types/index.ts +0 -28
- package/ts/types/optional.ts +0 -30
- package/ts/types/required.ts +0 -30
- package/ts/types/satisfy.accept.ts +0 -39
- package/ts/types/satisfy.spec.ts +0 -600
- package/ts/types/satisfy.ts +0 -27
- package/ts/types/types.ts +0 -10
- package/ts/utils/as.spec.ts +0 -45
package/ts/types/satisfy.spec.ts
DELETED
|
@@ -1,600 +0,0 @@
|
|
|
1
|
-
import { satisfies } from 'satisfier'
|
|
2
|
-
import { assertType, Equal } from '..'
|
|
3
|
-
import * as T from '.'
|
|
4
|
-
|
|
5
|
-
describe('undefined', () => {
|
|
6
|
-
test('satisfies only undefined', () => {
|
|
7
|
-
expect(T.satisfy(T.undefined, undefined)).toBe(true)
|
|
8
|
-
notSatisfyTypesOtherThan(T.undefined, undefined)
|
|
9
|
-
|
|
10
|
-
const value: unknown = undefined
|
|
11
|
-
if (T.satisfy(T.undefined, value)) {
|
|
12
|
-
assertType<undefined>(value)
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
describe('null', () => {
|
|
18
|
-
test('satisfies only null', () => {
|
|
19
|
-
expect(T.satisfy(T.null, null)).toBe(true)
|
|
20
|
-
notSatisfyTypesOtherThan(T.null, null)
|
|
21
|
-
|
|
22
|
-
const value: unknown = null
|
|
23
|
-
if (T.satisfy(T.null, value)) {
|
|
24
|
-
assertType<null>(value)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
test('optional', () => {
|
|
28
|
-
const t = T.null.optional
|
|
29
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
30
|
-
|
|
31
|
-
const value: unknown = undefined
|
|
32
|
-
if (T.satisfy(t, value)) {
|
|
33
|
-
assertType<null | undefined>(value)
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
describe('boolean', () => {
|
|
39
|
-
test('base type satisfies both true and false', () => {
|
|
40
|
-
expect(T.satisfy(T.boolean, true)).toBe(true)
|
|
41
|
-
expect(T.satisfy(T.boolean, false)).toBe(true)
|
|
42
|
-
notSatisfyTypesOtherThan(T.boolean, true, false)
|
|
43
|
-
|
|
44
|
-
const value: unknown = undefined
|
|
45
|
-
if (T.satisfy(T.boolean, value)) {
|
|
46
|
-
assertType<boolean>(value)
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
test('true', () => {
|
|
50
|
-
expect(T.satisfy(T.boolean.true, true)).toBe(true)
|
|
51
|
-
notSatisfyTypesOtherThan(T.boolean.true, true)
|
|
52
|
-
|
|
53
|
-
const value: unknown = true
|
|
54
|
-
if (T.satisfy(T.boolean.true, value)) {
|
|
55
|
-
assertType<true>(value)
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
test('false', () => {
|
|
59
|
-
expect(T.satisfy(T.boolean.false, false)).toBe(true)
|
|
60
|
-
notSatisfyTypesOtherThan(T.boolean.false, false)
|
|
61
|
-
|
|
62
|
-
const value: unknown = false
|
|
63
|
-
if (T.satisfy(T.boolean.false, value)) {
|
|
64
|
-
assertType<false>(value)
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
test('true does not satisfy False', () => {
|
|
68
|
-
expect(T.satisfy(T.boolean.false, true)).toBe(false)
|
|
69
|
-
})
|
|
70
|
-
test('false does not satisfy True', () => {
|
|
71
|
-
expect(T.satisfy(T.boolean.true, false)).toBe(false)
|
|
72
|
-
})
|
|
73
|
-
test('optional', () => {
|
|
74
|
-
const t = T.boolean.optional
|
|
75
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
76
|
-
|
|
77
|
-
const value: unknown = undefined
|
|
78
|
-
if (T.satisfy(t, value)) {
|
|
79
|
-
assertType<boolean | undefined>(value)
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
test('optional create', () => {
|
|
83
|
-
const t = T.boolean.optional.create(true)
|
|
84
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
85
|
-
|
|
86
|
-
const value: unknown = undefined
|
|
87
|
-
if (T.satisfy(t, value)) {
|
|
88
|
-
assertType<true | undefined>(value)
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
describe('number', () => {
|
|
94
|
-
test('base type satisfy all numbers', () => {
|
|
95
|
-
expect(T.satisfy(T.number, 0)).toBe(true)
|
|
96
|
-
expect(T.satisfy(T.number, -1)).toBe(true)
|
|
97
|
-
expect(T.satisfy(T.number, 1)).toBe(true)
|
|
98
|
-
notSatisfyTypesOtherThan(T.number, -1, 0, 1)
|
|
99
|
-
|
|
100
|
-
const value: unknown = 0
|
|
101
|
-
if (T.satisfy(T.number, value)) {
|
|
102
|
-
assertType<number>(value)
|
|
103
|
-
assertType.isTrue(true as Equal<number, typeof value>)
|
|
104
|
-
assertType.isFalse(false as Equal<0, typeof value>)
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
test('0', () => {
|
|
108
|
-
expect(T.satisfy(T.number.create(0), 0)).toBe(true)
|
|
109
|
-
notSatisfyTypesOtherThan(T.number.create(0), 0)
|
|
110
|
-
|
|
111
|
-
const value: unknown = 0
|
|
112
|
-
if (T.satisfy(T.number.create(0), value)) {
|
|
113
|
-
assertType<0>(value)
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
test('1', () => {
|
|
117
|
-
expect(T.satisfy(T.number.create(1), 1)).toBe(true)
|
|
118
|
-
notSatisfyTypesOtherThan(T.number.create(1), 1)
|
|
119
|
-
|
|
120
|
-
const value: unknown = 1
|
|
121
|
-
if (T.satisfy(T.number.create(1), value)) {
|
|
122
|
-
assertType<1>(value)
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
test('0 does not satisfy 1', () => {
|
|
126
|
-
expect(T.satisfy(T.number.create(1), 0)).toBe(false)
|
|
127
|
-
})
|
|
128
|
-
test('1 does not satisfy 0', () => {
|
|
129
|
-
expect(T.satisfy(T.number.create(0), 1)).toBe(false)
|
|
130
|
-
})
|
|
131
|
-
test('optional', () => {
|
|
132
|
-
const t = T.number.optional
|
|
133
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
134
|
-
|
|
135
|
-
const value: unknown = undefined
|
|
136
|
-
if (T.satisfy(t, value)) {
|
|
137
|
-
assertType<number | undefined>(value)
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
test('optional const', () => {
|
|
141
|
-
const t = T.number.optional.create(1)
|
|
142
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
143
|
-
|
|
144
|
-
const value: unknown = undefined
|
|
145
|
-
if (T.satisfy(t, value)) {
|
|
146
|
-
assertType<1 | undefined>(value)
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
test('list: single', () => {
|
|
150
|
-
const t = T.number.list(0)
|
|
151
|
-
const value: unknown = 0
|
|
152
|
-
|
|
153
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
154
|
-
if (T.satisfy(t, value)) {
|
|
155
|
-
assertType<0>(value)
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
test('list: multiple', () => {
|
|
159
|
-
const t = T.number.list(1, 2, 3)
|
|
160
|
-
const value: unknown = 1
|
|
161
|
-
|
|
162
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
163
|
-
if (T.satisfy(t, value)) {
|
|
164
|
-
assertType<1 | 2 | 3>(value)
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
test('optional.list: multiple', () => {
|
|
168
|
-
const t = T.number.optional.list(1, 2, 3)
|
|
169
|
-
const value: unknown = 1
|
|
170
|
-
|
|
171
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
172
|
-
if (T.satisfy(t, value)) {
|
|
173
|
-
assertType<1 | 2 | 3 | undefined>(value)
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
describe('string', () => {
|
|
179
|
-
test('base type satisfies any string', () => {
|
|
180
|
-
expect(T.satisfy(T.string, '')).toBe(true)
|
|
181
|
-
expect(T.satisfy(T.string, 'a')).toBe(true)
|
|
182
|
-
notSatisfyTypesOtherThan(T.string, '', 'a')
|
|
183
|
-
|
|
184
|
-
const value: unknown = ''
|
|
185
|
-
if (T.satisfy(T.string, value)) {
|
|
186
|
-
assertType<string>(value)
|
|
187
|
-
assertType.isTrue(true as Equal<string, typeof value>)
|
|
188
|
-
assertType.isFalse(false as Equal<'', typeof value>)
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
test(`''`, () => {
|
|
192
|
-
expect(T.satisfy(T.string, '')).toBe(true)
|
|
193
|
-
notSatisfyTypesOtherThan(T.string, '')
|
|
194
|
-
|
|
195
|
-
const value: unknown = ''
|
|
196
|
-
if (T.satisfy(T.string.create(''), value)) {
|
|
197
|
-
assertType<''>(value)
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
test(`'a'`, () => {
|
|
201
|
-
expect(T.satisfy(T.string, 'a')).toBe(true)
|
|
202
|
-
notSatisfyTypesOtherThan(T.string, '', 'a')
|
|
203
|
-
|
|
204
|
-
const value: unknown = 'a'
|
|
205
|
-
if (T.satisfy(T.string.create('a'), value)) {
|
|
206
|
-
assertType<'a'>(value)
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
test(`'' does not satisfy 'a'`, () => {
|
|
210
|
-
expect(T.satisfy(T.string.create('a'), '')).toBe(false)
|
|
211
|
-
})
|
|
212
|
-
test(`'a' does not satisfy ''`, () => {
|
|
213
|
-
expect(T.satisfy(T.string.create(''), 'a')).toBe(false)
|
|
214
|
-
})
|
|
215
|
-
test('optional', () => {
|
|
216
|
-
const t = T.string.optional
|
|
217
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
218
|
-
|
|
219
|
-
const value: unknown = undefined
|
|
220
|
-
if (T.satisfy(t, value)) {
|
|
221
|
-
assertType<string | undefined>(value)
|
|
222
|
-
}
|
|
223
|
-
})
|
|
224
|
-
test('optional const', () => {
|
|
225
|
-
const t = T.string.optional.create('a')
|
|
226
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
227
|
-
|
|
228
|
-
const value: unknown = undefined
|
|
229
|
-
if (T.satisfy(t, value)) {
|
|
230
|
-
assertType<'a' | undefined>(value)
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
test('list: single', () => {
|
|
234
|
-
const t = T.string.list('a')
|
|
235
|
-
const value: unknown = 'a'
|
|
236
|
-
|
|
237
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
238
|
-
if (T.satisfy(t, value)) {
|
|
239
|
-
assertType<'a'>(value)
|
|
240
|
-
}
|
|
241
|
-
})
|
|
242
|
-
test('list: multiple', () => {
|
|
243
|
-
const t = T.string.list('1', '2', '3')
|
|
244
|
-
const value: unknown = '1'
|
|
245
|
-
|
|
246
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
247
|
-
if (T.satisfy(t, value)) {
|
|
248
|
-
assertType<'1' | '2' | '3'>(value)
|
|
249
|
-
}
|
|
250
|
-
})
|
|
251
|
-
test('optional list: multiple', () => {
|
|
252
|
-
const t = T.string.optional.list('1', '2', '3')
|
|
253
|
-
const value: unknown = '1'
|
|
254
|
-
|
|
255
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
256
|
-
if (T.satisfy(t, value)) {
|
|
257
|
-
assertType<'1' | '2' | '3' | undefined>(value)
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
describe('bigint', () => {
|
|
263
|
-
// test('bigint', () => {
|
|
264
|
-
// expect(T.satisfy(T.bigint, 0n)).toBe(true)
|
|
265
|
-
// notSatisfyTypesOtherThan(T.bigint, 0n, 1n)
|
|
266
|
-
|
|
267
|
-
// const value: unknown = 0n
|
|
268
|
-
// if (T.satisfy(T.bigint, value)) {
|
|
269
|
-
// assertType<bigint>(value)
|
|
270
|
-
// assertType.isFalse(assignability<0>()(value))
|
|
271
|
-
// }
|
|
272
|
-
// })
|
|
273
|
-
|
|
274
|
-
// test('bigint:0', () => {
|
|
275
|
-
// expect(T.satisfy(T.bigint.create(0n), 0n)).toBe(true)
|
|
276
|
-
// notSatisfyTypesOtherThan(T.bigint.create(0n), 0n)
|
|
277
|
-
|
|
278
|
-
// const value: unknown = 0n
|
|
279
|
-
// if (T.satisfy(T.bigint.create(0n), value)) {
|
|
280
|
-
// assertType<0n>(value)
|
|
281
|
-
// }
|
|
282
|
-
// })
|
|
283
|
-
|
|
284
|
-
// test('bigint:1', () => {
|
|
285
|
-
// expect(T.satisfy(T.bigint.create(1n), 1n)).toBe(true)
|
|
286
|
-
// notSatisfyTypesOtherThan(T.bigint.create(1n), 1n)
|
|
287
|
-
|
|
288
|
-
// const value: unknown = 1n
|
|
289
|
-
// if (T.satisfy(T.bigint.create(1n), value)) {
|
|
290
|
-
// assertType<1n>(value)
|
|
291
|
-
// }
|
|
292
|
-
// })
|
|
293
|
-
|
|
294
|
-
// test('0n not satisfy 1n', () => {
|
|
295
|
-
// expect(T.satisfy(T.bigint.create(1n), 0n)).toBe(false)
|
|
296
|
-
// })
|
|
297
|
-
|
|
298
|
-
// test('1n not satisfy 0n', () => {
|
|
299
|
-
// expect(T.satisfy(T.bigint.create(0n), 1n)).toBe(false)
|
|
300
|
-
// })
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
describe('symbol', () => {
|
|
304
|
-
test('base type satisfies any symbol', () => {
|
|
305
|
-
expect(T.satisfy(T.symbol, Symbol())).toBe(true)
|
|
306
|
-
notSatisfyTypesOtherThan(T.symbol, Symbol())
|
|
307
|
-
|
|
308
|
-
const value: unknown = Symbol()
|
|
309
|
-
if (T.satisfy(T.symbol, value)) {
|
|
310
|
-
assertType<symbol>(value)
|
|
311
|
-
}
|
|
312
|
-
})
|
|
313
|
-
test('optional', () => {
|
|
314
|
-
const t = T.symbol.optional
|
|
315
|
-
const value: unknown = Symbol()
|
|
316
|
-
|
|
317
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
318
|
-
|
|
319
|
-
if (T.satisfy(t, value)) {
|
|
320
|
-
assertType<symbol | undefined>(value)
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
describe('union', () => {
|
|
326
|
-
test('single type gets the type back', () => {
|
|
327
|
-
const t = T.union.create(T.boolean)
|
|
328
|
-
assertType<T.Boolean>(t)
|
|
329
|
-
})
|
|
330
|
-
test('on two types', () => {
|
|
331
|
-
const t = T.union.create(T.boolean, T.number)
|
|
332
|
-
expect(T.satisfy(t, 0)).toBe(true)
|
|
333
|
-
expect(T.satisfy(t, false)).toBe(true)
|
|
334
|
-
|
|
335
|
-
const value: unknown = 0
|
|
336
|
-
if (T.satisfy(t, value)) {
|
|
337
|
-
assertType<boolean | number>(value)
|
|
338
|
-
}
|
|
339
|
-
})
|
|
340
|
-
test('on multiple primitive types', () => {
|
|
341
|
-
const t = T.union.create(T.boolean, T.null, T.number)
|
|
342
|
-
expect(T.satisfy(t, false)).toBe(true)
|
|
343
|
-
|
|
344
|
-
const value: unknown = true
|
|
345
|
-
if (T.satisfy(t, value)) {
|
|
346
|
-
assertType<boolean | null | number>(value)
|
|
347
|
-
}
|
|
348
|
-
})
|
|
349
|
-
test('nested union is flatten', () => {
|
|
350
|
-
const t = T.union.create(T.union.create(T.boolean, T.null), T.string)
|
|
351
|
-
expect(T.satisfy(t, false)).toBe(true)
|
|
352
|
-
const value: unknown = true
|
|
353
|
-
if (T.satisfy(t, value)) {
|
|
354
|
-
assertType<boolean | string | null>(value)
|
|
355
|
-
}
|
|
356
|
-
})
|
|
357
|
-
test.todo('remove duplicates')
|
|
358
|
-
test('optional create', () => {
|
|
359
|
-
const t = T.union.optional.create(T.boolean)
|
|
360
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
361
|
-
|
|
362
|
-
const value: unknown = undefined
|
|
363
|
-
if (T.satisfy(t, value)) {
|
|
364
|
-
assertType<boolean | undefined>(value)
|
|
365
|
-
}
|
|
366
|
-
})
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
describe('array', () => {
|
|
370
|
-
test('base type satisfies any array and type guard it to any[]', () => {
|
|
371
|
-
expect(T.satisfy(T.array, [])).toBe(true)
|
|
372
|
-
expect(T.satisfy(T.array, ['a'])).toBe(true)
|
|
373
|
-
|
|
374
|
-
const value: unknown = []
|
|
375
|
-
if (T.satisfy(T.array, value)) {
|
|
376
|
-
// Note that this test is weak.
|
|
377
|
-
// I don't have a good way to nail it down as it is a top type.
|
|
378
|
-
assertType<any[]>(value)
|
|
379
|
-
}
|
|
380
|
-
})
|
|
381
|
-
test('base type does not satisfy non-array', () => {
|
|
382
|
-
notSatisfyTypesOtherThan(T.array, [], ['a'])
|
|
383
|
-
})
|
|
384
|
-
test('unknown type assert result to unknown[]', () => {
|
|
385
|
-
expect(T.satisfy(T.array.unknown, [])).toBe(true)
|
|
386
|
-
expect(T.satisfy(T.array.unknown, ['a'])).toBe(true)
|
|
387
|
-
|
|
388
|
-
const value: unknown = []
|
|
389
|
-
if (T.satisfy(T.array.unknown, value)) {
|
|
390
|
-
// Note that this test is weak.
|
|
391
|
-
// I don't have a good way to nail it down as it is a top type.
|
|
392
|
-
assertType<unknown[]>(value)
|
|
393
|
-
}
|
|
394
|
-
})
|
|
395
|
-
test('unknown type does not satisfy non-array', () => {
|
|
396
|
-
notSatisfyTypesOtherThan(T.array.unknown, [], ['a'])
|
|
397
|
-
})
|
|
398
|
-
test('specific type', () => {
|
|
399
|
-
const t = T.array.create(T.number)
|
|
400
|
-
expect(T.satisfy(t, [])).toBe(true)
|
|
401
|
-
expect(T.satisfy(t, [0])).toBe(true)
|
|
402
|
-
expect(T.satisfy(t, [1, 2])).toBe(true)
|
|
403
|
-
expect(T.satisfy(t, ['a'])).toBe(false)
|
|
404
|
-
expect(T.satisfy(t, [1, 'a'])).toBe(false)
|
|
405
|
-
expect(T.satisfy(t, ['a', 1])).toBe(false)
|
|
406
|
-
|
|
407
|
-
const value: unknown = ['a']
|
|
408
|
-
if (T.satisfy(t, value)) {
|
|
409
|
-
assertType<number[]>(value)
|
|
410
|
-
}
|
|
411
|
-
})
|
|
412
|
-
test(`array's value type can be union type`, () => {
|
|
413
|
-
const t = T.array.create(T.union.create(T.number, T.boolean))
|
|
414
|
-
expect(T.satisfy(t, [])).toBe(true)
|
|
415
|
-
expect(T.satisfy(t, [0])).toBe(true)
|
|
416
|
-
expect(T.satisfy(t, [false])).toBe(true)
|
|
417
|
-
expect(T.satisfy(t, [false, 0])).toBe(true)
|
|
418
|
-
expect(T.satisfy(t, [0, false, ''])).toBe(false)
|
|
419
|
-
|
|
420
|
-
const value: unknown = [0, false]
|
|
421
|
-
if (T.satisfy(t, value)) {
|
|
422
|
-
assertType<Array<number | boolean>>(value)
|
|
423
|
-
}
|
|
424
|
-
})
|
|
425
|
-
test('optional', () => {
|
|
426
|
-
const t = T.array.optional
|
|
427
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
428
|
-
|
|
429
|
-
const value: unknown = undefined
|
|
430
|
-
if (T.satisfy(t, value)) {
|
|
431
|
-
assertType<any[] | undefined>(value)
|
|
432
|
-
}
|
|
433
|
-
})
|
|
434
|
-
test('optional create', () => {
|
|
435
|
-
const t = T.array.optional.create(T.string)
|
|
436
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
437
|
-
|
|
438
|
-
const value: unknown = undefined
|
|
439
|
-
if (T.satisfy(t, value)) {
|
|
440
|
-
assertType<string[] | undefined>(value)
|
|
441
|
-
}
|
|
442
|
-
})
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
describe('tuple', () => {
|
|
446
|
-
test('single value', () => {
|
|
447
|
-
const t = T.tuple.create(T.number)
|
|
448
|
-
expect(T.satisfy(t, [0])).toBe(true)
|
|
449
|
-
expect(T.satisfy(t, [''])).toBe(false)
|
|
450
|
-
|
|
451
|
-
const value: unknown = [1]
|
|
452
|
-
if (T.satisfy(t, value)) {
|
|
453
|
-
assertType<[number]>(value)
|
|
454
|
-
}
|
|
455
|
-
})
|
|
456
|
-
test('two values', () => {
|
|
457
|
-
const t = T.tuple.create(T.number, T.string)
|
|
458
|
-
expect(T.satisfy(t, [0, ''])).toBe(true)
|
|
459
|
-
expect(T.satisfy(t, [0])).toBe(false)
|
|
460
|
-
|
|
461
|
-
const value: unknown = [1, 'a']
|
|
462
|
-
if (T.satisfy(t, value)) {
|
|
463
|
-
assertType<[number, string]>(value)
|
|
464
|
-
}
|
|
465
|
-
})
|
|
466
|
-
test('pass with more values than what specified in the type', () => {
|
|
467
|
-
expect(T.satisfy(T.tuple.create(T.number), [1, 'a'])).toBe(true)
|
|
468
|
-
})
|
|
469
|
-
test('optional', () => {
|
|
470
|
-
const t = T.tuple.optional.create(T.boolean)
|
|
471
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
472
|
-
|
|
473
|
-
const value: unknown = undefined
|
|
474
|
-
if (T.satisfy(t, value)) {
|
|
475
|
-
assertType<[boolean] | undefined>(value)
|
|
476
|
-
}
|
|
477
|
-
})
|
|
478
|
-
})
|
|
479
|
-
|
|
480
|
-
describe('object', () => {
|
|
481
|
-
test('base type satisfies any object', () => {
|
|
482
|
-
expect(T.satisfy(T.object, {})).toBe(true)
|
|
483
|
-
expect(T.satisfy(T.object, { a: 1 })).toBe(true)
|
|
484
|
-
expect(T.satisfy(T.object, { 0: 0 })).toBe(true)
|
|
485
|
-
|
|
486
|
-
const value: unknown = { a: 1 }
|
|
487
|
-
if (T.satisfy(T.object, value)) {
|
|
488
|
-
assertType<Record<string, any>>(value)
|
|
489
|
-
}
|
|
490
|
-
})
|
|
491
|
-
test('base type does not satisfy non-object including array and null', () => {
|
|
492
|
-
notSatisfyTypesOtherThan(T.object, {}, { a: 1 })
|
|
493
|
-
})
|
|
494
|
-
test('single prop', () => {
|
|
495
|
-
const t = T.object.create({ a: T.number })
|
|
496
|
-
expect(T.satisfy(t, { a: 0 })).toBe(true)
|
|
497
|
-
expect(T.satisfy(t, { a: 1 })).toBe(true)
|
|
498
|
-
|
|
499
|
-
const value: unknown = { a: 1 }
|
|
500
|
-
if (T.satisfy(t, value)) {
|
|
501
|
-
assertType<{ a: number }>(value)
|
|
502
|
-
}
|
|
503
|
-
})
|
|
504
|
-
test('two props', () => {
|
|
505
|
-
const t = T.object.create({
|
|
506
|
-
a: T.number.create(1),
|
|
507
|
-
b: T.string
|
|
508
|
-
})
|
|
509
|
-
expect(T.satisfy(t, { a: 1, b: '' })).toBe(true)
|
|
510
|
-
expect(T.satisfy(t, { a: 1, b: 'b' })).toBe(true)
|
|
511
|
-
|
|
512
|
-
const value: unknown = { a: 1, b: '' }
|
|
513
|
-
if (T.satisfy(t, value)) {
|
|
514
|
-
assertType<{ a: 1, b: string }>(value)
|
|
515
|
-
}
|
|
516
|
-
})
|
|
517
|
-
test('props with union', () => {
|
|
518
|
-
const t = T.object.create({
|
|
519
|
-
a: T.union.create(T.number.create(1), T.boolean.true),
|
|
520
|
-
b: T.string
|
|
521
|
-
})
|
|
522
|
-
expect(T.satisfy(t, { a: 1, b: '' })).toBe(true)
|
|
523
|
-
expect(T.satisfy(t, { a: true, b: '' })).toBe(true)
|
|
524
|
-
expect(T.satisfy(t, { a: false, b: '' })).toBe(false)
|
|
525
|
-
|
|
526
|
-
const value: unknown = { a: 1, b: '' }
|
|
527
|
-
if (T.satisfy(t, value)) {
|
|
528
|
-
assertType<{ a: true | 1, b: string }>(value)
|
|
529
|
-
}
|
|
530
|
-
})
|
|
531
|
-
test('nested object', () => {
|
|
532
|
-
const t = T.object.create({
|
|
533
|
-
a: T.object.create({
|
|
534
|
-
b: T.number
|
|
535
|
-
})
|
|
536
|
-
})
|
|
537
|
-
expect(T.satisfy(t, { a: { b: 0 } })).toBe(true)
|
|
538
|
-
|
|
539
|
-
const value: unknown = { a: { b: 0 } }
|
|
540
|
-
if (T.satisfy(t, value)) {
|
|
541
|
-
assertType<{ a: { b: number } }>(value)
|
|
542
|
-
}
|
|
543
|
-
})
|
|
544
|
-
test('keys is string + number + symbol', () => {
|
|
545
|
-
// technically empty string is not a valid key.
|
|
546
|
-
// maybe we can do a disjoint or something
|
|
547
|
-
expect(T.satisfy(T.keys, '')).toBe(true)
|
|
548
|
-
expect(T.satisfy(T.keys, 'a')).toBe(true)
|
|
549
|
-
expect(T.satisfy(T.keys, 0)).toBe(true)
|
|
550
|
-
expect(T.satisfy(T.keys, Symbol.for('abc'))).toBe(true)
|
|
551
|
-
})
|
|
552
|
-
test('optional', () => {
|
|
553
|
-
const t = T.object.optional
|
|
554
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
555
|
-
|
|
556
|
-
const value: unknown = undefined
|
|
557
|
-
if (T.satisfy(t, value)) {
|
|
558
|
-
assertType<Record<string, any> | undefined>(value)
|
|
559
|
-
}
|
|
560
|
-
})
|
|
561
|
-
test('optional create', () => {
|
|
562
|
-
const t = T.object.optional.create({
|
|
563
|
-
a: T.string
|
|
564
|
-
})
|
|
565
|
-
expect(T.satisfy(t, undefined)).toBe(true)
|
|
566
|
-
|
|
567
|
-
const value: unknown = undefined
|
|
568
|
-
if (T.satisfy(t, value)) {
|
|
569
|
-
assertType<{ a: string } | undefined>(value)
|
|
570
|
-
}
|
|
571
|
-
})
|
|
572
|
-
})
|
|
573
|
-
|
|
574
|
-
describe('record', () => {
|
|
575
|
-
test('base case', () => {
|
|
576
|
-
const t = T.record.create(T.number)
|
|
577
|
-
const value: any = { 'a': 1 }
|
|
578
|
-
expect(T.satisfy(t, value)).toBe(true)
|
|
579
|
-
|
|
580
|
-
if (T.satisfy(t, value)) {
|
|
581
|
-
assertType<Record<string, number>>(value)
|
|
582
|
-
}
|
|
583
|
-
})
|
|
584
|
-
test('base type does not satisfy non-object including array and null', () => {
|
|
585
|
-
notSatisfyTypesOtherThan(T.record.create(T.null), {}, { a: 1 })
|
|
586
|
-
})
|
|
587
|
-
})
|
|
588
|
-
|
|
589
|
-
// test('if condition', () => {
|
|
590
|
-
// T.If(T.boolean.false, {}, false as const)
|
|
591
|
-
// })
|
|
592
|
-
|
|
593
|
-
function notSatisfyTypesOtherThan(type: T.AllType, ...excepts: any[]) {
|
|
594
|
-
const values = [undefined, null, true, false, 0, 1, 0n, 1n, '', 'a', [], ['a'], {}, { a: 1 }, Symbol(), Symbol.for('a')]
|
|
595
|
-
values.forEach(v => {
|
|
596
|
-
if (!excepts.some(e => satisfies(v, e))) {
|
|
597
|
-
expect(T.satisfy(type, v))
|
|
598
|
-
}
|
|
599
|
-
})
|
|
600
|
-
}
|
package/ts/types/satisfy.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AllType } from './AllType'
|
|
2
|
-
import { analyze } from './analyze'
|
|
3
|
-
import { Generate } from './Generate'
|
|
4
|
-
import { getPlainAnalysisReport } from './getPlainAnalysisReport'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Checks if the specified `subject` satisfies the `type`.
|
|
8
|
-
* `satisfy()` is the shortcut of `check({ strict: false }, ...)`.
|
|
9
|
-
* @return type guard (boolean). If the subject does not satisfies the type,
|
|
10
|
-
* the detail report is available in `satisfy.result`,
|
|
11
|
-
* and you can get a string report using `satisfy.getReport()`
|
|
12
|
-
*/
|
|
13
|
-
export function satisfy<T extends AllType>(type: T, subject: unknown): subject is Generate<T> {
|
|
14
|
-
const result = satisfy.result = analyze({ strict: false }, type, subject)
|
|
15
|
-
return !result.analysis.fail
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Analysis report.
|
|
20
|
-
*/
|
|
21
|
-
satisfy.result = { analysis: {} } as analyze.Result
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Gets a simple report of the analysis.
|
|
25
|
-
*/
|
|
26
|
-
satisfy.getReport = () => getPlainAnalysisReport(satisfy.result)
|
|
27
|
-
|
package/ts/types/types.ts
DELETED
package/ts/utils/as.spec.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { amend, as, asAny, isType } from '..'
|
|
2
|
-
|
|
3
|
-
describe('as<T>()', () => {
|
|
4
|
-
test('defaults subject type to unknown', () => {
|
|
5
|
-
const s: any = {}
|
|
6
|
-
const a = as(s)
|
|
7
|
-
isType.equal<true, unknown, typeof a>()
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
test('cast type to T', () => {
|
|
11
|
-
const s: any = {}
|
|
12
|
-
const n = as<number>(s)
|
|
13
|
-
isType.equal<true, number, typeof n>()
|
|
14
|
-
|
|
15
|
-
const str = as<string>(s)
|
|
16
|
-
isType.equal<true, string, typeof str>()
|
|
17
|
-
|
|
18
|
-
const o = as<{ a: number }>(s)
|
|
19
|
-
isType.equal<true, { a: number }, typeof o>()
|
|
20
|
-
|
|
21
|
-
const any = as<any>(s)
|
|
22
|
-
isType.equal<true, any, typeof any>()
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
describe('asAny()', () => {
|
|
27
|
-
test('cast type to any', () => {
|
|
28
|
-
const s: unknown = {}
|
|
29
|
-
const a = asAny(s)
|
|
30
|
-
isType.equal<true, any, typeof a>()
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
describe('amend<T>()', () => {
|
|
35
|
-
test('assert subject as (subject & T)', () => {
|
|
36
|
-
const s = { a: 1 }
|
|
37
|
-
const a = amend(s).union<{ b: string }>()
|
|
38
|
-
isType.equal<true, { a: number } & { b: string }, typeof a>()
|
|
39
|
-
})
|
|
40
|
-
test('assert subject as (subject | T)', () => {
|
|
41
|
-
const s = { a: 1 }
|
|
42
|
-
const a = amend(s).intersect<{ b: string }>()
|
|
43
|
-
isType.equal<true, { a: number } | { b: string }, typeof a>()
|
|
44
|
-
})
|
|
45
|
-
})
|