type-fest 5.0.0 → 5.1.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/index.d.ts +17 -12
- package/package.json +2 -1
- package/readme.md +18 -10
- package/source/all-extend.d.ts +3 -1
- package/source/all-union-fields.d.ts +2 -0
- package/source/and.d.ts +2 -0
- package/source/array-indices.d.ts +2 -0
- package/source/array-slice.d.ts +2 -0
- package/source/array-splice.d.ts +7 -4
- package/source/array-tail.d.ts +3 -1
- package/source/array-values.d.ts +2 -0
- package/source/arrayable.d.ts +2 -0
- package/source/async-return-type.d.ts +2 -0
- package/source/asyncify.d.ts +2 -0
- package/source/basic.d.ts +2 -0
- package/source/camel-case.d.ts +4 -2
- package/source/camel-cased-properties-deep.d.ts +4 -2
- package/source/camel-cased-properties.d.ts +4 -2
- package/source/characters.d.ts +2 -0
- package/source/conditional-except.d.ts +2 -0
- package/source/conditional-keys.d.ts +2 -0
- package/source/conditional-pick-deep.d.ts +2 -0
- package/source/conditional-pick.d.ts +2 -0
- package/source/conditional-simplify-deep.d.ts +2 -0
- package/source/conditional-simplify.d.ts +2 -0
- package/source/delimiter-case.d.ts +5 -3
- package/source/delimiter-cased-properties-deep.d.ts +4 -2
- package/source/delimiter-cased-properties.d.ts +4 -2
- package/source/distributed-omit.d.ts +2 -0
- package/source/distributed-pick.d.ts +2 -0
- package/source/empty-object.d.ts +2 -0
- package/source/entries.d.ts +7 -5
- package/source/entry.d.ts +10 -8
- package/source/exact.d.ts +2 -0
- package/source/except.d.ts +3 -1
- package/source/exclude-rest-element.d.ts +37 -0
- package/source/exclude-strict.d.ts +2 -0
- package/source/extends-strict.d.ts +2 -0
- package/source/extract-rest-element.d.ts +29 -0
- package/source/extract-strict.d.ts +2 -0
- package/source/find-global-type.d.ts +2 -0
- package/source/fixed-length-array.d.ts +67 -21
- package/source/get.d.ts +5 -3
- package/source/global-this.d.ts +2 -0
- package/source/globals/index.d.ts +2 -0
- package/source/globals/observable-like.d.ts +5 -0
- package/source/greater-than-or-equal.d.ts +2 -0
- package/source/greater-than.d.ts +2 -0
- package/source/has-optional-keys.d.ts +2 -0
- package/source/has-readonly-keys.d.ts +2 -0
- package/source/has-required-keys.d.ts +2 -0
- package/source/has-writable-keys.d.ts +2 -0
- package/source/if-any.d.ts +2 -0
- package/source/if-empty-object.d.ts +2 -0
- package/source/if-never.d.ts +2 -0
- package/source/if-null.d.ts +2 -0
- package/source/if-unknown.d.ts +2 -0
- package/source/if.d.ts +2 -0
- package/source/includes.d.ts +2 -0
- package/source/int-closed-range.d.ts +2 -0
- package/source/int-range.d.ts +7 -5
- package/source/internal/array.d.ts +2 -0
- package/source/internal/characters.d.ts +2 -0
- package/source/{enforce-optional.d.ts → internal/enforce-optional.d.ts} +3 -1
- package/source/internal/index.d.ts +3 -0
- package/source/internal/keys.d.ts +2 -0
- package/source/internal/numeric.d.ts +2 -0
- package/source/internal/object.d.ts +2 -0
- package/source/internal/string.d.ts +4 -2
- package/source/internal/tuple.d.ts +2 -13
- package/source/internal/type.d.ts +2 -0
- package/source/invariant-of.d.ts +2 -0
- package/source/is-any.d.ts +2 -0
- package/source/is-equal.d.ts +15 -0
- package/source/is-float.d.ts +2 -0
- package/source/is-integer.d.ts +2 -0
- package/source/is-literal.d.ts +4 -2
- package/source/is-lowercase.d.ts +2 -0
- package/source/is-never.d.ts +2 -0
- package/source/is-null.d.ts +2 -0
- package/source/is-nullable.d.ts +2 -0
- package/source/is-optional-key-of.d.ts +2 -0
- package/source/is-optional.d.ts +2 -0
- package/source/is-readonly-key-of.d.ts +2 -0
- package/source/is-required-key-of.d.ts +2 -0
- package/source/is-tuple.d.ts +2 -0
- package/source/is-undefined.d.ts +2 -0
- package/source/is-union.d.ts +2 -0
- package/source/is-unknown.d.ts +2 -0
- package/source/is-uppercase.d.ts +2 -0
- package/source/is-writable-key-of.d.ts +2 -0
- package/source/iterable-element.d.ts +2 -0
- package/source/join.d.ts +2 -0
- package/source/json-value.d.ts +3 -1
- package/source/jsonifiable.d.ts +2 -0
- package/source/jsonify.d.ts +2 -0
- package/source/kebab-case.d.ts +4 -2
- package/source/kebab-cased-properties-deep.d.ts +4 -2
- package/source/kebab-cased-properties.d.ts +4 -2
- package/source/key-as-string.d.ts +2 -0
- package/source/keys-of-union.d.ts +2 -0
- package/source/last-array-element.d.ts +3 -1
- package/source/less-than-or-equal.d.ts +2 -0
- package/source/less-than.d.ts +2 -0
- package/source/literal-to-primitive-deep.d.ts +2 -0
- package/source/literal-to-primitive.d.ts +2 -0
- package/source/literal-union.d.ts +3 -1
- package/source/merge-deep.d.ts +3 -1
- package/source/merge-exclusive.d.ts +1 -0
- package/source/merge.d.ts +2 -0
- package/source/multidimensional-array.d.ts +2 -0
- package/source/multidimensional-readonly-array.d.ts +2 -0
- package/source/non-empty-object.d.ts +2 -0
- package/source/non-empty-string.d.ts +2 -0
- package/source/non-empty-tuple.d.ts +2 -0
- package/source/numeric.d.ts +7 -5
- package/source/omit-deep.d.ts +2 -0
- package/source/omit-index-signature.d.ts +2 -0
- package/source/opaque.d.ts +2 -0
- package/source/optional-keys-of.d.ts +2 -0
- package/source/or.d.ts +2 -0
- package/source/override-properties.d.ts +2 -0
- package/source/package-json.d.ts +18 -16
- package/source/partial-deep.d.ts +20 -17
- package/source/partial-on-undefined-deep.d.ts +2 -0
- package/source/pascal-case.d.ts +5 -3
- package/source/pascal-cased-properties-deep.d.ts +4 -2
- package/source/pascal-cased-properties.d.ts +4 -2
- package/source/paths.d.ts +2 -0
- package/source/pick-deep.d.ts +8 -5
- package/source/pick-index-signature.d.ts +2 -0
- package/source/primitive.d.ts +2 -0
- package/source/promisable.d.ts +2 -0
- package/source/readonly-deep.d.ts +6 -4
- package/source/readonly-keys-of.d.ts +2 -0
- package/source/readonly-tuple.d.ts +6 -15
- package/source/remove-prefix.d.ts +4 -2
- package/source/replace.d.ts +3 -1
- package/source/require-all-or-none.d.ts +2 -0
- package/source/require-at-least-one.d.ts +2 -0
- package/source/require-exactly-one.d.ts +2 -0
- package/source/require-one-or-none.d.ts +2 -0
- package/source/required-deep.d.ts +4 -1
- package/source/required-keys-of.d.ts +2 -0
- package/source/schema.d.ts +2 -0
- package/source/screaming-snake-case.d.ts +4 -2
- package/source/set-field-type.d.ts +3 -1
- package/source/set-non-nullable-deep.d.ts +2 -0
- package/source/set-non-nullable.d.ts +2 -0
- package/source/set-optional.d.ts +2 -0
- package/source/set-parameter-type.d.ts +2 -0
- package/source/set-readonly.d.ts +2 -0
- package/source/set-required-deep.d.ts +2 -0
- package/source/set-required.d.ts +2 -0
- package/source/set-return-type.d.ts +2 -0
- package/source/shared-union-fields-deep.d.ts +2 -0
- package/source/shared-union-fields.d.ts +2 -0
- package/source/simplify-deep.d.ts +2 -0
- package/source/simplify.d.ts +2 -0
- package/source/single-key-object.d.ts +2 -0
- package/source/snake-case.d.ts +4 -2
- package/source/snake-cased-properties-deep.d.ts +4 -2
- package/source/snake-cased-properties.d.ts +4 -2
- package/source/split-on-rest-element.d.ts +106 -0
- package/source/split.d.ts +3 -1
- package/source/spread.d.ts +2 -0
- package/source/string-repeat.d.ts +2 -0
- package/source/string-slice.d.ts +2 -0
- package/source/stringified.d.ts +2 -0
- package/source/structured-cloneable.d.ts +2 -0
- package/source/subtract.d.ts +6 -3
- package/source/sum.d.ts +5 -2
- package/source/tagged-union.d.ts +2 -0
- package/source/tagged.d.ts +3 -0
- package/source/trim.d.ts +2 -0
- package/source/tsconfig-json.d.ts +54 -25
- package/source/tuple-of.d.ts +78 -0
- package/source/tuple-to-object.d.ts +2 -0
- package/source/tuple-to-union.d.ts +2 -0
- package/source/typed-array.d.ts +2 -0
- package/source/undefined-on-partial-deep.d.ts +2 -0
- package/source/union-to-intersection.d.ts +3 -1
- package/source/union-to-tuple.d.ts +2 -0
- package/source/unknown-array.d.ts +2 -0
- package/source/unknown-map.d.ts +2 -0
- package/source/unknown-record.d.ts +2 -0
- package/source/unknown-set.d.ts +2 -0
- package/source/value-of.d.ts +2 -0
- package/source/words.d.ts +4 -2
- package/source/writable-deep.d.ts +5 -4
- package/source/writable-keys-of.d.ts +2 -0
- package/source/writable.d.ts +2 -0
- package/source/xor.d.ts +83 -0
package/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type {UnknownRecord} from './source/unknown-record.d.ts';
|
|
|
17
17
|
export type {UnknownArray} from './source/unknown-array.d.ts';
|
|
18
18
|
export type {UnknownSet} from './source/unknown-set.d.ts';
|
|
19
19
|
export type {UnknownMap} from './source/unknown-map.d.ts';
|
|
20
|
-
export type {Except} from './source/except.d.ts';
|
|
20
|
+
export type {Except, ExceptOptions} from './source/except.d.ts';
|
|
21
21
|
export type {TaggedUnion} from './source/tagged-union.d.ts';
|
|
22
22
|
export type {Writable} from './source/writable.d.ts';
|
|
23
23
|
export type {WritableDeep} from './source/writable-deep.d.ts';
|
|
@@ -111,6 +111,9 @@ export type {WritableKeysOf} from './source/writable-keys-of.d.ts';
|
|
|
111
111
|
export type {IsWritableKeyOf} from './source/is-writable-key-of.d.ts';
|
|
112
112
|
export type {HasWritableKeys} from './source/has-writable-keys.d.ts';
|
|
113
113
|
export type {Spread} from './source/spread.d.ts';
|
|
114
|
+
export type {SplitOnRestElement} from './source/split-on-rest-element.d.ts';
|
|
115
|
+
export type {ExtractRestElement} from './source/extract-rest-element.d.ts';
|
|
116
|
+
export type {ExcludeRestElement} from './source/exclude-rest-element.d.ts';
|
|
114
117
|
export type {IsInteger} from './source/is-integer.d.ts';
|
|
115
118
|
export type {IsFloat} from './source/is-float.d.ts';
|
|
116
119
|
export type {TupleToObject} from './source/tuple-to-object.d.ts';
|
|
@@ -132,23 +135,24 @@ export type {IsNever} from './source/is-never.d.ts';
|
|
|
132
135
|
export type {IfNever} from './source/if-never.d.ts';
|
|
133
136
|
export type {IsUnknown} from './source/is-unknown.d.ts';
|
|
134
137
|
export type {IfUnknown} from './source/if-unknown.d.ts';
|
|
135
|
-
export type {IsTuple} from './source/is-tuple.d.ts';
|
|
138
|
+
export type {IsTuple, IsTupleOptions} from './source/is-tuple.d.ts';
|
|
136
139
|
export type {ArrayIndices} from './source/array-indices.d.ts';
|
|
137
140
|
export type {ArrayValues} from './source/array-values.d.ts';
|
|
138
141
|
export type {ArraySlice} from './source/array-slice.d.ts';
|
|
139
142
|
export type {ArraySplice} from './source/array-splice.d.ts';
|
|
140
143
|
export type {ArrayTail} from './source/array-tail.d.ts';
|
|
141
|
-
export type {SetFieldType} from './source/set-field-type.d.ts';
|
|
142
|
-
export type {Paths} from './source/paths.d.ts';
|
|
144
|
+
export type {SetFieldType, SetFieldTypeOptions} from './source/set-field-type.d.ts';
|
|
145
|
+
export type {Paths, PathsOptions} from './source/paths.d.ts';
|
|
143
146
|
export type {AllUnionFields} from './source/all-union-fields.d.ts';
|
|
144
147
|
export type {SharedUnionFields} from './source/shared-union-fields.d.ts';
|
|
145
|
-
export type {SharedUnionFieldsDeep} from './source/shared-union-fields-deep.d.ts';
|
|
148
|
+
export type {SharedUnionFieldsDeep, SharedUnionFieldsDeepOptions} from './source/shared-union-fields-deep.d.ts';
|
|
146
149
|
export type {IsNull} from './source/is-null.d.ts';
|
|
147
150
|
export type {IfNull} from './source/if-null.d.ts';
|
|
148
151
|
export type {IsUndefined} from './source/is-undefined.d.ts';
|
|
149
152
|
export type {And} from './source/and.d.ts';
|
|
150
153
|
export type {Or} from './source/or.d.ts';
|
|
151
|
-
export type {
|
|
154
|
+
export type {Xor} from './source/xor.d.ts';
|
|
155
|
+
export type {AllExtend, AllExtendOptions} from './source/all-extend.d.ts';
|
|
152
156
|
export type {NonEmptyTuple} from './source/non-empty-tuple.d.ts';
|
|
153
157
|
export type {FindGlobalInstanceType, FindGlobalType} from './source/find-global-type.d.ts';
|
|
154
158
|
export type {If} from './source/if.d.ts';
|
|
@@ -157,9 +161,10 @@ export type {IsLowercase} from './source/is-lowercase.d.ts';
|
|
|
157
161
|
export type {IsUppercase} from './source/is-uppercase.d.ts';
|
|
158
162
|
export type {IsOptional} from './source/is-optional.d.ts';
|
|
159
163
|
export type {IsNullable} from './source/is-nullable.d.ts';
|
|
164
|
+
export type {TupleOf} from './source/tuple-of.d.ts';
|
|
160
165
|
|
|
161
166
|
// Template literal types
|
|
162
|
-
export type {CamelCase} from './source/camel-case.d.ts';
|
|
167
|
+
export type {CamelCase, CamelCaseOptions} from './source/camel-case.d.ts';
|
|
163
168
|
export type {CamelCasedProperties} from './source/camel-cased-properties.d.ts';
|
|
164
169
|
export type {CamelCasedPropertiesDeep} from './source/camel-cased-properties-deep.d.ts';
|
|
165
170
|
export type {KebabCase} from './source/kebab-case.d.ts';
|
|
@@ -176,17 +181,17 @@ export type {DelimiterCase} from './source/delimiter-case.d.ts';
|
|
|
176
181
|
export type {DelimiterCasedProperties} from './source/delimiter-cased-properties.d.ts';
|
|
177
182
|
export type {DelimiterCasedPropertiesDeep} from './source/delimiter-cased-properties-deep.d.ts';
|
|
178
183
|
export type {Join} from './source/join.d.ts';
|
|
179
|
-
export type {Split} from './source/split.d.ts';
|
|
180
|
-
export type {Words} from './source/words.d.ts';
|
|
184
|
+
export type {Split, SplitOptions} from './source/split.d.ts';
|
|
185
|
+
export type {Words, WordsOptions} from './source/words.d.ts';
|
|
181
186
|
export type {Trim} from './source/trim.d.ts';
|
|
182
|
-
export type {Replace} from './source/replace.d.ts';
|
|
187
|
+
export type {Replace, ReplaceOptions} from './source/replace.d.ts';
|
|
183
188
|
export type {StringRepeat} from './source/string-repeat.d.ts';
|
|
184
189
|
export type {Includes} from './source/includes.d.ts';
|
|
185
|
-
export type {Get} from './source/get.d.ts';
|
|
190
|
+
export type {Get, GetOptions} from './source/get.d.ts';
|
|
186
191
|
export type {LastArrayElement} from './source/last-array-element.d.ts';
|
|
187
192
|
export type {ConditionalSimplify} from './source/conditional-simplify.d.ts';
|
|
188
193
|
export type {ConditionalSimplifyDeep} from './source/conditional-simplify-deep.d.ts';
|
|
189
|
-
export type {RemovePrefix} from './source/remove-prefix.d.ts';
|
|
194
|
+
export type {RemovePrefix, RemovePrefixOptions} from './source/remove-prefix.d.ts';
|
|
190
195
|
|
|
191
196
|
// Miscellaneous
|
|
192
197
|
export type {GlobalThis} from './source/global-this.d.ts';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-fest",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "A collection of essential TypeScript types",
|
|
5
5
|
"license": "(MIT OR CC0-1.0)",
|
|
6
6
|
"repository": "sindresorhus/type-fest",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test:tsc": "tsc",
|
|
29
29
|
"test:tsd": "tsd",
|
|
30
30
|
"test:xo": "xo",
|
|
31
|
+
"test:linter": "node --test",
|
|
31
32
|
"test": "run-p test:*"
|
|
32
33
|
},
|
|
33
34
|
"files": [
|
package/readme.md
CHANGED
|
@@ -60,6 +60,8 @@ npm install type-fest
|
|
|
60
60
|
> [!NOTE]
|
|
61
61
|
> This readme shows the current development version. For docs about the latest version, see the [npm page](https://www.npmjs.com/package/type-fest).
|
|
62
62
|
|
|
63
|
+
*You may also like my [`ts-extras`](https://github.com/sindresorhus/ts-extras) package which provides runtime functions for some of these types.*
|
|
64
|
+
|
|
63
65
|
## Usage
|
|
64
66
|
|
|
65
67
|
```ts
|
|
@@ -167,8 +169,8 @@ Click the type names for complete docs.
|
|
|
167
169
|
- [`IntClosedRange`](source/int-closed-range.d.ts) - Generate a union of numbers (includes the start and the end).
|
|
168
170
|
- [`ArrayIndices`](source/array-indices.d.ts) - Provides valid indices for a constant array or tuple.
|
|
169
171
|
- [`ArrayValues`](source/array-values.d.ts) - Provides all values for a constant array or tuple.
|
|
170
|
-
- [`ArraySplice`](source/array-splice.d.ts) -
|
|
171
|
-
- [`ArrayTail`](source/array-tail.d.ts) -
|
|
172
|
+
- [`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.
|
|
173
|
+
- [`ArrayTail`](source/array-tail.d.ts) - Extract the type of an array or tuple minus the first element.
|
|
172
174
|
- [`SetFieldType`](source/set-field-type.d.ts) - Create a type that changes the type of the given keys.
|
|
173
175
|
- [`Paths`](source/paths.d.ts) - Generate a union of all possible paths to properties in the given object.
|
|
174
176
|
- [`SharedUnionFields`](source/shared-union-fields.d.ts) - Create a type with shared fields from a union of object types.
|
|
@@ -178,6 +180,7 @@ Click the type names for complete docs.
|
|
|
178
180
|
- [`DistributedPick`](source/distributed-pick.d.ts) - Picks keys from a type, distributing the operation over a union.
|
|
179
181
|
- [`And`](source/and.d.ts) - Returns a boolean for whether two given types are both true.
|
|
180
182
|
- [`Or`](source/or.d.ts) - Returns a boolean for whether either of two given types are true.
|
|
183
|
+
- [`Xor`](source/xor.d.ts) - Returns a boolean for whether only one of two given types is true.
|
|
181
184
|
- [`AllExtend`](source/all-extend.d.ts) - Returns a boolean for whether every element in an array type extends another type.
|
|
182
185
|
- [`NonEmptyTuple`](source/non-empty-tuple.d.ts) - Matches any non-empty tuple.
|
|
183
186
|
- [`NonEmptyString`](source/non-empty-string.d.ts) - Matches any non-empty string.
|
|
@@ -238,7 +241,7 @@ Click the type names for complete docs.
|
|
|
238
241
|
- [`Replace`](source/replace.d.ts) - Represents a string with some or all matches replaced by a replacement.
|
|
239
242
|
- [`StringSlice`](source/string-slice.d.ts) - Returns a string slice of a given range, just like `String#slice()`.
|
|
240
243
|
- [`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()`.
|
|
241
|
-
- [`RemovePrefix`](source/remove-prefix.d.ts) -
|
|
244
|
+
- [`RemovePrefix`](source/remove-prefix.d.ts) - Remove the specified prefix from the start of a string.
|
|
242
245
|
|
|
243
246
|
### Array
|
|
244
247
|
|
|
@@ -246,14 +249,18 @@ Click the type names for complete docs.
|
|
|
246
249
|
- [`Includes`](source/includes.d.ts) - Returns a boolean for whether the given array includes the given item.
|
|
247
250
|
- [`Join`](source/join.d.ts) - Join an array of strings and/or numbers using the given string as a delimiter.
|
|
248
251
|
- [`ArraySlice`](source/array-slice.d.ts) - Returns an array slice of a given range, just like `Array#slice()`.
|
|
249
|
-
- [`LastArrayElement`](source/last-array-element.d.ts) -
|
|
250
|
-
- [`FixedLengthArray`](source/fixed-length-array.d.ts) - Create a type that represents an array of the given type and length.
|
|
252
|
+
- [`LastArrayElement`](source/last-array-element.d.ts) - Extract the type of the last element of an array.
|
|
253
|
+
- [`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.
|
|
251
254
|
- [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and dimensions.
|
|
252
255
|
- [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and dimensions.
|
|
253
256
|
- [`ReadonlyTuple`](source/readonly-tuple.d.ts) - Create a type that represents a read-only tuple of the given type and length.
|
|
254
257
|
- [`TupleToUnion`](source/tuple-to-union.d.ts) - Convert a tuple/array into a union type of its elements.
|
|
255
258
|
- [`UnionToTuple`](source/union-to-tuple.d.ts) - Convert a union type into an unordered tuple type of its elements.
|
|
256
259
|
- [`TupleToObject`](source/tuple-to-object.d.ts) - Transforms a tuple into an object, mapping each tuple index to its corresponding type as a key-value pair.
|
|
260
|
+
- [`TupleOf`](source/tuple-of.d.ts) - Create a tuple type of the specified length with elements of the specified type.
|
|
261
|
+
- [`SplitOnRestElement`](source/split-on-rest-element.d.ts) - Splits an array into three parts, where the first contains all elements before the rest element, the second is the [`rest`](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) element itself, and the third contains all elements after the rest element.
|
|
262
|
+
- [`ExtractRestElement`](source/extract-rest-element.d.ts) - Extract the [`rest`](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) element type from an array.
|
|
263
|
+
- [`ExcludeRestElement`](source/exclude-rest-element.d.ts) - Create a tuple with the [`rest`](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) element removed.
|
|
257
264
|
|
|
258
265
|
### Numeric
|
|
259
266
|
|
|
@@ -283,11 +290,11 @@ Click the type names for complete docs.
|
|
|
283
290
|
- [`CamelCasedProperties`](source/camel-cased-properties.d.ts) - Convert object properties to camel-case (`fooBar`).
|
|
284
291
|
- [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) - Convert object properties to camel-case recursively (`fooBar`).
|
|
285
292
|
- [`KebabCase`](source/kebab-case.d.ts) - Convert a string literal to kebab-case (`foo-bar`).
|
|
286
|
-
- [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert
|
|
287
|
-
- [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab-case (`foo-bar`).
|
|
288
|
-
- [`PascalCase`](source/pascal-case.d.ts) -
|
|
289
|
-
- [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) -
|
|
290
|
-
- [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) -
|
|
293
|
+
- [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert object properties to kebab-case (`foo-bar`).
|
|
294
|
+
- [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab-case recursively (`foo-bar`).
|
|
295
|
+
- [`PascalCase`](source/pascal-case.d.ts) - Convert a string literal to pascal-case (`FooBar`).
|
|
296
|
+
- [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) - Convert object properties to pascal-case (`FooBar`).
|
|
297
|
+
- [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) - Convert object properties to pascal-case recursively (`FooBar`).
|
|
291
298
|
- [`SnakeCase`](source/snake-case.d.ts) - Convert a string literal to snake-case (`foo_bar`).
|
|
292
299
|
- [`SnakeCasedProperties`](source/snake-cased-properties.d.ts) - Convert object properties to snake-case (`foo_bar`).
|
|
293
300
|
- [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake-case recursively (`foo_bar`).
|
|
@@ -342,6 +349,7 @@ Click the type names for complete docs.
|
|
|
342
349
|
- `HomomorphicOmit` - See [`Except`](source/except.d.ts)
|
|
343
350
|
- `IfAny`, `IfNever`, `If*` - See [`If`](source/if.d.ts)
|
|
344
351
|
- `MaybePromise` - See [`Promisable`](source/promisable.d.ts)
|
|
352
|
+
- `ReadonlyTuple` - See [`TupleOf`](source/tuple-of.d.ts)
|
|
345
353
|
|
|
346
354
|
## Tips
|
|
347
355
|
|
package/source/all-extend.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {UnknownArray} from './unknown-array.d.ts';
|
|
|
10
10
|
/**
|
|
11
11
|
@see {@link AllExtend}
|
|
12
12
|
*/
|
|
13
|
-
type AllExtendOptions = {
|
|
13
|
+
export type AllExtendOptions = {
|
|
14
14
|
/**
|
|
15
15
|
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
16
16
|
|
|
@@ -113,3 +113,5 @@ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllE
|
|
|
113
113
|
: false
|
|
114
114
|
: true
|
|
115
115
|
>, false, false>;
|
|
116
|
+
|
|
117
|
+
export {};
|
package/source/and.d.ts
CHANGED
package/source/array-slice.d.ts
CHANGED
package/source/array-splice.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {StaticPartOfArray, VariablePartOfArray} from './internal/index.d.ts';
|
|
2
2
|
import type {GreaterThanOrEqual} from './greater-than-or-equal.d.ts';
|
|
3
3
|
import type {Subtract} from './subtract.d.ts';
|
|
4
4
|
import type {UnknownArray} from './unknown-array.d.ts';
|
|
5
|
+
import type {TupleOf} from './tuple-of.d.ts';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
The implementation of `SplitArrayByIndex` for fixed length arrays.
|
|
@@ -9,7 +10,7 @@ The implementation of `SplitArrayByIndex` for fixed length arrays.
|
|
|
9
10
|
type SplitFixedArrayByIndex<T extends UnknownArray, SplitIndex extends number> =
|
|
10
11
|
SplitIndex extends 0
|
|
11
12
|
? [[], T]
|
|
12
|
-
: T extends readonly [...
|
|
13
|
+
: T extends readonly [...TupleOf<SplitIndex>, ...infer V]
|
|
13
14
|
? T extends readonly [...infer U, ...V]
|
|
14
15
|
? [U, V]
|
|
15
16
|
: [never, never]
|
|
@@ -22,7 +23,7 @@ type SplitVariableArrayByIndex<T extends UnknownArray,
|
|
|
22
23
|
SplitIndex extends number,
|
|
23
24
|
T1 = Subtract<SplitIndex, StaticPartOfArray<T>['length']>,
|
|
24
25
|
T2 = T1 extends number
|
|
25
|
-
?
|
|
26
|
+
? TupleOf<GreaterThanOrEqual<T1, 0> extends true ? T1 : number, VariablePartOfArray<T>[number]>
|
|
26
27
|
: [],
|
|
27
28
|
> =
|
|
28
29
|
SplitIndex extends 0
|
|
@@ -63,7 +64,7 @@ type SplitArrayByIndex<T extends UnknownArray, SplitIndex extends number> =
|
|
|
63
64
|
: SplitFixedArrayByIndex<T, SplitIndex>;
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
|
|
67
|
+
Create a new array type by adding or removing elements at a specified index range in the original array.
|
|
67
68
|
|
|
68
69
|
Use-case: Replace or insert items in an array type.
|
|
69
70
|
|
|
@@ -97,3 +98,5 @@ export type ArraySplice<
|
|
|
97
98
|
? [...U, ...Items, ...X]
|
|
98
99
|
: never // Should never happen
|
|
99
100
|
: never; // Should never happen
|
|
101
|
+
|
|
102
|
+
export {};
|
package/source/array-tail.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {IfNotAnyOrNever, IsArrayReadonly} from './internal/index.d.ts';
|
|
|
3
3
|
import type {UnknownArray} from './unknown-array.d.ts';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
|
|
6
|
+
Extract the type of an array or tuple minus the first element.
|
|
7
7
|
|
|
8
8
|
@example
|
|
9
9
|
```
|
|
@@ -66,3 +66,5 @@ type _ArrayTail<TArray extends UnknownArray> = TArray extends readonly [unknown?
|
|
|
66
66
|
: TArray // Happens when `TArray` is a non-tuple array (e.g., `string[]`) or has a leading rest element (e.g., `[...string[], number]`)
|
|
67
67
|
: Tail
|
|
68
68
|
: [];
|
|
69
|
+
|
|
70
|
+
export {};
|
package/source/array-values.d.ts
CHANGED
package/source/arrayable.d.ts
CHANGED
package/source/asyncify.d.ts
CHANGED
package/source/basic.d.ts
CHANGED
package/source/camel-case.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type CamelCaseOptions = {
|
|
|
15
15
|
preserveConsecutiveUppercase?: boolean;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export type
|
|
18
|
+
export type _DefaultCamelCaseOptions = {
|
|
19
19
|
preserveConsecutiveUppercase: false;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -84,6 +84,8 @@ export type CamelCase<Type, Options extends CamelCaseOptions = {}> = Type extend
|
|
|
84
84
|
? Type
|
|
85
85
|
: Uncapitalize<CamelCaseFromArray<
|
|
86
86
|
Words<Type extends Uppercase<Type> ? Lowercase<Type> : Type>,
|
|
87
|
-
ApplyDefaultOptions<CamelCaseOptions,
|
|
87
|
+
ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options>
|
|
88
88
|
>>
|
|
89
89
|
: Type;
|
|
90
|
+
|
|
91
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {CamelCase, CamelCaseOptions,
|
|
1
|
+
import type {CamelCase, CamelCaseOptions, _DefaultCamelCaseOptions} from './camel-case.d.ts';
|
|
2
2
|
import type {ApplyDefaultOptions, NonRecursiveType} from './internal/index.d.ts';
|
|
3
3
|
import type {UnknownArray} from './unknown-array.d.ts';
|
|
4
4
|
|
|
@@ -57,7 +57,7 @@ const preserveConsecutiveUppercase: CamelCasedPropertiesDeep<{fooBAR: {fooBARBiz
|
|
|
57
57
|
export type CamelCasedPropertiesDeep<
|
|
58
58
|
Value,
|
|
59
59
|
Options extends CamelCaseOptions = {},
|
|
60
|
-
> = _CamelCasedPropertiesDeep<Value, ApplyDefaultOptions<CamelCaseOptions,
|
|
60
|
+
> = _CamelCasedPropertiesDeep<Value, ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options>>;
|
|
61
61
|
|
|
62
62
|
type _CamelCasedPropertiesDeep<
|
|
63
63
|
Value,
|
|
@@ -95,3 +95,5 @@ type CamelCasedPropertiesArrayDeep<
|
|
|
95
95
|
: Value extends ReadonlyArray<infer U>
|
|
96
96
|
? ReadonlyArray<_CamelCasedPropertiesDeep<U, Options>>
|
|
97
97
|
: never;
|
|
98
|
+
|
|
99
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {CamelCase, CamelCaseOptions,
|
|
1
|
+
import type {CamelCase, CamelCaseOptions, _DefaultCamelCaseOptions} from './camel-case.d.ts';
|
|
2
2
|
import type {ApplyDefaultOptions} from './internal/index.d.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -38,6 +38,8 @@ export type CamelCasedProperties<Value, Options extends CamelCaseOptions = {}> =
|
|
|
38
38
|
? Value
|
|
39
39
|
: {
|
|
40
40
|
[K in keyof Value as
|
|
41
|
-
CamelCase<K, ApplyDefaultOptions<CamelCaseOptions,
|
|
41
|
+
CamelCase<K, ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options>>
|
|
42
42
|
]: Value[K];
|
|
43
43
|
};
|
|
44
|
+
|
|
45
|
+
export {};
|
package/source/characters.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type {ApplyDefaultOptions, AsciiPunctuation, StartsWith} from './internal
|
|
|
2
2
|
import type {IsStringLiteral} from './is-literal.d.ts';
|
|
3
3
|
import type {Merge} from './merge.d.ts';
|
|
4
4
|
import type {RemovePrefix} from './remove-prefix.d.ts';
|
|
5
|
-
import type {
|
|
5
|
+
import type {_DefaultWordsOptions, Words, WordsOptions} from './words.d.ts';
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type _DefaultDelimiterCaseOptions = Merge<_DefaultWordsOptions, {splitOnNumbers: false}>;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
Convert an array of words to delimiter case starting with a delimiter with input capitalization.
|
|
@@ -69,7 +69,9 @@ export type DelimiterCase<
|
|
|
69
69
|
? IsStringLiteral<Value> extends false
|
|
70
70
|
? Value
|
|
71
71
|
: Lowercase<RemovePrefix<DelimiterCaseFromArray<
|
|
72
|
-
Words<Value, ApplyDefaultOptions<WordsOptions,
|
|
72
|
+
Words<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>,
|
|
73
73
|
Delimiter
|
|
74
74
|
>, string, {strict: false}>>
|
|
75
75
|
: Value;
|
|
76
|
+
|
|
77
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {_DefaultDelimiterCaseOptions, DelimiterCase} from './delimiter-case.d.ts';
|
|
2
2
|
import type {ApplyDefaultOptions, NonRecursiveType} from './internal/index.d.ts';
|
|
3
3
|
import type {UnknownArray} from './unknown-array.d.ts';
|
|
4
4
|
import type {WordsOptions} from './words.d.ts';
|
|
@@ -61,7 +61,7 @@ export type DelimiterCasedPropertiesDeep<
|
|
|
61
61
|
Value,
|
|
62
62
|
Delimiter extends string,
|
|
63
63
|
Options extends WordsOptions = {},
|
|
64
|
-
> = _DelimiterCasedPropertiesDeep<Value, Delimiter, ApplyDefaultOptions<WordsOptions,
|
|
64
|
+
> = _DelimiterCasedPropertiesDeep<Value, Delimiter, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
|
|
65
65
|
|
|
66
66
|
type _DelimiterCasedPropertiesDeep<
|
|
67
67
|
Value,
|
|
@@ -104,3 +104,5 @@ type DelimiterCasedPropertiesArrayDeep<
|
|
|
104
104
|
: Value extends ReadonlyArray<infer U>
|
|
105
105
|
? ReadonlyArray<_DelimiterCasedPropertiesDeep<U, Delimiter, Options>>
|
|
106
106
|
: never;
|
|
107
|
+
|
|
108
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {_DefaultDelimiterCaseOptions, DelimiterCase} from './delimiter-case.d.ts';
|
|
2
2
|
import type {ApplyDefaultOptions} from './internal/index.d.ts';
|
|
3
3
|
import type {WordsOptions} from './words.d.ts';
|
|
4
4
|
|
|
@@ -42,5 +42,7 @@ export type DelimiterCasedProperties<
|
|
|
42
42
|
: Value extends Array<infer U>
|
|
43
43
|
? Value
|
|
44
44
|
: {[K in keyof Value as
|
|
45
|
-
DelimiterCase<K, Delimiter, ApplyDefaultOptions<WordsOptions,
|
|
45
|
+
DelimiterCase<K, Delimiter, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>
|
|
46
46
|
]: Value[K]};
|
|
47
|
+
|
|
48
|
+
export {};
|
package/source/empty-object.d.ts
CHANGED
package/source/entries.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {_ArrayEntry, _MapEntry, _ObjectEntry, _SetEntry} from './entry.d.ts';
|
|
2
2
|
|
|
3
|
-
type ArrayEntries<BaseType extends readonly unknown[]> = Array<
|
|
4
|
-
type MapEntries<BaseType> = Array<
|
|
5
|
-
type ObjectEntries<BaseType> = Array<
|
|
6
|
-
type SetEntries<BaseType extends Set<unknown>> = Array<
|
|
3
|
+
type ArrayEntries<BaseType extends readonly unknown[]> = Array<_ArrayEntry<BaseType>>;
|
|
4
|
+
type MapEntries<BaseType> = Array<_MapEntry<BaseType>>;
|
|
5
|
+
type ObjectEntries<BaseType> = Array<_ObjectEntry<BaseType>>;
|
|
6
|
+
type SetEntries<BaseType extends Set<unknown>> = Array<_SetEntry<BaseType>>;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
Many collections have an `entries` method which returns an array of a given object's own enumerable string-keyed property [key, value] pairs. The `Entries` type will return the type of that collection's entries.
|
|
@@ -60,3 +60,5 @@ export type Entries<BaseType> =
|
|
|
60
60
|
: BaseType extends readonly unknown[] ? ArrayEntries<BaseType>
|
|
61
61
|
: BaseType extends object ? ObjectEntries<BaseType>
|
|
62
62
|
: never;
|
|
63
|
+
|
|
64
|
+
export {};
|
package/source/entry.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
type MapKey<BaseType> = BaseType extends Map<infer KeyType, unknown> ? KeyType : never;
|
|
2
2
|
type MapValue<BaseType> = BaseType extends Map<unknown, infer ValueType> ? ValueType : never;
|
|
3
3
|
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
4
|
+
export type _ArrayEntry<BaseType extends readonly unknown[]> = [number, BaseType[number]];
|
|
5
|
+
export type _MapEntry<BaseType> = [MapKey<BaseType>, MapValue<BaseType>];
|
|
6
|
+
export type _ObjectEntry<BaseType> = [keyof BaseType, BaseType[keyof BaseType]];
|
|
7
|
+
export type _SetEntry<BaseType> = BaseType extends Set<infer ItemType> ? [ItemType, ItemType] : never;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
Many collections have an `entries` method which returns an array of a given object's own enumerable string-keyed property [key, value] pairs. The `Entry` type will return the type of that collection's entry.
|
|
@@ -58,8 +58,10 @@ const setEntryNumber: Entry<typeof setExample> = [1, 1];
|
|
|
58
58
|
@category Set
|
|
59
59
|
*/
|
|
60
60
|
export type Entry<BaseType> =
|
|
61
|
-
BaseType extends Map<unknown, unknown> ?
|
|
62
|
-
: BaseType extends Set<unknown> ?
|
|
63
|
-
: BaseType extends readonly unknown[] ?
|
|
64
|
-
: BaseType extends object ?
|
|
61
|
+
BaseType extends Map<unknown, unknown> ? _MapEntry<BaseType>
|
|
62
|
+
: BaseType extends Set<unknown> ? _SetEntry<BaseType>
|
|
63
|
+
: BaseType extends readonly unknown[] ? _ArrayEntry<BaseType>
|
|
64
|
+
: BaseType extends object ? _ObjectEntry<BaseType>
|
|
65
65
|
: never;
|
|
66
|
+
|
|
67
|
+
export {};
|
package/source/exact.d.ts
CHANGED
|
@@ -66,3 +66,5 @@ export type Exact<ParameterType, InputType> =
|
|
|
66
66
|
// In TypeScript, Array is a subtype of ReadonlyArray, so always test Array before ReadonlyArray.
|
|
67
67
|
: ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
|
|
68
68
|
: ExactObject<ParameterType, InputType>;
|
|
69
|
+
|
|
70
|
+
export {};
|
package/source/except.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
30
30
|
*/
|
|
31
31
|
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
32
32
|
|
|
33
|
-
type ExceptOptions = {
|
|
33
|
+
export type ExceptOptions = {
|
|
34
34
|
/**
|
|
35
35
|
Disallow assigning non-specified properties.
|
|
36
36
|
|
|
@@ -106,3 +106,5 @@ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Requ
|
|
|
106
106
|
} & (Options['requireExactProps'] extends true
|
|
107
107
|
? Partial<Record<KeysType, never>>
|
|
108
108
|
: {});
|
|
109
|
+
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type {SplitOnRestElement} from './split-on-rest-element.d.ts';
|
|
2
|
+
import type {IsArrayReadonly} from './internal/array.d.ts';
|
|
3
|
+
import type {UnknownArray} from './unknown-array.d.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Create a tuple with the [`rest`](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) element removed.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import type {ExcludeRestElement} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
type T1 = ExcludeRestElement<[number, ...string[], string, 'foo']>;
|
|
13
|
+
//=> [number, string, 'foo']
|
|
14
|
+
|
|
15
|
+
type T2 = ExcludeRestElement<[...boolean[], string]>;
|
|
16
|
+
//=> [string]
|
|
17
|
+
|
|
18
|
+
type T3 = ExcludeRestElement<[...'foo'[], true]>;
|
|
19
|
+
//=> [true]
|
|
20
|
+
|
|
21
|
+
type T4 = ExcludeRestElement<[number, string]>;
|
|
22
|
+
//=> [number, string]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
@see ExtractRestElement, SplitOnRestElement
|
|
26
|
+
@category Array
|
|
27
|
+
*/
|
|
28
|
+
export type ExcludeRestElement<Array_ extends UnknownArray> =
|
|
29
|
+
SplitOnRestElement<Array_> extends infer Result
|
|
30
|
+
? Result extends readonly UnknownArray[]
|
|
31
|
+
? IsArrayReadonly<Array_> extends true
|
|
32
|
+
? Readonly<[...Result[0], ...Result[2]]>
|
|
33
|
+
: [...Result[0], ...Result[2]]
|
|
34
|
+
: Result
|
|
35
|
+
: never;
|
|
36
|
+
|
|
37
|
+
export {};
|