@depup/type-fest 5.5.0-depup.0 → 5.9.0-depup.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/README.md +2 -2
- package/changes.json +1 -1
- package/index.d.ts +16 -8
- package/package.json +8 -6
- package/readme.md +85 -61
- package/source/absolute.d.ts +52 -0
- package/source/all-extend.d.ts +6 -4
- package/source/all-union-fields.d.ts +18 -18
- package/source/and.d.ts +1 -1
- package/source/array-reverse.d.ts +4 -3
- package/source/array-splice.d.ts +24 -24
- package/source/array-tail.d.ts +4 -4
- package/source/camel-case.d.ts +38 -5
- package/source/camel-cased-properties-deep.d.ts +11 -4
- package/source/camel-cased-properties.d.ts +5 -1
- package/source/conditional-keys.d.ts +1 -1
- package/source/delimiter-case.d.ts +11 -9
- package/source/delimiter-cased-properties-deep.d.ts +8 -1
- package/source/delimiter-cased-properties.d.ts +5 -1
- package/source/empty-object.d.ts +1 -1
- package/source/entries.d.ts +1 -1
- package/source/entry.d.ts +1 -1
- package/source/exclude-exactly.d.ts +11 -11
- package/source/exclude-rest-element.d.ts +4 -4
- package/source/exclusify-union.d.ts +4 -4
- package/source/extends-strict.d.ts +129 -22
- package/source/extract-exactly.d.ts +56 -0
- package/source/get.d.ts +1 -1
- package/source/greater-than.d.ts +3 -2
- package/source/has-optional-keys.d.ts +1 -1
- package/source/has-readonly-keys.d.ts +1 -1
- package/source/has-required-keys.d.ts +1 -1
- package/source/has-writable-keys.d.ts +1 -1
- package/source/int-closed-range.d.ts +1 -3
- package/source/int-range.d.ts +3 -5
- package/source/internal/array.d.ts +8 -8
- package/source/internal/keys.d.ts +9 -9
- package/source/internal/numeric.d.ts +19 -27
- package/source/internal/object.d.ts +44 -6
- package/source/internal/string.d.ts +1 -76
- package/source/internal/tuple.d.ts +2 -2
- package/source/internal/type.d.ts +16 -10
- package/source/is-boolean-literal.d.ts +39 -0
- package/source/is-integer.d.ts +8 -8
- package/source/is-literal.d.ts +43 -267
- package/source/is-numeric-literal.d.ts +50 -0
- package/source/is-string-literal.d.ts +72 -0
- package/source/is-symbol-literal.d.ts +39 -0
- package/source/is-union.d.ts +12 -12
- package/source/iterable-element.d.ts +5 -5
- package/source/jsonify.d.ts +5 -9
- package/source/kebab-case.d.ts +1 -0
- package/source/kebab-cased-properties-deep.d.ts +7 -0
- package/source/kebab-cased-properties.d.ts +5 -1
- package/source/keys-of-union.d.ts +2 -2
- package/source/last-array-element.d.ts +66 -13
- package/source/less-than-or-equal.d.ts +1 -1
- package/source/literal-to-primitive.d.ts +1 -1
- package/source/literal-union.d.ts +1 -1
- package/source/merge-exclusive.d.ts +3 -3
- package/source/multidimensional-array.d.ts +1 -1
- package/source/multidimensional-readonly-array.d.ts +1 -1
- package/source/non-nullable-deep.d.ts +102 -0
- package/source/numeric.d.ts +3 -3
- package/source/object-merge.d.ts +21 -16
- package/source/omit-deep.d.ts +22 -22
- package/source/or.d.ts +1 -1
- package/source/package-json.d.ts +7 -7
- package/source/partial-deep.d.ts +3 -1
- package/source/pascal-case.d.ts +1 -0
- package/source/pascal-cased-properties-deep.d.ts +7 -0
- package/source/pascal-cased-properties.d.ts +5 -1
- package/source/pick-deep.d.ts +2 -0
- package/source/readonly-deep.d.ts +5 -3
- package/source/remove-prefix.d.ts +16 -34
- package/source/remove-suffix.d.ts +114 -0
- package/source/rename-keys.d.ts +163 -0
- package/source/replace.d.ts +2 -2
- package/source/require-all-or-none.d.ts +5 -5
- package/source/require-at-least-one.d.ts +9 -11
- package/source/require-exactly-one.d.ts +7 -7
- package/source/require-one-or-none.d.ts +5 -5
- package/source/required-deep.d.ts +3 -1
- package/source/schema.d.ts +16 -8
- package/source/screaming-snake-case.d.ts +1 -0
- package/source/set-non-nullable-deep.d.ts +8 -4
- package/source/set-non-nullable.d.ts +1 -1
- package/source/set-optional.d.ts +5 -5
- package/source/set-readonly.d.ts +3 -3
- package/source/set-required-deep.d.ts +3 -2
- package/source/set-required.d.ts +3 -3
- package/source/shared-union-fields-deep.d.ts +4 -3
- package/source/shared-union-fields.d.ts +9 -9
- package/source/snake-case.d.ts +1 -0
- package/source/snake-cased-properties-deep.d.ts +7 -0
- package/source/snake-cased-properties.d.ts +5 -1
- package/source/some-extend.d.ts +6 -4
- package/source/split-on-rest-element.d.ts +6 -4
- package/source/split.d.ts +1 -1
- package/source/string-length.d.ts +38 -0
- package/source/string-repeat.d.ts +48 -21
- package/source/string-slice.d.ts +1 -1
- package/source/string-to-array.d.ts +97 -0
- package/source/string-to-number.d.ts +67 -0
- package/source/subtract.d.ts +4 -3
- package/source/sum.d.ts +5 -4
- package/source/tagged.d.ts +3 -5
- package/source/tsconfig-json.d.ts +40 -8
- package/source/tuple-of.d.ts +42 -8
- package/source/typed-array.d.ts +1 -0
- package/source/union-length.d.ts +27 -0
- package/source/union-to-intersection.d.ts +1 -1
- package/source/union-to-tuple.d.ts +8 -4
- package/source/unwrap-required.d.ts +37 -0
- package/source/words.d.ts +30 -4
- package/source/writable.d.ts +14 -14
- package/source/xor.d.ts +1 -1
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/type-fest
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [type-fest](https://www.npmjs.com/package/type-fest) @ 5.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [type-fest](https://www.npmjs.com/package/type-fest) @ 5.9.0 |
|
|
17
|
+
| Processed | 2026-09-06 |
|
|
18
18
|
| Smoke test | failed |
|
|
19
19
|
| Deps updated | 0 |
|
|
20
20
|
|
package/changes.json
CHANGED
package/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export type {OmitIndexSignature} from './source/omit-index-signature.d.ts';
|
|
|
34
34
|
export type {PickIndexSignature} from './source/pick-index-signature.d.ts';
|
|
35
35
|
export type {PartialDeep, PartialDeepOptions} from './source/partial-deep.d.ts';
|
|
36
36
|
export type {UnwrapPartial} from './source/unwrap-partial.d.ts';
|
|
37
|
+
export type {UnwrapRequired} from './source/unwrap-required.d.ts';
|
|
37
38
|
export type {RequiredDeep} from './source/required-deep.d.ts';
|
|
38
39
|
export type {PickDeep} from './source/pick-deep.d.ts';
|
|
39
40
|
export type {OmitDeep} from './source/omit-deep.d.ts';
|
|
@@ -52,6 +53,7 @@ export type {SetRequired} from './source/set-required.d.ts';
|
|
|
52
53
|
export type {SetRequiredDeep} from './source/set-required-deep.d.ts';
|
|
53
54
|
export type {SetNonNullable} from './source/set-non-nullable.d.ts';
|
|
54
55
|
export type {SetNonNullableDeep} from './source/set-non-nullable-deep.d.ts';
|
|
56
|
+
export type {NonNullableDeep} from './source/non-nullable-deep.d.ts';
|
|
55
57
|
export type {ValueOf} from './source/value-of.d.ts';
|
|
56
58
|
export type {AsyncReturnType} from './source/async-return-type.d.ts';
|
|
57
59
|
export type {ConditionalExcept} from './source/conditional-except.d.ts';
|
|
@@ -101,6 +103,7 @@ export type {KeyAsString} from './source/key-as-string.d.ts';
|
|
|
101
103
|
export type {Exact} from './source/exact.d.ts';
|
|
102
104
|
export type {ReadonlyTuple} from './source/readonly-tuple.d.ts';
|
|
103
105
|
export type {OverrideProperties} from './source/override-properties.d.ts';
|
|
106
|
+
export type {RenameKeys} from './source/rename-keys.d.ts';
|
|
104
107
|
export type {OptionalKeysOf} from './source/optional-keys-of.d.ts';
|
|
105
108
|
export type {IsOptionalKeyOf} from './source/is-optional-key-of.d.ts';
|
|
106
109
|
export type {HasOptionalKeys} from './source/has-optional-keys.d.ts';
|
|
@@ -125,13 +128,11 @@ export type {UnionToTuple} from './source/union-to-tuple.d.ts';
|
|
|
125
128
|
export type {IntRange} from './source/int-range.d.ts';
|
|
126
129
|
export type {IntClosedRange} from './source/int-closed-range.d.ts';
|
|
127
130
|
export type {IsEqual} from './source/is-equal.d.ts';
|
|
128
|
-
export type {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
IsSymbolLiteral,
|
|
134
|
-
} from './source/is-literal.d.ts';
|
|
131
|
+
export type {IsLiteral} from './source/is-literal.d.ts';
|
|
132
|
+
export type {IsStringLiteral} from './source/is-string-literal.d.ts';
|
|
133
|
+
export type {IsNumericLiteral} from './source/is-numeric-literal.d.ts';
|
|
134
|
+
export type {IsBooleanLiteral} from './source/is-boolean-literal.d.ts';
|
|
135
|
+
export type {IsSymbolLiteral} from './source/is-symbol-literal.d.ts';
|
|
135
136
|
export type {IsAny} from './source/is-any.d.ts';
|
|
136
137
|
export type {IfAny} from './source/if-any.d.ts';
|
|
137
138
|
export type {IsNever} from './source/is-never.d.ts';
|
|
@@ -173,6 +174,9 @@ export type {TupleOf} from './source/tuple-of.d.ts';
|
|
|
173
174
|
export type {ExclusifyUnion} from './source/exclusify-union.d.ts';
|
|
174
175
|
export type {ArrayReverse} from './source/array-reverse.d.ts';
|
|
175
176
|
export type {UnionMember} from './source/union-member.d.ts';
|
|
177
|
+
export type {Absolute} from './source/absolute.d.ts';
|
|
178
|
+
export type {UnionLength} from './source/union-length.d.ts';
|
|
179
|
+
export type {StringToNumber} from './source/string-to-number.d.ts';
|
|
176
180
|
|
|
177
181
|
// Template literal types
|
|
178
182
|
export type {CamelCase, CamelCaseOptions} from './source/camel-case.d.ts';
|
|
@@ -203,6 +207,9 @@ export type {LastArrayElement} from './source/last-array-element.d.ts';
|
|
|
203
207
|
export type {ConditionalSimplify} from './source/conditional-simplify.d.ts';
|
|
204
208
|
export type {ConditionalSimplifyDeep} from './source/conditional-simplify-deep.d.ts';
|
|
205
209
|
export type {RemovePrefix, RemovePrefixOptions} from './source/remove-prefix.d.ts';
|
|
210
|
+
export type {RemoveSuffix, RemoveSuffixOptions} from './source/remove-suffix.d.ts';
|
|
211
|
+
export type {StringToArray, StringToArrayOptions} from './source/string-to-array.d.ts';
|
|
212
|
+
export type {StringLength} from './source/string-length.d.ts';
|
|
206
213
|
|
|
207
214
|
// Miscellaneous
|
|
208
215
|
export type {GlobalThis} from './source/global-this.d.ts';
|
|
@@ -210,9 +217,10 @@ export type {PackageJson} from './source/package-json.d.ts';
|
|
|
210
217
|
export type {TsConfigJson} from './source/tsconfig-json.d.ts';
|
|
211
218
|
|
|
212
219
|
// Improved built-in
|
|
213
|
-
export type {ExtendsStrict} from './source/extends-strict.d.ts';
|
|
220
|
+
export type {ExtendsStrict, ExtendsStrictOptions} from './source/extends-strict.d.ts';
|
|
214
221
|
export type {ExtractStrict} from './source/extract-strict.d.ts';
|
|
215
222
|
export type {ExcludeStrict} from './source/exclude-strict.d.ts';
|
|
216
223
|
export type {ExcludeExactly} from './source/exclude-exactly.d.ts';
|
|
224
|
+
export type {ExtractExactly} from './source/extract-exactly.d.ts';
|
|
217
225
|
|
|
218
226
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/type-fest",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0-depup.0",
|
|
4
4
|
"description": "A collection of essential TypeScript types (with updated dependencies)",
|
|
5
5
|
"license": "(MIT OR CC0-1.0)",
|
|
6
6
|
"repository": "sindresorhus/type-fest",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"test:tsc": "node --max-old-space-size=6144 ./node_modules/.bin/tsc",
|
|
29
29
|
"test:tsd": "node --max-old-space-size=6144 ./node_modules/.bin/tsd",
|
|
30
|
-
"test:xo": "node --max-old-space-size=6144 ./node_modules/.bin/xo --ignores=lint-processors/fixtures/**/*.d.ts",
|
|
30
|
+
"test:xo": "node --max-old-space-size=6144 ./node_modules/.bin/xo --ignores=lint-processors/fixtures/**/*.d.ts '**/*.{js,ts,md}'",
|
|
31
31
|
"test:linter": "node --test",
|
|
32
32
|
"test": "run-p test:*"
|
|
33
33
|
},
|
|
@@ -61,17 +61,19 @@
|
|
|
61
61
|
"tagged-tag": "^1.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
+
"@eslint/markdown": "^8.0.1",
|
|
64
65
|
"@sindresorhus/tsconfig": "^8.0.1",
|
|
66
|
+
"@types/node": "^25.5.0",
|
|
65
67
|
"@typescript-eslint/parser": "^8.44.0",
|
|
66
|
-
"eslint": "^9.35.0",
|
|
67
68
|
"@typescript/vfs": "^1.6.1",
|
|
68
69
|
"dedent": "^1.7.0",
|
|
70
|
+
"eslint": "^10.1.0",
|
|
69
71
|
"expect-type": "^1.2.2",
|
|
70
72
|
"npm-run-all2": "^8.0.4",
|
|
71
73
|
"tsd": "^0.33.0",
|
|
72
74
|
"typescript": "^5.9.2",
|
|
73
75
|
"typescript-eslint": "^8.47.0",
|
|
74
|
-
"xo": "^
|
|
76
|
+
"xo": "^2.0.2"
|
|
75
77
|
},
|
|
76
78
|
"tsd": {
|
|
77
79
|
"compilerOptions": {
|
|
@@ -82,8 +84,8 @@
|
|
|
82
84
|
"changes": {},
|
|
83
85
|
"depsUpdated": 0,
|
|
84
86
|
"originalPackage": "type-fest",
|
|
85
|
-
"originalVersion": "5.
|
|
86
|
-
"processedAt": "2026-
|
|
87
|
+
"originalVersion": "5.9.0",
|
|
88
|
+
"processedAt": "2026-09-06T01:00:57.924Z",
|
|
87
89
|
"smokeTest": "failed"
|
|
88
90
|
}
|
|
89
91
|
}
|
package/readme.md
CHANGED
|
@@ -29,6 +29,17 @@
|
|
|
29
29
|
<sup>An open-source framework that supports any programming language, cloud provider, or deployment automation tool.</sup>
|
|
30
30
|
</div>
|
|
31
31
|
</a>
|
|
32
|
+
<br>
|
|
33
|
+
<br>
|
|
34
|
+
<a href="https://circleback.ai?utm_source=sindresorhus&utm_medium=sponsorship&utm_campaign=awesome-list&utm_id=type-fest">
|
|
35
|
+
<div>
|
|
36
|
+
<img width="300" src="https://sindresorhus.com/assets/thanks/circleback-logo.png?x" alt="Circleback logo">
|
|
37
|
+
</div>
|
|
38
|
+
<b>Get the most out of every conversation.</b>
|
|
39
|
+
<div>
|
|
40
|
+
<sup>AI-powered meeting notes, automations, and search. Give AI agents the context they need to get things done.</sup>
|
|
41
|
+
</div>
|
|
42
|
+
</a>
|
|
32
43
|
</p>
|
|
33
44
|
</div>
|
|
34
45
|
<br>
|
|
@@ -102,73 +113,76 @@ Click the type names for complete docs.
|
|
|
102
113
|
- [`UnknownArray`](source/unknown-array.d.ts) - Represents an array with `unknown` value.
|
|
103
114
|
- [`UnknownMap`](source/unknown-map.d.ts) - Represents a map with `unknown` key and value.
|
|
104
115
|
- [`UnknownSet`](source/unknown-set.d.ts) - Represents a set with `unknown` value.
|
|
105
|
-
- [`Except`](source/except.d.ts) - Create a type from an object type without certain keys.
|
|
116
|
+
- [`Except`](source/except.d.ts) - Create a type from an object type without certain keys.
|
|
106
117
|
- [`Writable`](source/writable.d.ts) - Create a type that strips `readonly` from the given type. Inverse of `Readonly<T>`.
|
|
107
118
|
- [`WritableDeep`](source/writable-deep.d.ts) - Create a deeply mutable version of an `object`/`ReadonlyMap`/`ReadonlySet`/`ReadonlyArray` type. The inverse of `ReadonlyDeep<T>`. Use `Writable<T>` if you only need one level deep.
|
|
108
119
|
- [`Merge`](source/merge.d.ts) - Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
109
120
|
- [`ObjectMerge`](source/object-merge.d.ts) - Merge two object types into a new object type, where keys from the second override keys from the first.
|
|
110
121
|
- [`MergeDeep`](source/merge-deep.d.ts) - Merge two objects or two arrays/tuples recursively into a new type.
|
|
111
122
|
- [`MergeExclusive`](source/merge-exclusive.d.ts) - Create a type that has mutually exclusive keys.
|
|
112
|
-
- [`OverrideProperties`](source/override-properties.d.ts) - Override
|
|
113
|
-
- [`
|
|
114
|
-
- [`
|
|
115
|
-
- [`
|
|
116
|
-
- [`
|
|
123
|
+
- [`OverrideProperties`](source/override-properties.d.ts) - Override existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
|
|
124
|
+
- [`RenameKeys`](source/rename-keys.d.ts) - Rename keys in an object type according to a map of old-to-new names.
|
|
125
|
+
- [`RequireAtLeastOne`](source/require-at-least-one.d.ts) - Create a type that requires at least one of the given keys, while keeping the remaining keys as is.
|
|
126
|
+
- [`RequireExactlyOne`](source/require-exactly-one.d.ts) - Create a type that requires exactly one of the given keys and disallows more, while keeping the remaining keys as is.
|
|
127
|
+
- [`RequireAllOrNone`](source/require-all-or-none.d.ts) - Create a type that requires all of the given keys or none of the given keys, while keeping the remaining keys as is.
|
|
128
|
+
- [`RequireOneOrNone`](source/require-one-or-none.d.ts) - Create a type that requires exactly one of the given keys or none of the given keys, while keeping the remaining keys as is.
|
|
117
129
|
- [`SingleKeyObject`](source/single-key-object.d.ts) - Create a type that only accepts an object with a single key.
|
|
118
|
-
- [`RequiredDeep`](source/required-deep.d.ts) - Create a deeply required version of another type.
|
|
119
|
-
- [`PickDeep`](source/pick-deep.d.ts) - Pick properties from a deeply-nested object.
|
|
120
|
-
- [`OmitDeep`](source/omit-deep.d.ts) - Omit properties from a deeply-nested object.
|
|
130
|
+
- [`RequiredDeep`](source/required-deep.d.ts) - Create a deeply required version of another type.
|
|
131
|
+
- [`PickDeep`](source/pick-deep.d.ts) - Pick properties from a deeply-nested object.
|
|
132
|
+
- [`OmitDeep`](source/omit-deep.d.ts) - Omit properties from a deeply-nested object.
|
|
121
133
|
- [`OmitIndexSignature`](source/omit-index-signature.d.ts) - Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
122
134
|
- [`PickIndexSignature`](source/pick-index-signature.d.ts) - Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
123
|
-
- [`PartialDeep`](source/partial-deep.d.ts) - Create a deeply optional version of another type.
|
|
135
|
+
- [`PartialDeep`](source/partial-deep.d.ts) - Create a deeply optional version of another type.
|
|
124
136
|
- [`PartialOnUndefinedDeep`](source/partial-on-undefined-deep.d.ts) - Create a deep version of another type where all keys accepting `undefined` type are set to optional.
|
|
125
137
|
- [`UndefinedOnPartialDeep`](source/undefined-on-partial-deep.d.ts) - Create a deep version of another type where all optional keys are set to also accept `undefined`.
|
|
126
138
|
- [`UnwrapPartial`](source/unwrap-partial.d.ts) - Revert the `Partial` modifier on an object type.
|
|
127
|
-
- [`
|
|
128
|
-
- [`
|
|
129
|
-
- [`
|
|
130
|
-
- [`
|
|
139
|
+
- [`UnwrapRequired`](source/unwrap-required.d.ts) - Revert the `Required` modifier on an object type.
|
|
140
|
+
- [`ReadonlyDeep`](source/readonly-deep.d.ts) - Create a deeply immutable version of another type.
|
|
141
|
+
- [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
142
|
+
- [`Tagged`](source/tagged.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
|
|
143
|
+
- [`UnwrapTagged`](source/tagged.d.ts) - Get the untagged portion of a tagged type created with `Tagged`.
|
|
131
144
|
- [`InvariantOf`](source/invariant-of.d.ts) - Create an [invariant type](https://basarat.gitbook.io/typescript/type-system/type-compatibility#footnote-invariance), which is a type that does not accept supertypes and subtypes.
|
|
132
|
-
- [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional.
|
|
133
|
-
- [`SetReadonly`](source/set-readonly.d.ts) - Create a type that makes the given keys readonly.
|
|
134
|
-
- [`SetRequired`](source/set-required.d.ts) - Create a type that makes the given keys required.
|
|
135
|
-
- [`SetRequiredDeep`](source/set-required-deep.d.ts) -
|
|
136
|
-
- [`SetNonNullable`](source/set-non-nullable.d.ts) - Create a type that makes the given keys non-nullable.
|
|
145
|
+
- [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional, while keeping the remaining keys as is.
|
|
146
|
+
- [`SetReadonly`](source/set-readonly.d.ts) - Create a type that makes the given keys readonly, while keeping the remaining keys as is.
|
|
147
|
+
- [`SetRequired`](source/set-required.d.ts) - Create a type that makes the given keys required, while keeping the remaining keys as is.
|
|
148
|
+
- [`SetRequiredDeep`](source/set-required-deep.d.ts) - Create a type that makes the given keys required, with support for deeply nested key paths, while keeping the remaining keys as is.
|
|
149
|
+
- [`SetNonNullable`](source/set-non-nullable.d.ts) - Create a type that makes the given keys non-nullable, while keeping the remaining keys as is.
|
|
137
150
|
- [`SetNonNullableDeep`](source/set-non-nullable-deep.d.ts) - Create a type that makes the specified keys non-nullable (removes `null` and `undefined`), supports deeply nested key paths, and leaves all other keys unchanged.
|
|
151
|
+
- [`NonNullableDeep`](source/non-nullable-deep.d.ts) - Recursively removes `null` and `undefined` from the specified type.
|
|
138
152
|
- [`ValueOf`](source/value-of.d.ts) - Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
139
|
-
- [`ConditionalKeys`](source/conditional-keys.d.ts) - Extract keys from a
|
|
140
|
-
- [`ConditionalPick`](source/conditional-pick.d.ts) -
|
|
141
|
-
- [`ConditionalPickDeep`](source/conditional-pick-deep.d.ts) -
|
|
142
|
-
- [`ConditionalExcept`](source/conditional-except.d.ts) -
|
|
153
|
+
- [`ConditionalKeys`](source/conditional-keys.d.ts) - Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
154
|
+
- [`ConditionalPick`](source/conditional-pick.d.ts) - Pick keys from the shape that matches the given `Condition`.
|
|
155
|
+
- [`ConditionalPickDeep`](source/conditional-pick-deep.d.ts) - Pick keys recursively from the shape that matches the given condition.
|
|
156
|
+
- [`ConditionalExcept`](source/conditional-except.d.ts) - Exclude keys from a shape that matches the given `Condition`.
|
|
143
157
|
- [`UnionToIntersection`](source/union-to-intersection.d.ts) - Convert a union type to an intersection type.
|
|
144
|
-
- [`LiteralToPrimitive`](source/literal-to-primitive.d.ts) -
|
|
158
|
+
- [`LiteralToPrimitive`](source/literal-to-primitive.d.ts) - Given a [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types) return the [primitive type](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) it belongs to, or `never` if it's not a primitive.
|
|
145
159
|
- [`LiteralToPrimitiveDeep`](source/literal-to-primitive-deep.d.ts) - Like `LiteralToPrimitive` except it converts literal types inside an object or array deeply.
|
|
146
160
|
- [`Stringified`](source/stringified.d.ts) - Create a type with the keys of the given type changed to `string` type.
|
|
147
161
|
- [`IterableElement`](source/iterable-element.d.ts) - Get the element type of an `Iterable`/`AsyncIterable`. For example, `Array`, `Set`, `Map`, generator, stream, etc.
|
|
148
|
-
- [`Entry`](source/entry.d.ts) - Create a type that
|
|
149
|
-
- [`Entries`](source/entries.d.ts) - Create a type that
|
|
162
|
+
- [`Entry`](source/entry.d.ts) - Create a type that describes a single key-value pair produced when calling a collection’s `entries` method.
|
|
163
|
+
- [`Entries`](source/entries.d.ts) - Create a type that describes the key-value pairs produced when calling a collection’s `entries` method.
|
|
150
164
|
- [`SetReturnType`](source/set-return-type.d.ts) - Create a function type with a return type of your choice and the same parameters as the given function type.
|
|
151
165
|
- [`SetParameterType`](source/set-parameter-type.d.ts) - Create a function that replaces some parameters with the given parameters.
|
|
152
166
|
- [`Simplify`](source/simplify.d.ts) - Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
153
167
|
- [`SimplifyDeep`](source/simplify-deep.d.ts) - Deeply simplifies an object type.
|
|
154
|
-
- [`Get`](source/get.d.ts) - Get a deeply-nested property from an object using a key path, like [Lodash's `.get()`](https://lodash.com/docs
|
|
168
|
+
- [`Get`](source/get.d.ts) - Get a deeply-nested property from an object using a key path, like [Lodash's `.get()`](https://lodash.com/docs#get) function.
|
|
155
169
|
- [`KeyAsString`](source/key-as-string.d.ts) - Get keys of the given type as strings.
|
|
156
170
|
- [`Schema`](source/schema.d.ts) - Create a deep version of another object type where property values are recursively replaced into a given value type.
|
|
157
|
-
- [`Exact`](source/exact.d.ts) - Create a type that does not allow extra properties.
|
|
171
|
+
- [`Exact`](source/exact.d.ts) - Create a type that does not allow extra properties, meaning it only allows properties that are explicitly declared.
|
|
158
172
|
- [`KeysOfUnion`](source/keys-of-union.d.ts) - Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
159
173
|
- [`OptionalKeysOf`](source/optional-keys-of.d.ts) - Extract all optional keys from the given type.
|
|
160
|
-
- [`HasOptionalKeys`](source/has-optional-keys.d.ts) -
|
|
174
|
+
- [`HasOptionalKeys`](source/has-optional-keys.d.ts) - Returns a boolean for whether the given type has any optional fields.
|
|
161
175
|
- [`RequiredKeysOf`](source/required-keys-of.d.ts) - Extract all required keys from the given type.
|
|
162
|
-
- [`HasRequiredKeys`](source/has-required-keys.d.ts) -
|
|
176
|
+
- [`HasRequiredKeys`](source/has-required-keys.d.ts) - Returns a boolean for whether the given type has any required fields.
|
|
163
177
|
- [`ReadonlyKeysOf`](source/readonly-keys-of.d.ts) - Extract all readonly keys from the given type.
|
|
164
|
-
- [`HasReadonlyKeys`](source/has-readonly-keys.d.ts) -
|
|
165
|
-
- [`WritableKeysOf`](source/writable-keys-of.d.ts) - Extract all writable
|
|
166
|
-
- [`HasWritableKeys`](source/has-writable-keys.d.ts) -
|
|
178
|
+
- [`HasReadonlyKeys`](source/has-readonly-keys.d.ts) - Returns a boolean for whether the given type has any readonly fields.
|
|
179
|
+
- [`WritableKeysOf`](source/writable-keys-of.d.ts) - Extract all writable keys from the given type.
|
|
180
|
+
- [`HasWritableKeys`](source/has-writable-keys.d.ts) - Returns a boolean for whether the given type has any writable fields.
|
|
167
181
|
- [`Spread`](source/spread.d.ts) - Mimic the type inferred by TypeScript when merging two objects or two arrays/tuples using the spread syntax.
|
|
168
182
|
- [`IsEqual`](source/is-equal.d.ts) - Returns a boolean for whether the two given types are equal.
|
|
169
183
|
- [`TaggedUnion`](source/tagged-union.d.ts) - Create a union of types that share a common discriminant property.
|
|
170
|
-
- [`IntRange`](source/int-range.d.ts) - Generate a union of numbers
|
|
171
|
-
- [`IntClosedRange`](source/int-closed-range.d.ts) - Generate a union of numbers
|
|
184
|
+
- [`IntRange`](source/int-range.d.ts) - Generate a union of numbers between a specified start (inclusive) and end (exclusive), with an optional step.
|
|
185
|
+
- [`IntClosedRange`](source/int-closed-range.d.ts) - Generate a union of numbers between a specified start and end (both inclusive), with an optional step.
|
|
172
186
|
- [`ArrayIndices`](source/array-indices.d.ts) - Provides valid indices for a constant array or tuple.
|
|
173
187
|
- [`ArrayValues`](source/array-values.d.ts) - Provides all values for a constant array or tuple.
|
|
174
188
|
- [`ArraySplice`](source/array-splice.d.ts) - Create a new array type by adding or removing elements at a specified index range in the original array.
|
|
@@ -179,7 +193,7 @@ Click the type names for complete docs.
|
|
|
179
193
|
- [`SharedUnionFieldsDeep`](source/shared-union-fields-deep.d.ts) - Create a type with shared fields from a union of object types, deeply traversing nested structures.
|
|
180
194
|
- [`AllUnionFields`](source/all-union-fields.d.ts) - Create a type with all fields from a union of object types.
|
|
181
195
|
- [`DistributedOmit`](source/distributed-omit.d.ts) - Omits keys from a type, distributing the operation over a union.
|
|
182
|
-
- [`DistributedPick`](source/distributed-pick.d.ts) -
|
|
196
|
+
- [`DistributedPick`](source/distributed-pick.d.ts) - Pick keys from a type, distributing the operation over a union.
|
|
183
197
|
- [`And`](source/and.d.ts) - Returns a boolean for whether two given types are both `true`.
|
|
184
198
|
- [`Or`](source/or.d.ts) - Returns a boolean for whether either of two given types is `true`.
|
|
185
199
|
- [`Xor`](source/xor.d.ts) - Returns a boolean for whether only one of two given types is `true`.
|
|
@@ -196,15 +210,16 @@ Click the type names for complete docs.
|
|
|
196
210
|
- [`ExclusifyUnion`](source/exclusify-union.d.ts) - Ensure mutual exclusivity in object unions by adding other members’ keys as `?: never`.
|
|
197
211
|
- [`Optional`](source/optional.d.ts) - Create a type that represents either the value or `undefined`, while stripping `null` from the type.
|
|
198
212
|
- [`UnionMember`](source/union-member.d.ts) - Returns an arbitrary member of a union type.
|
|
213
|
+
- [`UnionLength`](source/union-length.d.ts) - Returns the length of a union type.
|
|
199
214
|
|
|
200
215
|
### Type Guard
|
|
201
216
|
|
|
202
217
|
- [`If`](source/if.d.ts) - An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
203
218
|
- [`IsLiteral`](source/is-literal.d.ts) - Returns a boolean for whether the given type is a [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
204
|
-
- [`IsStringLiteral`](source/is-literal.d.ts) - Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
205
|
-
- [`IsNumericLiteral`](source/is-literal.d.ts) - Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
206
|
-
- [`IsBooleanLiteral`](source/is-literal.d.ts) - Returns a boolean for whether the given type is a `true` or `false` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
207
|
-
- [`IsSymbolLiteral`](source/is-literal.d.ts) - Returns a boolean for whether the given type is a `symbol` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
219
|
+
- [`IsStringLiteral`](source/is-string-literal.d.ts) - Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
220
|
+
- [`IsNumericLiteral`](source/is-numeric-literal.d.ts) - Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
221
|
+
- [`IsBooleanLiteral`](source/is-boolean-literal.d.ts) - Returns a boolean for whether the given type is a `true` or `false` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
222
|
+
- [`IsSymbolLiteral`](source/is-symbol-literal.d.ts) - Returns a boolean for whether the given type is a `symbol` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
208
223
|
- [`IsAny`](source/is-any.d.ts) - Returns a boolean for whether the given type is `any`.
|
|
209
224
|
- [`IsNever`](source/is-never.d.ts) - Returns a boolean for whether the given type is `never`.
|
|
210
225
|
- [`IsUnknown`](source/is-unknown.d.ts) - Returns a boolean for whether the given type is `unknown`.
|
|
@@ -226,7 +241,7 @@ Click the type names for complete docs.
|
|
|
226
241
|
|
|
227
242
|
- [`Jsonify`](source/jsonify.d.ts) - Transform a type to one that is assignable to the `JsonValue` type.
|
|
228
243
|
- [`Jsonifiable`](source/jsonifiable.d.ts) - Matches a value that can be losslessly converted to JSON.
|
|
229
|
-
- [`JsonPrimitive`](source/json-value.d.ts) - Matches
|
|
244
|
+
- [`JsonPrimitive`](source/json-value.d.ts) - Matches any valid JSON primitive value.
|
|
230
245
|
- [`JsonObject`](source/json-value.d.ts) - Matches a JSON object.
|
|
231
246
|
- [`JsonArray`](source/json-value.d.ts) - Matches a JSON array.
|
|
232
247
|
- [`JsonValue`](source/json-value.d.ts) - Matches any valid JSON value.
|
|
@@ -239,17 +254,20 @@ Click the type names for complete docs.
|
|
|
239
254
|
|
|
240
255
|
- [`Promisable`](source/promisable.d.ts) - Create a type that represents either the value or the value wrapped in `PromiseLike`.
|
|
241
256
|
- [`AsyncReturnType`](source/async-return-type.d.ts) - Unwrap the return type of a function that returns a `Promise`.
|
|
242
|
-
- [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type.
|
|
257
|
+
- [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type, by boxing the return type in `Promise` while keeping the same parameter types.
|
|
243
258
|
|
|
244
259
|
### String
|
|
245
260
|
|
|
246
261
|
- [`Trim`](source/trim.d.ts) - Remove leading and trailing spaces from a string.
|
|
247
262
|
- [`Split`](source/split.d.ts) - Represents an array of strings split using a given character or character set.
|
|
248
|
-
- [`Words`](source/words.d.ts) -
|
|
263
|
+
- [`Words`](source/words.d.ts) - Split a string similar to Lodash's `_.words()` function.
|
|
249
264
|
- [`Replace`](source/replace.d.ts) - Represents a string with some or all matches replaced by a replacement.
|
|
250
265
|
- [`StringSlice`](source/string-slice.d.ts) - Returns a string slice of a given range, just like `String#slice()`.
|
|
251
266
|
- [`StringRepeat`](source/string-repeat.d.ts) - Returns a new string which contains the specified number of copies of a given string, just like `String#repeat()`.
|
|
252
267
|
- [`RemovePrefix`](source/remove-prefix.d.ts) - Remove the specified prefix from the start of a string.
|
|
268
|
+
- [`RemoveSuffix`](source/remove-suffix.d.ts) - Remove the specified suffix from the end of a string.
|
|
269
|
+
- [`StringToArray`](source/string-to-array.d.ts) - Returns an array of the characters of the specified string.
|
|
270
|
+
- [`StringLength`](source/string-length.d.ts) - Returns the length of the given string.
|
|
253
271
|
|
|
254
272
|
### Array
|
|
255
273
|
|
|
@@ -260,8 +278,8 @@ Click the type names for complete docs.
|
|
|
260
278
|
- [`ArrayElement`](source/array-element.d.ts) - Extracts the element type of an array or tuple.
|
|
261
279
|
- [`LastArrayElement`](source/last-array-element.d.ts) - Extract the type of the last element of an array.
|
|
262
280
|
- [`FixedLengthArray`](source/fixed-length-array.d.ts) - Create a type that represents an array of the given type and length. The `Array` prototype methods that manipulate its length are excluded from the resulting type.
|
|
263
|
-
- [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and
|
|
264
|
-
- [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and
|
|
281
|
+
- [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and dimension.
|
|
282
|
+
- [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and dimension.
|
|
265
283
|
- [`ReadonlyTuple`](source/readonly-tuple.d.ts) - Create a type that represents a read-only tuple of the given type and length.
|
|
266
284
|
- [`TupleToUnion`](source/tuple-to-union.d.ts) - Convert a tuple/array into a union type of its elements.
|
|
267
285
|
- [`UnionToTuple`](source/union-to-tuple.d.ts) - Convert a union type into an unordered tuple type of its elements.
|
|
@@ -287,29 +305,31 @@ Click the type names for complete docs.
|
|
|
287
305
|
- [`NonNegativeInteger`](source/numeric.d.ts) - A non-negative (`0 <= x < ∞`) `number` that is an integer.
|
|
288
306
|
- [`IsNegative`](source/numeric.d.ts) - Returns a boolean for whether the given number is a negative number.
|
|
289
307
|
- [`IsFloat`](source/is-float.d.ts) - Returns a boolean for whether the given number is a float, like `1.5` or `-1.5`.
|
|
290
|
-
- [`IsInteger`](source/is-integer.d.ts) - Returns a boolean for whether the given number is an integer, like `-5`, `1.0
|
|
308
|
+
- [`IsInteger`](source/is-integer.d.ts) - Returns a boolean for whether the given number is an integer, like `-5`, `1.0`, or `100`.
|
|
291
309
|
- [`GreaterThan`](source/greater-than.d.ts) - Returns a boolean for whether a given number is greater than another number.
|
|
292
310
|
- [`GreaterThanOrEqual`](source/greater-than-or-equal.d.ts) - Returns a boolean for whether a given number is greater than or equal to another number.
|
|
293
311
|
- [`LessThan`](source/less-than.d.ts) - Returns a boolean for whether a given number is less than another number.
|
|
294
312
|
- [`LessThanOrEqual`](source/less-than-or-equal.d.ts) - Returns a boolean for whether a given number is less than or equal to another number.
|
|
295
313
|
- [`Sum`](source/sum.d.ts) - Returns the sum of two numbers.
|
|
296
314
|
- [`Subtract`](source/subtract.d.ts) - Returns the difference between two numbers.
|
|
315
|
+
- [`Absolute`](source/absolute.d.ts) - Returns the absolute value of the specified number or bigint.
|
|
316
|
+
- [`StringToNumber`](source/string-to-number.d.ts) - Converts a numeric string to a number.
|
|
297
317
|
|
|
298
318
|
### Change case
|
|
299
319
|
|
|
300
|
-
- [`CamelCase`](source/camel-case.d.ts) - Convert a string literal to camel-case
|
|
301
|
-
- [`CamelCasedProperties`](source/camel-cased-properties.d.ts) - Convert object properties to camel
|
|
302
|
-
- [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) - Convert object properties to camel
|
|
303
|
-
- [`KebabCase`](source/kebab-case.d.ts) - Convert a string literal to kebab-case
|
|
304
|
-
- [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert object properties to kebab
|
|
305
|
-
- [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab
|
|
306
|
-
- [`PascalCase`](source/pascal-case.d.ts) - Convert a string literal to pascal-case
|
|
307
|
-
- [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) - Convert object properties to pascal
|
|
308
|
-
- [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) - Convert object properties to pascal
|
|
309
|
-
- [`SnakeCase`](source/snake-case.d.ts) - Convert a string literal to snake-case
|
|
310
|
-
- [`SnakeCasedProperties`](source/snake-cased-properties.d.ts) - Convert object properties to snake
|
|
311
|
-
- [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake
|
|
312
|
-
- [`ScreamingSnakeCase`](source/screaming-snake-case.d.ts) - Convert a string literal to screaming-snake-case
|
|
320
|
+
- [`CamelCase`](source/camel-case.d.ts) - Convert a string literal to camel-case.
|
|
321
|
+
- [`CamelCasedProperties`](source/camel-cased-properties.d.ts) - Convert top-level object properties to camel case.
|
|
322
|
+
- [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) - Convert object properties to camel case recursively.
|
|
323
|
+
- [`KebabCase`](source/kebab-case.d.ts) - Convert a string literal to kebab-case.
|
|
324
|
+
- [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert top-level object properties to kebab case.
|
|
325
|
+
- [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab case recursively.
|
|
326
|
+
- [`PascalCase`](source/pascal-case.d.ts) - Convert a string literal to pascal-case.
|
|
327
|
+
- [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) - Convert top-level object properties to pascal case.
|
|
328
|
+
- [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) - Convert object properties to pascal case recursively.
|
|
329
|
+
- [`SnakeCase`](source/snake-case.d.ts) - Convert a string literal to snake-case.
|
|
330
|
+
- [`SnakeCasedProperties`](source/snake-cased-properties.d.ts) - Convert top-level object properties to snake case.
|
|
331
|
+
- [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake case recursively.
|
|
332
|
+
- [`ScreamingSnakeCase`](source/screaming-snake-case.d.ts) - Convert a string literal to screaming-snake-case.
|
|
313
333
|
- [`DelimiterCase`](source/delimiter-case.d.ts) - Convert a string literal to a custom string delimiter casing.
|
|
314
334
|
- [`DelimiterCasedProperties`](source/delimiter-cased-properties.d.ts) - Convert object properties to a custom string delimiter casing.
|
|
315
335
|
- [`DelimiterCasedPropertiesDeep`](source/delimiter-cased-properties-deep.d.ts) - Convert object properties to a custom string delimiter casing recursively.
|
|
@@ -317,15 +337,16 @@ Click the type names for complete docs.
|
|
|
317
337
|
### Miscellaneous
|
|
318
338
|
|
|
319
339
|
- [`GlobalThis`](source/global-this.d.ts) - Declare locally scoped properties on `globalThis`.
|
|
320
|
-
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file).
|
|
340
|
+
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
|
|
321
341
|
- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
|
|
322
342
|
|
|
323
343
|
### Improved built-in
|
|
324
344
|
|
|
325
|
-
- [`ExtendsStrict`](source/extends-strict.d.ts) - A
|
|
345
|
+
- [`ExtendsStrict`](source/extends-strict.d.ts) - A customizable version of `extends` for checking whether one type is assignable to another.
|
|
326
346
|
- [`ExtractStrict`](source/extract-strict.d.ts) - A stricter version of `Extract<T, U>` that ensures every member of `U` can successfully extract something from `T`.
|
|
327
347
|
- [`ExcludeStrict`](source/exclude-strict.d.ts) - A stricter version of `Exclude<T, U>` that ensures every member of `U` can successfully exclude something from `T`.
|
|
328
348
|
- [`ExcludeExactly`](source/exclude-exactly.d.ts) - A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
|
|
349
|
+
- [`ExtractExactly`](source/extract-exactly.d.ts) - A stricter version of `Extract<T, U>` that extracts types only when they are exactly identical.
|
|
329
350
|
|
|
330
351
|
## Declined types
|
|
331
352
|
|
|
@@ -370,6 +391,7 @@ Click the type names for complete docs.
|
|
|
370
391
|
|
|
371
392
|
### Extending existing types
|
|
372
393
|
|
|
394
|
+
<!-- eslint-disable-next-line type-fest/readme-jsdoc-sync -->
|
|
373
395
|
- [`PackageJson`](source/package-json.d.ts) - There are a lot of tools that place extra configurations inside the `package.json` file. You can extend `PackageJson` to support these additional configurations.
|
|
374
396
|
<details>
|
|
375
397
|
<summary>
|
|
@@ -519,6 +541,8 @@ There are many advanced types most users don't know about.
|
|
|
519
541
|
email: 'ex@mple.com',
|
|
520
542
|
});
|
|
521
543
|
```
|
|
544
|
+
|
|
545
|
+
`Required<T>` can be reverted with [`UnwrapRequired`](source/unwrap-required.d.ts).
|
|
522
546
|
</details>
|
|
523
547
|
|
|
524
548
|
- [`Readonly<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) - Make all properties in `T` readonly.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type {StringToNumber} from './string-to-number.d.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Returns the absolute value of the specified number or bigint.
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
```
|
|
8
|
+
import type {Absolute} from 'type-fest';
|
|
9
|
+
|
|
10
|
+
type A = Absolute<-1>;
|
|
11
|
+
//=> 1
|
|
12
|
+
|
|
13
|
+
type B = Absolute<1>;
|
|
14
|
+
//=> 1
|
|
15
|
+
|
|
16
|
+
type C = Absolute<0>;
|
|
17
|
+
//=> 0
|
|
18
|
+
|
|
19
|
+
type D = Absolute<-1.025>;
|
|
20
|
+
//=> 1.025
|
|
21
|
+
|
|
22
|
+
type E = Absolute<-9999n>;
|
|
23
|
+
//=> 9999n
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Returns back the same type if the input is not a literal type.
|
|
27
|
+
|
|
28
|
+
@example
|
|
29
|
+
```
|
|
30
|
+
import type {Absolute} from 'type-fest';
|
|
31
|
+
|
|
32
|
+
type A = Absolute<number>;
|
|
33
|
+
//=> number
|
|
34
|
+
|
|
35
|
+
type B = Absolute<bigint>;
|
|
36
|
+
//=> bigint
|
|
37
|
+
|
|
38
|
+
type C = Absolute<number | bigint>;
|
|
39
|
+
//=> number | bigint
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
@category Numeric
|
|
43
|
+
*/
|
|
44
|
+
export type Absolute<N extends number | bigint> = N extends bigint // Also, distributes `N`
|
|
45
|
+
? `${N}` extends `-${infer Magnitude extends bigint}`
|
|
46
|
+
? Magnitude
|
|
47
|
+
: N
|
|
48
|
+
: `${N}` extends `-${infer Magnitude}` // This doesn't use the `extends number` constraint approach because that fails with the `-Infinity` case
|
|
49
|
+
? StringToNumber<Magnitude>
|
|
50
|
+
: N;
|
|
51
|
+
|
|
52
|
+
export {};
|
package/source/all-extend.d.ts
CHANGED
|
@@ -103,8 +103,8 @@ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
|
|
|
103
103
|
export type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> =
|
|
104
104
|
_AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
|
|
105
105
|
|
|
106
|
-
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray,
|
|
107
|
-
TArray extends readonly [infer First, ...infer Rest]
|
|
106
|
+
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, {
|
|
107
|
+
ifNot: TArray extends readonly [infer First, ...infer Rest]
|
|
108
108
|
? IsNever<First> extends true
|
|
109
109
|
? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true
|
|
110
110
|
// If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
@@ -113,7 +113,9 @@ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllE
|
|
|
113
113
|
: First extends Type
|
|
114
114
|
? _AllExtend<Rest, Type, Options>
|
|
115
115
|
: false
|
|
116
|
-
: true
|
|
117
|
-
|
|
116
|
+
: true;
|
|
117
|
+
ifAny: false;
|
|
118
|
+
ifNever: false;
|
|
119
|
+
}>;
|
|
118
120
|
|
|
119
121
|
export {};
|
|
@@ -69,23 +69,23 @@ function displayPetInfoWithAllUnionFields(petInfo: AllUnionFields<Cat | Dog>) {
|
|
|
69
69
|
@category Union
|
|
70
70
|
*/
|
|
71
71
|
export type AllUnionFields<Union> =
|
|
72
|
-
Extract<Union, NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | UnknownArray> extends infer SkippedMembers
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
72
|
+
Extract<Union, NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | UnknownArray> extends infer SkippedMembers
|
|
73
|
+
? Exclude<Union, SkippedMembers> extends infer RelevantMembers
|
|
74
|
+
? // eslint-disable-line @stylistic/operator-linebreak
|
|
75
|
+
| SkippedMembers
|
|
76
|
+
| Simplify<
|
|
77
|
+
// Include fields that are common in all union members
|
|
78
|
+
SharedUnionFields<RelevantMembers>
|
|
79
|
+
// Include readonly fields present in any union member
|
|
80
|
+
& {
|
|
81
|
+
readonly [P in ReadonlyKeysOfUnion<RelevantMembers>]?: ValueOfUnion<RelevantMembers, P & KeysOfUnion<RelevantMembers>>
|
|
82
|
+
}
|
|
83
|
+
// Include remaining fields that are neither common nor readonly
|
|
84
|
+
& {
|
|
85
|
+
[P in Exclude<KeysOfUnion<RelevantMembers>, ReadonlyKeysOfUnion<RelevantMembers> | keyof RelevantMembers>]?: ValueOfUnion<RelevantMembers, P>
|
|
86
|
+
}
|
|
87
|
+
>
|
|
88
|
+
: never
|
|
89
|
+
: never;
|
|
90
90
|
|
|
91
91
|
export {};
|
package/source/and.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {AndAll} from './and-all.d.ts';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
Returns a boolean for whether two given types are both true
|
|
4
|
+
Returns a boolean for whether two given types are both `true`.
|
|
5
5
|
|
|
6
6
|
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
7
7
|
|
|
@@ -51,12 +51,13 @@ type E = ArrayReverse<[string?, number?, ...boolean[]]>;
|
|
|
51
51
|
|
|
52
52
|
@category Array
|
|
53
53
|
*/
|
|
54
|
-
export type ArrayReverse<TArray extends UnknownArray> = IfNotAnyOrNever<TArray,
|
|
55
|
-
TArray extends unknown // For distributing `TArray`
|
|
54
|
+
export type ArrayReverse<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, {
|
|
55
|
+
ifNot: TArray extends unknown // For distributing `TArray`
|
|
56
56
|
? _ArrayReverse<TArray> extends infer Result
|
|
57
57
|
? If<IsArrayReadonly<TArray>, Readonly<Result>, Result>
|
|
58
58
|
: never // Should never happen
|
|
59
|
-
: never
|
|
59
|
+
: never; // Should never happen
|
|
60
|
+
}>;
|
|
60
61
|
|
|
61
62
|
type _ArrayReverse<
|
|
62
63
|
TArray extends UnknownArray,
|