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
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { assertType, ExcludePropType } from '..'
|
|
2
|
-
|
|
3
|
-
test('exclude type R from properties of T', () => {
|
|
4
|
-
interface Customer {
|
|
5
|
-
name: string,
|
|
6
|
-
age: number | null,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type CustomerAgeNotNull = ExcludePropType<Customer, null>
|
|
10
|
-
|
|
11
|
-
const x: CustomerAgeNotNull = { name: '', age: 0 }
|
|
12
|
-
assertType.isNumber(x.age)
|
|
13
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { isType, IsDisjoint } from '..'
|
|
2
|
-
|
|
3
|
-
test('disjoint returns true', () => {
|
|
4
|
-
type A = { a: 1 }
|
|
5
|
-
type B = { b: 1 }
|
|
6
|
-
isType.t<IsDisjoint<A, B>>()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('same type returns false', () => {
|
|
10
|
-
type A = { a: 1 }
|
|
11
|
-
type B = { a: 1 }
|
|
12
|
-
isType.f<IsDisjoint<A, B>>()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('A subset of B returns false', () => {
|
|
16
|
-
type A = { a: 1 }
|
|
17
|
-
type B = { a: 1, b: 1 }
|
|
18
|
-
isType.f<IsDisjoint<A, B>>()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('B subset of A returns false', () => {
|
|
22
|
-
type A = { a: 1, b: 1 }
|
|
23
|
-
type B = { a: 1 }
|
|
24
|
-
isType.f<IsDisjoint<A, B>>()
|
|
25
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { assertType, IsRecord } from '..'
|
|
2
|
-
|
|
3
|
-
test('boolean, number, string, null, undefined, symbol are not record', () => {
|
|
4
|
-
assertType.isFalse(false as IsRecord<undefined>)
|
|
5
|
-
assertType.isFalse(false as IsRecord<null>)
|
|
6
|
-
assertType.isFalse(false as IsRecord<boolean>)
|
|
7
|
-
assertType.isFalse(false as IsRecord<number>)
|
|
8
|
-
assertType.isFalse(false as IsRecord<string>)
|
|
9
|
-
assertType.isFalse(false as IsRecord<symbol>)
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('array is not record', () => {
|
|
13
|
-
assertType.isFalse(false as IsRecord<[]>)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
test('object is record', () => {
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
18
|
-
assertType.isTrue(true as IsRecord<{}>)
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
|
-
assertType.isTrue(true as IsRecord<object>)
|
|
21
|
-
assertType.isTrue(true as IsRecord<{ a: string }>)
|
|
22
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { assertType, KeysWithDiffType } from '..'
|
|
2
|
-
|
|
3
|
-
test('disjoint type gets never', () => {
|
|
4
|
-
type A = { a: 1 }
|
|
5
|
-
type B = { b: 2 }
|
|
6
|
-
const actual = 'a' as KeysWithDiffType<A, B>
|
|
7
|
-
assertType<never>(actual)
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
test('key with same type is not included', () => {
|
|
11
|
-
type A = { a: 1 }
|
|
12
|
-
const actual = 'a' as KeysWithDiffType<A, A>
|
|
13
|
-
assertType<never>(actual)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
test('key with different type is returned', () => {
|
|
17
|
-
type A = { a: 1 }
|
|
18
|
-
type B = { a: 2 }
|
|
19
|
-
const actual = 'a' as KeysWithDiffType<A, B>
|
|
20
|
-
assertType<'a'>(actual)
|
|
21
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { assertType, KnownKeys } from '..'
|
|
2
|
-
|
|
3
|
-
test('pick out only known keys', () => {
|
|
4
|
-
type A = {
|
|
5
|
-
a?: boolean,
|
|
6
|
-
b?: number,
|
|
7
|
-
[k: string]: any,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const input: A = {}
|
|
11
|
-
const actual = getKnownKeys(input)
|
|
12
|
-
assertType<'a' | 'b'>(actual)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('primitive type yields never', () => {
|
|
16
|
-
assertType<never>(getKnownKeys(undefined))
|
|
17
|
-
assertType<never>(getKnownKeys(true))
|
|
18
|
-
assertType<never>(getKnownKeys(false))
|
|
19
|
-
assertType<never>(getKnownKeys(null))
|
|
20
|
-
assertType<never>(getKnownKeys('str'))
|
|
21
|
-
assertType<never>(getKnownKeys(1))
|
|
22
|
-
assertType<never>(getKnownKeys({}))
|
|
23
|
-
assertType<never>(getKnownKeys([]))
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('literal gets keys', () => {
|
|
27
|
-
assertType<'a'>(getKnownKeys({ a: 1 }))
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('empty record yields never', () => {
|
|
31
|
-
const x: Record<any, any> = {}
|
|
32
|
-
const actual = getKnownKeys(x)
|
|
33
|
-
assertType<never>(actual)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function getKnownKeys<T>(_value: T): KnownKeys<T> {
|
|
38
|
-
return {} as unknown as KnownKeys<T>
|
|
39
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { assertType, IsEqual, OptionalKeys } from '..'
|
|
2
|
-
|
|
3
|
-
test('extract optional keys from object', () => {
|
|
4
|
-
type X = { a?: string, b: string }
|
|
5
|
-
|
|
6
|
-
assertType.isTrue(true as IsEqual<'a', OptionalKeys<X>>)
|
|
7
|
-
})
|
|
8
|
-
test('work with union type', () => {
|
|
9
|
-
type X = { a?: string, b: string } | { c: string, d?: string }
|
|
10
|
-
|
|
11
|
-
type A = OptionalKeys<X>
|
|
12
|
-
assertType.isTrue(true as IsEqual<'a' | 'd', A>)
|
|
13
|
-
})
|
|
14
|
-
test('no optional keys returns never', () => {
|
|
15
|
-
type X = { b: string }
|
|
16
|
-
|
|
17
|
-
assertType.isTrue(true as IsEqual<never, OptionalKeys<X>>)
|
|
18
|
-
})
|
|
19
|
-
test('keys with undefined value is not optional', () => {
|
|
20
|
-
type X = { a: string | undefined }
|
|
21
|
-
|
|
22
|
-
assertType.isTrue(true as IsEqual<never, OptionalKeys<X>>)
|
|
23
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { assertType, PartialExcept, PartialOmit, PartialPick } from '..'
|
|
2
|
-
|
|
3
|
-
test('work on primitive type', () => {
|
|
4
|
-
type Foo = PartialPick<number, 'toFixed'>
|
|
5
|
-
const x: Foo = 1
|
|
6
|
-
assertType<typeof x['toFixed']>(1 as unknown as 1['toFixed'] | undefined)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('make picked properties optional', () => {
|
|
10
|
-
type Foo = {
|
|
11
|
-
a: number,
|
|
12
|
-
b: number,
|
|
13
|
-
c: number,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const y: PartialPick<Foo, 'a'> = { b: 1, c: 2 }
|
|
17
|
-
|
|
18
|
-
y.a = undefined
|
|
19
|
-
assertType.noUndefined(y.b)
|
|
20
|
-
assertType.noUndefined(y.c)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test('make not specified properties optional', () => {
|
|
24
|
-
type Foo = {
|
|
25
|
-
a: number,
|
|
26
|
-
b: number,
|
|
27
|
-
c: number,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const y: PartialExcept<Foo, 'a'> = { a: 1 }
|
|
31
|
-
assertType.noUndefined(y.a)
|
|
32
|
-
y.b = undefined
|
|
33
|
-
y.c = undefined
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
test('make not specified properties optional', () => {
|
|
38
|
-
type Foo = {
|
|
39
|
-
a: number,
|
|
40
|
-
b: number,
|
|
41
|
-
c: number,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const y: PartialOmit<Foo, 'a'> = { a: 1 }
|
|
45
|
-
|
|
46
|
-
assertType.noUndefined(y.a)
|
|
47
|
-
y.b = undefined
|
|
48
|
-
y.c = undefined
|
|
49
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { RecursiveIntersect } from '..'
|
|
2
|
-
|
|
3
|
-
test('add object type to types', () => {
|
|
4
|
-
type U = { u: number }
|
|
5
|
-
|
|
6
|
-
acceptU(addU('a'))
|
|
7
|
-
acceptU(addU(1))
|
|
8
|
-
acceptU(addU(true))
|
|
9
|
-
// acceptU(addU(1n))
|
|
10
|
-
acceptU(addU(undefined))
|
|
11
|
-
acceptU(addU(null))
|
|
12
|
-
|
|
13
|
-
const obj = addU({ x: 1 })
|
|
14
|
-
acceptU(obj)
|
|
15
|
-
acceptU(obj.x)
|
|
16
|
-
|
|
17
|
-
const comObj = addU({ array: ['a'] })
|
|
18
|
-
acceptU(comObj)
|
|
19
|
-
acceptU(comObj.array)
|
|
20
|
-
acceptU(comObj.array[0])
|
|
21
|
-
|
|
22
|
-
const arr = addU(['1'])
|
|
23
|
-
acceptU(arr)
|
|
24
|
-
acceptU(arr[0])
|
|
25
|
-
|
|
26
|
-
// Not supported
|
|
27
|
-
// const comArr = addU([{ x: 1 }])
|
|
28
|
-
// acceptU(comArr)
|
|
29
|
-
// acceptU(comArr[0])
|
|
30
|
-
// acceptU(comArr[0].x)
|
|
31
|
-
|
|
32
|
-
function addU<T>(x: T): RecursiveIntersect<T, U> {
|
|
33
|
-
return x as any as RecursiveIntersect<T, U>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function acceptU(x: U) {
|
|
37
|
-
return x
|
|
38
|
-
}
|
|
39
|
-
})
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import t from 'assert'
|
|
2
|
-
import { RecursiveRequired } from '..'
|
|
3
|
-
|
|
4
|
-
test('simple optional property becomes required', () => {
|
|
5
|
-
type SimpleOptional = {
|
|
6
|
-
x?: string,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const actual: RecursiveRequired<SimpleOptional> = { x: '' }
|
|
10
|
-
t.strictEqual(actual.x.length, 0)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('deep optional object property becomes required', () => {
|
|
14
|
-
type DeepOptonal = {
|
|
15
|
-
x: {
|
|
16
|
-
y?: string,
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const actual: RecursiveRequired<DeepOptonal> = { x: { y: '' } }
|
|
21
|
-
t.strictEqual(actual.x.y.length, 0)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('deep optional array property becomes required', () => {
|
|
25
|
-
type DeepArrayOptonal = {
|
|
26
|
-
x: {
|
|
27
|
-
y?: string,
|
|
28
|
-
}[],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const actual: RecursiveRequired<DeepArrayOptonal> = { x: [{ y: '' }] }
|
|
32
|
-
t.strictEqual(actual.x[0].y.length, 0)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
// Not supported
|
|
36
|
-
|
|
37
|
-
// test('simple optional array property becomes required', () => {
|
|
38
|
-
// type SimpleArrayOptonal = Array<{ y?: string }>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// let actual: RecursiveRequired<SimpleArrayOptonal> = [{ y: '' }]
|
|
42
|
-
// t.strictEqual(actual[0].y.length, 0)
|
|
43
|
-
// })
|
|
44
|
-
|
|
45
|
-
// test('deep optional tuple property becomes required', () => {
|
|
46
|
-
// type DeepArrayOptonal = {
|
|
47
|
-
// x: [{
|
|
48
|
-
// y?: string
|
|
49
|
-
// }, {
|
|
50
|
-
// z?: string
|
|
51
|
-
// }]
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// let actual: RecursiveRequired<DeepArrayOptonal> = { x: [{ y: '' }, { z: '' }] }
|
|
55
|
-
// t.strictEqual(actual.x[0].y.length, 0)
|
|
56
|
-
// t.strictEqual(actual.x[1].z.length, 0)
|
|
57
|
-
// })
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assertType, RequiredExcept, RequiredPick } from '..'
|
|
2
|
-
|
|
3
|
-
test('make picked properties required', () => {
|
|
4
|
-
type Foo = {
|
|
5
|
-
a?: number,
|
|
6
|
-
b?: number,
|
|
7
|
-
c: number,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const y: RequiredPick<Foo, 'a'> = { a: 1, c: 2 }
|
|
11
|
-
|
|
12
|
-
assertType.noUndefined(y.a)
|
|
13
|
-
y.b = undefined
|
|
14
|
-
assertType.noUndefined(y.c)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('make not picked properties required', () => {
|
|
18
|
-
type Foo = {
|
|
19
|
-
a?: number,
|
|
20
|
-
b?: number,
|
|
21
|
-
c: number,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const y: RequiredExcept<Foo, 'a'> = { b: 1, c: 2 }
|
|
25
|
-
|
|
26
|
-
y.a = undefined
|
|
27
|
-
assertType.noUndefined(y.b)
|
|
28
|
-
assertType.noUndefined(y.c)
|
|
29
|
-
})
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { assertType, IsEqual, RequiredKeys } from '..'
|
|
2
|
-
|
|
3
|
-
test('extract required keys from object', () => {
|
|
4
|
-
type X = { a?: string, b: string }
|
|
5
|
-
|
|
6
|
-
type A = RequiredKeys<X>
|
|
7
|
-
assertType.isTrue(true as IsEqual<'b', A>)
|
|
8
|
-
})
|
|
9
|
-
test('work with union type', () => {
|
|
10
|
-
type X = { a?: string, b: string } | { c: string, d?: string }
|
|
11
|
-
|
|
12
|
-
type A = RequiredKeys<X>
|
|
13
|
-
assertType.isTrue(true as IsEqual<'b' | 'c', A>)
|
|
14
|
-
})
|
|
15
|
-
test('no required keys returns never', () => {
|
|
16
|
-
type X = { b?: string }
|
|
17
|
-
|
|
18
|
-
assertType.isTrue(true as IsEqual<never, RequiredKeys<X>>)
|
|
19
|
-
})
|
|
20
|
-
test('keys with undefined value is required', () => {
|
|
21
|
-
type X = { a: string | undefined }
|
|
22
|
-
|
|
23
|
-
assertType.isTrue(true as IsEqual<'a', RequiredKeys<X>>)
|
|
24
|
-
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { assertType, Equal, SpreadRecord } from '..'
|
|
2
|
-
|
|
3
|
-
test('records are combined as intersection', () => {
|
|
4
|
-
type S = SpreadRecord<{ a: number }, { b: string }>
|
|
5
|
-
assertType.isTrue(true as Equal<S, { a: number } & { b: string }>)
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('Property in B overrides A', () => {
|
|
9
|
-
type A = { a: number }
|
|
10
|
-
type B = { a: string, b: string }
|
|
11
|
-
type S = SpreadRecord<A, B>
|
|
12
|
-
|
|
13
|
-
assertType.isTrue(true as Equal<S, { a: string, b: string }>)
|
|
14
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { isType, ValueOf } from '..'
|
|
2
|
-
|
|
3
|
-
test('work with primitive type', () => {
|
|
4
|
-
type A = ValueOf<string>
|
|
5
|
-
isType.equal<false, never, A>()
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('If all values has the same type, the result is of that type', () => {
|
|
9
|
-
const HTTP_METHOD = {
|
|
10
|
-
GET: 'GET',
|
|
11
|
-
POST: 'POST',
|
|
12
|
-
DELETE: 'DELETE',
|
|
13
|
-
PUT: 'PUT',
|
|
14
|
-
}
|
|
15
|
-
type A = ValueOf<typeof HTTP_METHOD>
|
|
16
|
-
isType.equal<true, string, A>()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test('If value has multiple types, the result is the union of those types', () => {
|
|
20
|
-
const logLevel = {
|
|
21
|
-
none: '0',
|
|
22
|
-
error: '1',
|
|
23
|
-
warn: 2,
|
|
24
|
-
info: 3,
|
|
25
|
-
debug: 4,
|
|
26
|
-
}
|
|
27
|
-
type A = ValueOf<typeof logLevel>
|
|
28
|
-
isType.equal<true, string | number, A>()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('literal types are preserved', () => {
|
|
32
|
-
type L = { a: 1, b: 2, c: 'a', d: 'b' }
|
|
33
|
-
type A = ValueOf<L>
|
|
34
|
-
isType.equal<true, 1 | 2 | 'a' | 'b', A>()
|
|
35
|
-
})
|
|
36
|
-
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { everyKey } from '..'
|
|
2
|
-
|
|
3
|
-
test('predicate key can be used as indexer of the subject', () => {
|
|
4
|
-
const subject = { a: 1, b: 2, c: 3 }
|
|
5
|
-
expect(everyKey(subject, key => typeof subject[key] === 'number')).toBe(true)
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('type this arg', () => {
|
|
9
|
-
const subject = { b: 2 }
|
|
10
|
-
expect(everyKey(subject, function () { return this.a === 1 }, { a: 1 })).toBe(true)
|
|
11
|
-
})
|
package/ts/object/facade.spec.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { facade } from '..'
|
|
2
|
-
|
|
3
|
-
test('facade on property', () => {
|
|
4
|
-
const subject = { a: 1, b: 2, c: 3 }
|
|
5
|
-
|
|
6
|
-
const actual = facade(subject, 'a', 'b')
|
|
7
|
-
expect(actual.a).toBe(1)
|
|
8
|
-
expect(actual.b).toBe(2)
|
|
9
|
-
|
|
10
|
-
actual.b = 4
|
|
11
|
-
expect(subject.b).toBe(4)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('facade on function', () => {
|
|
15
|
-
const subject = {
|
|
16
|
-
a: 1,
|
|
17
|
-
foo() { return this.a },
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const actual = facade(subject, 'foo')
|
|
21
|
-
expect(actual.foo()).toBe(1)
|
|
22
|
-
})
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import t from 'assert'
|
|
2
|
-
import { forEachKey } from '..'
|
|
3
|
-
|
|
4
|
-
test('predicate key can be used as indexer of the subject', () => {
|
|
5
|
-
const subject = { a: 1, b: 2, c: 3 }
|
|
6
|
-
let actual = 0
|
|
7
|
-
forEachKey(subject, key => actual += subject[key])
|
|
8
|
-
t.strictEqual(actual, 6)
|
|
9
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getField } from '..'
|
|
2
|
-
|
|
3
|
-
test('support undefined', () => {
|
|
4
|
-
const sub: { a: number } | undefined = { a: 1 }
|
|
5
|
-
expect(getField(sub, 'a')).toBe(1)
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('support null', () => {
|
|
9
|
-
const sub: { a: number } | null = { a: 1 }
|
|
10
|
-
expect(getField(sub, 'a')).toBe(1)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('can specify default value', () => {
|
|
14
|
-
const sub: { a?: number } = { a: undefined }
|
|
15
|
-
expect(getField(sub, 'a', 2)).toBe(2)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('get from union keys', () => {
|
|
19
|
-
const sub: { a: number, b: string } | { a: number, c: string } = { a: 1, b: 'b' }
|
|
20
|
-
expect(getField(sub, 'b')).toBe('b')
|
|
21
|
-
})
|
package/ts/object/hasKey.spec.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assertType, HasKey, hasKey } from '..'
|
|
2
|
-
|
|
3
|
-
describe('HasKey<T, K>', () => {
|
|
4
|
-
test('true if has key', () => {
|
|
5
|
-
type Foo = { a: 1, b: 2 }
|
|
6
|
-
assertType.isTrue(true as HasKey<Foo, 'a'>)
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('false if do not have key', () => {
|
|
10
|
-
type Foo = { a: 1, b: 2 }
|
|
11
|
-
assertType.isFalse(false as HasKey<Foo, 'c'>)
|
|
12
|
-
})
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('hasKey()', () => {
|
|
16
|
-
test('true if has key', () => {
|
|
17
|
-
const subject = { a: 1, b: 2 }
|
|
18
|
-
|
|
19
|
-
expect(hasKey(subject, 'a')).toBeTruthy()
|
|
20
|
-
expect(hasKey(subject, 'b')).toBeTruthy()
|
|
21
|
-
expect(hasKey(subject, 'a', 'b')).toBeTruthy()
|
|
22
|
-
})
|
|
23
|
-
test('false if do not have key', () => {
|
|
24
|
-
const subject = { a: 1, b: 2 }
|
|
25
|
-
|
|
26
|
-
expect(hasKey(subject, 'c')).toBeFalsy()
|
|
27
|
-
expect(hasKey(subject, 'a', 'c')).toBeFalsy()
|
|
28
|
-
})
|
|
29
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { hasProperty } from '..'
|
|
2
|
-
|
|
3
|
-
test('hasProperty', () => {
|
|
4
|
-
type X = { name: string } & ({ a: 1 } | { b: 2 })
|
|
5
|
-
|
|
6
|
-
const x: X = { name: 'n', a: 1 }
|
|
7
|
-
|
|
8
|
-
if (hasProperty(x, 'a'))
|
|
9
|
-
expect(x.a).toBe(1)
|
|
10
|
-
|
|
11
|
-
const y: X = { name: 'n', b: 2 }
|
|
12
|
-
|
|
13
|
-
if (hasProperty(y, 'b'))
|
|
14
|
-
expect(y.b).toBe(2)
|
|
15
|
-
})
|
package/ts/object/mapKey.spec.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { mapProperties } from '..'
|
|
2
|
-
|
|
3
|
-
test('basic usage', () => {
|
|
4
|
-
const actual = mapProperties({ a: 1, b: 2 }, (v, k) => k + String((v * 2)))
|
|
5
|
-
expect(actual).toEqual({ a: 'a2', b: 'b4' })
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('mixed type', () => {
|
|
9
|
-
const actual = mapProperties({ a: 1, b: 'b' }, (v, k) => k + String(v))
|
|
10
|
-
expect(actual).toEqual({ a: 'a1', b: 'bb' })
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('extract value from prop', () => {
|
|
14
|
-
const actual = mapProperties({ a: { foo: 'x' }, b: { foo: 'y' } }, (v) => v.foo)
|
|
15
|
-
expect(actual).toEqual({ a: 'x', b: 'y' })
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('parent props are not mapped', () => {
|
|
19
|
-
class Boo {
|
|
20
|
-
shared(v: number) { return v * 2 }
|
|
21
|
-
own = (v: number) => v * 3
|
|
22
|
-
}
|
|
23
|
-
const boo = new Boo()
|
|
24
|
-
|
|
25
|
-
const actual = mapProperties(boo, (v) => v(2))
|
|
26
|
-
expect(actual).toEqual({ own: 6 })
|
|
27
|
-
})
|