type-plus 8.0.0-beta.7 → 8.0.0-beta.8
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/cjs/array/array.reverse.d.ts +1 -1
- package/cjs/array/array.reverse.d.ts.map +1 -1
- package/cjs/array/literal_array.js +1 -2
- package/cjs/array/literal_array.js.map +1 -1
- package/cjs/array/reduce_while.js +1 -2
- package/cjs/array/reduce_while.js.map +1 -1
- package/cjs/assertion/assert_type.d.ts +1 -1
- package/cjs/assertion/assert_type.d.ts.map +1 -1
- package/cjs/assertion/assert_type.js +1 -4
- package/cjs/assertion/assert_type.js.map +1 -1
- package/cjs/class/isConstructor.js +2 -3
- package/cjs/class/isConstructor.js.map +1 -1
- package/cjs/function/extract_function.d.ts.map +1 -1
- package/cjs/function/extract_function.js +1 -2
- package/cjs/function/extract_function.js.map +1 -1
- package/cjs/functional/Maybe.js +2 -3
- package/cjs/functional/Maybe.js.map +1 -1
- package/cjs/functional/compose.js +1 -2
- package/cjs/functional/compose.js.map +1 -1
- package/cjs/functional/context.js +1 -2
- package/cjs/functional/context.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/json.js +1 -1
- package/cjs/json.js.map +1 -1
- package/cjs/math/numeric_struct.d.ts.map +1 -1
- package/cjs/mix_types/merge.js +1 -2
- package/cjs/mix_types/merge.js.map +1 -1
- package/cjs/nodejs/isNodeError.js +1 -2
- package/cjs/nodejs/isNodeError.js.map +1 -1
- package/cjs/nominal/brand.js +1 -2
- package/cjs/nominal/brand.js.map +1 -1
- package/cjs/nominal/flavor.js +1 -2
- package/cjs/nominal/flavor.js.map +1 -1
- package/cjs/nominal/nominal_match.js +1 -2
- package/cjs/nominal/nominal_match.js.map +1 -1
- package/cjs/object/ANotB.d.ts +1 -1
- package/cjs/object/ANotB.d.ts.map +1 -1
- package/cjs/object/KeysWithDiffType.d.ts +1 -1
- package/cjs/object/KeysWithDiffType.d.ts.map +1 -1
- package/cjs/object/adjust_exact_optional_props.d.ts +7 -4
- package/cjs/object/adjust_exact_optional_props.d.ts.map +1 -1
- package/cjs/object/everyKey.js +1 -2
- package/cjs/object/everyKey.js.map +1 -1
- package/cjs/object/facade.js +1 -2
- package/cjs/object/facade.js.map +1 -1
- package/cjs/object/filterKey.js +1 -2
- package/cjs/object/filterKey.js.map +1 -1
- package/cjs/object/findKey.js +1 -2
- package/cjs/object/findKey.js.map +1 -1
- package/cjs/object/forEachKey.js +1 -2
- package/cjs/object/forEachKey.js.map +1 -1
- package/cjs/object/getField.js +1 -2
- package/cjs/object/getField.js.map +1 -1
- package/cjs/object/hasKey.js +1 -2
- package/cjs/object/hasKey.js.map +1 -1
- package/cjs/object/hasProperty.js +1 -2
- package/cjs/object/hasProperty.js.map +1 -1
- package/cjs/object/index.d.ts +6 -6
- package/cjs/object/index.d.ts.map +1 -1
- package/cjs/object/index.js.map +1 -1
- package/cjs/object/left_join.d.ts +1 -1
- package/cjs/object/left_join.d.ts.map +1 -1
- package/cjs/object/mapKey.js +1 -2
- package/cjs/object/mapKey.js.map +1 -1
- package/cjs/object/mapProperties.d.ts +1 -1
- package/cjs/object/mapProperties.d.ts.map +1 -1
- package/cjs/object/mapProperties.js +1 -2
- package/cjs/object/mapProperties.js.map +1 -1
- package/cjs/object/merge.d.ts +1 -1
- package/cjs/object/merge.d.ts.map +1 -1
- package/cjs/object/omit.js +1 -2
- package/cjs/object/omit.js.map +1 -1
- package/cjs/object/optional_key.d.ts +1 -1
- package/cjs/object/optional_key.d.ts.map +1 -1
- package/cjs/object/pick.js +1 -2
- package/cjs/object/pick.js.map +1 -1
- package/cjs/object/properties.d.ts +29 -4
- package/cjs/object/properties.d.ts.map +1 -1
- package/cjs/object/properties.js +1 -0
- package/cjs/object/properties.js.map +1 -1
- package/cjs/object/record.d.ts.map +1 -1
- package/cjs/object/record.js +1 -2
- package/cjs/object/record.js.map +1 -1
- package/cjs/object/reduceKey.js +2 -2
- package/cjs/object/reduceKey.js.map +1 -1
- package/cjs/object/replaceProperty.js +1 -2
- package/cjs/object/replaceProperty.js.map +1 -1
- package/cjs/object/someKey.js +1 -2
- package/cjs/object/someKey.js.map +1 -1
- package/cjs/object/split.d.ts +1 -1
- package/cjs/object/split.d.ts.map +1 -1
- package/cjs/object/split.js +1 -2
- package/cjs/object/split.js.map +1 -1
- package/cjs/object/typeOverrideIncompatible.d.ts.map +1 -1
- package/cjs/object/typeOverrideIncompatible.js +1 -2
- package/cjs/object/typeOverrideIncompatible.js.map +1 -1
- package/cjs/predicates/CanAssign.d.ts +1 -1
- package/cjs/predicates/CanAssign.d.ts.map +1 -1
- package/cjs/predicates/CanAssign.js +1 -2
- package/cjs/predicates/CanAssign.js.map +1 -1
- package/cjs/predicates/index.d.ts +1 -1
- package/cjs/predicates/index.d.ts.map +1 -1
- package/cjs/predicates/index.js.map +1 -1
- package/cjs/promise/MaybePromise.js +2 -2
- package/cjs/promise/MaybePromise.js.map +1 -1
- package/cjs/promise/index.d.ts +1 -1
- package/cjs/promise/index.d.ts.map +1 -1
- package/cjs/promise/index.js +1 -1
- package/cjs/promise/index.js.map +1 -1
- package/cjs/promise/isPromise.js +2 -3
- package/cjs/promise/isPromise.js.map +1 -1
- package/cjs/promise/mapSeries.js +1 -2
- package/cjs/promise/mapSeries.js.map +1 -1
- package/cjs/string/$extract_manipulated_string.d.ts.map +1 -1
- package/cjs/string/_string_type.d.ts.map +1 -1
- package/cjs/testing/stub.d.ts +2 -2
- package/cjs/testing/stub.d.ts.map +1 -1
- package/cjs/testing/stub.js +1 -2
- package/cjs/testing/stub.js.map +1 -1
- package/cjs/tuple/drop.js +1 -2
- package/cjs/tuple/drop.js.map +1 -1
- package/cjs/type-guard/is_type.d.ts +2 -2
- package/cjs/type-guard/is_type.d.ts.map +1 -1
- package/cjs/type-guard/is_type.js +1 -2
- package/cjs/type-guard/is_type.js.map +1 -1
- package/cjs/union/union_to_intersection.js +1 -2
- package/cjs/union/union_to_intersection.js.map +1 -1
- package/cjs/utils/as.d.ts +1 -1
- package/cjs/utils/as.d.ts.map +1 -1
- package/cjs/utils/as.js +3 -4
- package/cjs/utils/as.js.map +1 -1
- package/cjs/utils/inspect.js +1 -2
- package/cjs/utils/inspect.js.map +1 -1
- package/esm/array/array.reverse.d.ts +1 -1
- package/esm/array/array.reverse.d.ts.map +1 -1
- package/esm/assertion/assert_type.d.ts +1 -1
- package/esm/assertion/assert_type.d.ts.map +1 -1
- package/esm/assertion/assert_type.js +0 -2
- package/esm/assertion/assert_type.js.map +1 -1
- package/esm/function/extract_function.d.ts.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/json.js +1 -1
- package/esm/json.js.map +1 -1
- package/esm/math/numeric_struct.d.ts.map +1 -1
- package/esm/object/ANotB.d.ts +1 -1
- package/esm/object/ANotB.d.ts.map +1 -1
- package/esm/object/KeysWithDiffType.d.ts +1 -1
- package/esm/object/KeysWithDiffType.d.ts.map +1 -1
- package/esm/object/adjust_exact_optional_props.d.ts +7 -4
- package/esm/object/adjust_exact_optional_props.d.ts.map +1 -1
- package/esm/object/index.d.ts +6 -6
- package/esm/object/index.d.ts.map +1 -1
- package/esm/object/index.js.map +1 -1
- package/esm/object/left_join.d.ts +1 -1
- package/esm/object/left_join.d.ts.map +1 -1
- package/esm/object/mapProperties.d.ts +1 -1
- package/esm/object/mapProperties.d.ts.map +1 -1
- package/esm/object/mapProperties.js.map +1 -1
- package/esm/object/merge.d.ts +1 -1
- package/esm/object/merge.d.ts.map +1 -1
- package/esm/object/optional_key.d.ts +1 -1
- package/esm/object/optional_key.d.ts.map +1 -1
- package/esm/object/properties.d.ts +29 -4
- package/esm/object/properties.d.ts.map +1 -1
- package/esm/object/properties.js +1 -0
- package/esm/object/properties.js.map +1 -1
- package/esm/object/record.d.ts.map +1 -1
- package/esm/object/split.d.ts +1 -1
- package/esm/object/split.d.ts.map +1 -1
- package/esm/object/typeOverrideIncompatible.d.ts.map +1 -1
- package/esm/predicates/CanAssign.d.ts +1 -1
- package/esm/predicates/CanAssign.d.ts.map +1 -1
- package/esm/predicates/index.d.ts +1 -1
- package/esm/predicates/index.d.ts.map +1 -1
- package/esm/predicates/index.js.map +1 -1
- package/esm/promise/index.d.ts +1 -1
- package/esm/promise/index.d.ts.map +1 -1
- package/esm/promise/index.js +1 -1
- package/esm/promise/index.js.map +1 -1
- package/esm/promise/isPromise.js +1 -1
- package/esm/promise/isPromise.js.map +1 -1
- package/esm/string/$extract_manipulated_string.d.ts.map +1 -1
- package/esm/string/_string_type.d.ts.map +1 -1
- package/esm/testing/stub.d.ts +2 -2
- package/esm/testing/stub.d.ts.map +1 -1
- package/esm/type-guard/is_type.d.ts +2 -2
- package/esm/type-guard/is_type.d.ts.map +1 -1
- package/esm/utils/as.d.ts +1 -1
- package/esm/utils/as.d.ts.map +1 -1
- package/package.json +16 -20
- package/src/array/array.reverse.ts +2 -5
- package/src/assertion/assert_type.ts +0 -2
- package/src/index.ts +1 -1
- package/src/json.ts +1 -1
- package/src/math/numeric_struct.ts +6 -6
- package/src/object/ANotB.ts +1 -1
- package/src/object/KeysWithDiffType.ts +1 -1
- package/src/object/adjust_exact_optional_props.ts +11 -2
- package/src/object/index.ts +6 -6
- package/src/object/left_join.ts +1 -1
- package/src/object/mapProperties.ts +1 -1
- package/src/object/merge.ts +1 -1
- package/src/object/optional_key.ts +1 -1
- package/src/object/properties.ts +35 -2
- package/src/object/record.ts +1 -1
- package/src/object/split.ts +1 -1
- package/src/predicates/CanAssign.ts +1 -1
- package/src/predicates/index.ts +1 -1
- package/src/promise/index.ts +1 -1
- package/src/promise/isPromise.ts +1 -1
- package/src/string/$extract_manipulated_string.ts +32 -28
- package/src/string/_string_type.ts +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_type.d.ts","sourceRoot":"","sources":["../../src/type-guard/is_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,CAAA;AACnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,IAAI,CAAC,CAAA;yBAAvE,MAAM
|
|
1
|
+
{"version":3,"file":"is_type.d.ts","sourceRoot":"","sources":["../../src/type-guard/is_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,CAAA;AACnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,IAAI,CAAC,CAAA;yBAAvE,MAAM;YAQV,CAAC,SAAS,IAAI,YAAY,CAAC;YAK3B,CAAC,SAAS,KAAK,YAAY,CAAC;;gBAyBxB,EAAE,SAAS,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;;AAvB9C;;;GAGG;AACH,iBAAS,OAAO,CAAC,EAAE,SAAS,KAAK,KAAK,OAAO,CAAA;AAC7C;;;GAGG;AACH,iBAAS,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,IAAI,KAAK,CAAA"}
|
package/esm/utils/as.d.ts
CHANGED
package/esm/utils/as.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../src/utils/as.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAEzC;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAE3C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../src/utils/as.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAEzC;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAE3C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;UAE3B,CAAC,KAAK,CAAC,GAAG,CAAC;cAGP,CAAC,KAAK,CAAC,GAAG,CAAC;EAItB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-plus",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.8",
|
|
4
4
|
"description": "Provides additional types for TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"assert",
|
|
@@ -55,46 +55,42 @@
|
|
|
55
55
|
"unpartial": "^1.0.4"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@jest/globals": "^29.5.0",
|
|
59
|
-
"@repobuddy/jest": "^4.0.0",
|
|
60
58
|
"@repobuddy/typescript": "^2.0.0",
|
|
61
59
|
"@size-limit/esbuild-why": "^11.1.5",
|
|
62
60
|
"@size-limit/preset-small-lib": "^11.1.5",
|
|
63
61
|
"@types/node": "^18.11.11",
|
|
62
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
64
63
|
"assertron": "^11.0.2",
|
|
65
64
|
"cross-env": "^7.0.3",
|
|
66
|
-
"
|
|
67
|
-
"jest": "^29.7.0",
|
|
68
|
-
"jest-watch-suspend": "^1.1.2",
|
|
69
|
-
"jest-watch-toggle-config-2": "^2.1.0",
|
|
70
|
-
"jest-watch-typeahead": "^2.2.2",
|
|
71
|
-
"npm-run-all2": "^7.0.0",
|
|
65
|
+
"npm-run-all2": "^8.0.0",
|
|
72
66
|
"rimraf": "^6.0.0",
|
|
73
67
|
"size-limit": "^11.1.5",
|
|
74
68
|
"ts-5.4": "npm:typescript@~5.4.0",
|
|
75
69
|
"ts-5.5": "npm:typescript@~5.5.0",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
70
|
+
"typescript": "~5.6.0",
|
|
71
|
+
"vitest": "^4.0.15"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"typescript": ">= 5.6.0"
|
|
78
75
|
},
|
|
79
76
|
"scripts": {
|
|
80
77
|
"build": "run-p build:*",
|
|
81
78
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
82
79
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
83
|
-
"build:doc": "typedoc",
|
|
84
80
|
"clean": "rimraf cjs coverage esm lib libm tslib --glob *.tsbuildinfo",
|
|
85
|
-
"coverage": "
|
|
86
|
-
"
|
|
81
|
+
"coverage": "vitest run --coverage",
|
|
82
|
+
"knip": "knip",
|
|
87
83
|
"nuke": "run-p clean nuke:local",
|
|
88
84
|
"nuke:local": "rimraf node_modules",
|
|
89
85
|
"size": "size-limit",
|
|
90
|
-
"test": "
|
|
86
|
+
"test": "vitest run",
|
|
91
87
|
"test:type": "run-p test:type:*",
|
|
92
|
-
"test:type:latest": "./node_modules/typescript/bin/tsc --noEmit",
|
|
93
88
|
"test:type:54": "./node_modules/ts-5.4/bin/tsc -p tsconfig.ts54.json --noEmit",
|
|
94
89
|
"test:type:55": "./node_modules/ts-5.5/bin/tsc -p tsconfig.ts55.json --noEmit",
|
|
95
|
-
"test:
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
90
|
+
"test:type:latest": "./node_modules/typescript/bin/tsc --noEmit",
|
|
91
|
+
"test:watch": "vitest watch",
|
|
92
|
+
"verify": "npm-run-all clean -p build knip lint coverage -p size",
|
|
93
|
+
"w": "vitest watch",
|
|
94
|
+
"watch": "vitest watch"
|
|
99
95
|
}
|
|
100
96
|
}
|
|
@@ -13,11 +13,8 @@ import type { IsReadonly } from './array_plus.is_readonly.js'
|
|
|
13
13
|
* @param T The array type to reverse.
|
|
14
14
|
* @returns The reversed array type.
|
|
15
15
|
*/
|
|
16
|
-
export type Reverse<A extends readonly unknown[]> =
|
|
17
|
-
? IsReadonly<A> extends true
|
|
18
|
-
? Readonly<R>
|
|
19
|
-
: R
|
|
20
|
-
: never
|
|
16
|
+
export type Reverse<A extends readonly unknown[]> =
|
|
17
|
+
Reverse._<A> extends infer R ? (IsReadonly<A> extends true ? Readonly<R> : R) : never
|
|
21
18
|
|
|
22
19
|
export namespace Reverse {
|
|
23
20
|
export type _<A extends readonly unknown[]> = A extends readonly [infer First, ...infer Rest]
|
|
@@ -58,7 +58,6 @@ assertType.isTrue = (subject: true): asserts subject is true => {
|
|
|
58
58
|
if (subject !== true) throw TypeError('subject is not true')
|
|
59
59
|
}
|
|
60
60
|
assertType.noTrue = <S>(subject: Exclude<S, true>): void => {
|
|
61
|
-
// @ts-ignore
|
|
62
61
|
if (subject === true) throw TypeError('subject is true')
|
|
63
62
|
}
|
|
64
63
|
|
|
@@ -66,7 +65,6 @@ assertType.isFalse = (subject: false): asserts subject is false => {
|
|
|
66
65
|
if (subject !== false) throw TypeError('subject is not false')
|
|
67
66
|
}
|
|
68
67
|
assertType.noFalse = <S>(subject: Exclude<S, false>): void => {
|
|
69
|
-
// @ts-ignore
|
|
70
68
|
if (subject === false) throw TypeError('subject is false')
|
|
71
69
|
}
|
|
72
70
|
|
package/src/index.ts
CHANGED
|
@@ -114,8 +114,8 @@ export * from './testing/stub.js'
|
|
|
114
114
|
export * from './testing/test_type.js'
|
|
115
115
|
export type { CommonKeys, CommonPropKeys } from './tuple/common_prop_keys.js'
|
|
116
116
|
export * from './tuple/create_tuple.js'
|
|
117
|
-
export { drop } from './tuple/drop.js'
|
|
118
117
|
export type { DropFirst, DropLast, DropMatch, DropNull, DropNullable, DropUndefined } from './tuple/drop.js'
|
|
118
|
+
export { drop } from './tuple/drop.js'
|
|
119
119
|
export type * from './tuple/is_not_tuple.js'
|
|
120
120
|
export type * from './tuple/is_tuple.js'
|
|
121
121
|
export type { Tail } from './tuple/tail.js'
|
package/src/json.ts
CHANGED
|
@@ -12,6 +12,6 @@ function get<T extends JSONTypes>(obj: JSONTypes, ...props: Array<string | numbe
|
|
|
12
12
|
if (props.length === 0) return obj as T
|
|
13
13
|
if (typeof obj !== 'object' || obj === null) return undefined
|
|
14
14
|
const p = props.shift()!
|
|
15
|
-
// @ts-
|
|
15
|
+
// @ts-expect-error
|
|
16
16
|
return get(obj[p], ...props) as T
|
|
17
17
|
}
|
|
@@ -96,12 +96,12 @@ export namespace NumericStruct {
|
|
|
96
96
|
*
|
|
97
97
|
* It includes the normalization of the `NumericStruct`.
|
|
98
98
|
*/
|
|
99
|
-
export type ToNumeric<M extends NumericStruct> =
|
|
100
|
-
string
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
export type ToNumeric<M extends NumericStruct> =
|
|
100
|
+
DigitsStruct.ToString<M[DIGITS_STRUCT]> extends infer S extends string
|
|
101
|
+
? M[TYPE] extends 'bigint'
|
|
102
|
+
? StringToBigint<S, StringToNumber<S, `The value '${S}' cannot be represented as bigint or number`>>
|
|
103
|
+
: StringToNumber<S, StringToBigint<S, `The value '${S}' cannot be represented as bigint or number`>>
|
|
104
|
+
: never
|
|
105
105
|
|
|
106
106
|
export type Add<A extends NumericStruct, B extends NumericStruct> = [
|
|
107
107
|
A[TYPE],
|
package/src/object/ANotB.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IsEqual } from '../equal/is_equal.js'
|
|
2
|
+
import type { AnyRecord } from './any_record.js'
|
|
2
3
|
import type { IsDisjoint } from './IsDisjoint.js'
|
|
3
4
|
import type { KeysWithDiffType } from './KeysWithDiffType.js'
|
|
4
|
-
import type { AnyRecord } from './any_record.js'
|
|
5
5
|
|
|
6
6
|
export type ANotB<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true
|
|
7
7
|
? never
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { AnyRecord } from './any_record.js'
|
|
1
2
|
import type { IsDisjoint } from './IsDisjoint.js'
|
|
2
3
|
import type { ValueOf } from './ValueOf.js'
|
|
3
|
-
import type { AnyRecord } from './any_record.js'
|
|
4
4
|
|
|
5
5
|
export type KeysWithDiffType<A extends AnyRecord, B extends AnyRecord> = IsDisjoint<A, B> extends true
|
|
6
6
|
? never
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RequiredKeys } from './RequiredKeys.js'
|
|
2
1
|
import type { AnyRecord } from './any_record.js'
|
|
3
2
|
import type { OptionalKeys } from './optional_key.js'
|
|
3
|
+
import type { RequiredKeys } from './RequiredKeys.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* ⚗️ *transform*
|
|
@@ -10,5 +10,14 @@ import type { OptionalKeys } from './optional_key.js'
|
|
|
10
10
|
* It adds `undefined` to optional properties.
|
|
11
11
|
*/
|
|
12
12
|
export type AdjustExactOptionalProps<T extends AnyRecord> = T extends object
|
|
13
|
-
? { [K in OptionalKeys<T>]?: T[K] | undefined }
|
|
13
|
+
? [{ [K in OptionalKeys<T>]?: T[K] | undefined }, { [K in RequiredKeys<T>]: T[K] }] extends [
|
|
14
|
+
infer O extends AnyRecord,
|
|
15
|
+
infer R extends AnyRecord,
|
|
16
|
+
]
|
|
17
|
+
? keyof O extends never
|
|
18
|
+
? R
|
|
19
|
+
: keyof R extends never
|
|
20
|
+
? O
|
|
21
|
+
: O & R
|
|
22
|
+
: never
|
|
14
23
|
: never
|
package/src/object/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type * from './adjust_exact_optional_props.js'
|
|
2
1
|
export type { ANotB, BNotA } from './ANotB.js'
|
|
2
|
+
export type * from './adjust_exact_optional_props.js'
|
|
3
3
|
export type { AnyRecord } from './any_record.js'
|
|
4
|
-
export * from './everyKey.js'
|
|
5
4
|
export type { ExcludePropType } from './ExcludePropType.js'
|
|
5
|
+
export * from './everyKey.js'
|
|
6
6
|
export * from './facade.js'
|
|
7
7
|
export * from './filterKey.js'
|
|
8
8
|
export * from './findKey.js'
|
|
@@ -25,15 +25,15 @@ export type * from './optional_key.js'
|
|
|
25
25
|
export type { Partial, PartialExcept, PartialOmit, PartialPick } from './Partial.js'
|
|
26
26
|
export * from './pick.js'
|
|
27
27
|
export type { Properties } from './properties.js'
|
|
28
|
-
export * from './record.js'
|
|
29
|
-
export type { RecursivePartial } from './recursive_partial.js'
|
|
30
28
|
export type { RecursiveIntersect } from './RecursiveIntersect.js'
|
|
31
29
|
export type { RecursiveRequired } from './RecursiveRequired.js'
|
|
30
|
+
export type { RequiredKeys } from './RequiredKeys.js'
|
|
31
|
+
export * from './record.js'
|
|
32
|
+
export type { RecursivePartial } from './recursive_partial.js'
|
|
32
33
|
export * from './reduceKey.js'
|
|
33
34
|
export * from './replaceProperty.js'
|
|
34
|
-
export type {
|
|
35
|
+
export type { SpreadRecord } from './SpreadRecord.js'
|
|
35
36
|
export * from './someKey.js'
|
|
36
37
|
export * from './split.js'
|
|
37
|
-
export type { SpreadRecord } from './SpreadRecord.js'
|
|
38
38
|
export * from './typeOverrideIncompatible.js'
|
|
39
39
|
export type { ValueOf } from './ValueOf.js'
|
package/src/object/left_join.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IsEqual } from '../equal/is_equal.js'
|
|
2
|
-
import type { IsDisjoint } from './IsDisjoint.js'
|
|
3
2
|
import type { AnyRecord } from './any_record.js'
|
|
3
|
+
import type { IsDisjoint } from './IsDisjoint.js'
|
|
4
4
|
import type { Properties } from './properties.js'
|
|
5
5
|
|
|
6
6
|
export type LeftJoin<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true
|
package/src/object/merge.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type { Or } from '../logical/logical.js'
|
|
|
5
5
|
import type { IsNever } from '../never/is_never.js'
|
|
6
6
|
import type { IsNotNever } from '../never/is_not_never.js'
|
|
7
7
|
import type { IsLiteral } from '../predicates/literal.js'
|
|
8
|
+
import type { AnyRecord } from './any_record.js'
|
|
8
9
|
import type { IsDisjoint } from './IsDisjoint.js'
|
|
9
10
|
import type { KeyTypes } from './KeyTypes.js'
|
|
10
|
-
import type { AnyRecord } from './any_record.js'
|
|
11
11
|
import type { OptionalKeys } from './optional_key.js'
|
|
12
12
|
|
|
13
13
|
/**
|
package/src/object/properties.ts
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
+
import type { IsAny } from '../any/is_any.js'
|
|
2
|
+
import type { IsUnknown } from '../unknown/is_unknown.js'
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* Extracts the property map of a type: an object type with the same keys and
|
|
6
|
+
* value types as `T`, preserving optional and readonly modifiers.
|
|
7
|
+
*
|
|
8
|
+
* - For object types: returns `{ [k in keyof T]: T[k] }`.
|
|
9
|
+
* - For `any` and `unknown`: returns the input type unchanged.
|
|
10
|
+
* - For function types (e.g. `() => void`): returns `{}` because call signatures
|
|
11
|
+
* are not indexable; for `Function`, returns the interface of methods.
|
|
12
|
+
* - For intersections: merges properties from all branches.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam T - The type whose properties to extract.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* type T = { a: number; b?: string }
|
|
19
|
+
* type R = Properties<T> // { a: number; b?: string }
|
|
20
|
+
*
|
|
21
|
+
* type Merged = Properties<{ a: 1 } & { b: 2 }> // { a: 1; b: 2 }
|
|
22
|
+
* ```
|
|
3
23
|
*/
|
|
4
|
-
export type Properties<T> =
|
|
24
|
+
export type Properties<T> = IsAny<
|
|
25
|
+
T,
|
|
26
|
+
{
|
|
27
|
+
$then: T
|
|
28
|
+
$else: IsUnknown<
|
|
29
|
+
T,
|
|
30
|
+
{
|
|
31
|
+
$then: T
|
|
32
|
+
$else: { [k in keyof T]: T[k] } // & {}
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
// [unknown] extends [T] ? unknown : { [k in keyof T]: T[k] } // & {}
|
package/src/object/record.ts
CHANGED
package/src/object/split.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Partial } from './Partial.js'
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
2
|
import type { AnyRecord } from './any_record.js'
|
|
4
3
|
import type { Omit } from './omit.js'
|
|
4
|
+
import type { Partial } from './Partial.js'
|
|
5
5
|
import { reduceByKey } from './reduceKey.js'
|
|
6
6
|
|
|
7
7
|
type Splitter<T extends AnyRecord> = Partial<{ [k in keyof T]: T[k] | undefined }>
|
package/src/predicates/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export type { And, Not, Or, Xor } from '../logical/logical.js'
|
|
1
2
|
export * from './CanAssign.js'
|
|
2
3
|
export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends.js'
|
|
3
4
|
export type { If } from './If.js'
|
|
4
5
|
export type { IsEmptyObject } from './IsEmptyObject.js'
|
|
5
6
|
export type { IsLiteral } from './literal.js'
|
|
6
|
-
export type { And, Not, Or, Xor } from '../logical/logical.js'
|
package/src/promise/index.ts
CHANGED
package/src/promise/isPromise.ts
CHANGED
|
@@ -19,32 +19,36 @@ export type $ExtractManipulatedString<T extends string> = [T, unknown] extends [
|
|
|
19
19
|
>
|
|
20
20
|
|
|
21
21
|
export namespace $ExtractManipulatedString {
|
|
22
|
-
export type _UpperOrElse<N, Else> =
|
|
23
|
-
|
|
24
|
-
?
|
|
25
|
-
?
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
export type _UpperOrElse<N, Else> =
|
|
23
|
+
N extends Uppercase<infer Y>
|
|
24
|
+
? string extends Y
|
|
25
|
+
? Uppercase<any> extends N
|
|
26
|
+
? Y
|
|
27
|
+
: N
|
|
28
|
+
: $ExtractManipulatedString<Y>
|
|
29
|
+
: Else
|
|
30
|
+
export type _LowerOrElse<N, Else> =
|
|
31
|
+
N extends Lowercase<infer Y>
|
|
32
|
+
? string extends Y
|
|
33
|
+
? Lowercase<any> extends N
|
|
34
|
+
? Y
|
|
35
|
+
: N
|
|
36
|
+
: $ExtractManipulatedString<Y>
|
|
37
|
+
: Else
|
|
38
|
+
export type _CapOrElse<N, Else> =
|
|
39
|
+
N extends Capitalize<infer Y>
|
|
40
|
+
? string extends Y
|
|
41
|
+
? Capitalize<any> extends N
|
|
42
|
+
? Y
|
|
43
|
+
: N
|
|
44
|
+
: $ExtractManipulatedString<Y>
|
|
45
|
+
: Else
|
|
46
|
+
export type _UncapOrElse<N, Else> =
|
|
47
|
+
N extends Uncapitalize<infer Y>
|
|
48
|
+
? string extends Y
|
|
49
|
+
? Uncapitalize<any> extends N
|
|
50
|
+
? Y
|
|
51
|
+
: N
|
|
52
|
+
: $ExtractManipulatedString<Y>
|
|
53
|
+
: Else
|
|
50
54
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { $ExtractManipulatedString } from './$extract_manipulated_string.js'
|
|
2
2
|
|
|
3
|
-
export type _StringType<T extends string> =
|
|
4
|
-
|
|
5
|
-
?
|
|
6
|
-
?
|
|
7
|
-
?
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export type _StringType<T extends string> =
|
|
4
|
+
$ExtractManipulatedString<T> extends infer K
|
|
5
|
+
? K extends string & infer U
|
|
6
|
+
? [K, U] extends [U, K]
|
|
7
|
+
? {} extends { [P in `${K}`]: unknown }
|
|
8
|
+
? 'templateLiteral'
|
|
9
|
+
: 'stringLiteral'
|
|
10
|
+
: 'string'
|
|
11
|
+
: never
|
|
10
12
|
: never
|
|
11
|
-
: never
|