type-fest 3.13.0 → 4.0.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 CHANGED
@@ -16,13 +16,7 @@ export type {MergeExclusive} from './source/merge-exclusive';
16
16
  export type {RequireAtLeastOne} from './source/require-at-least-one';
17
17
  export type {RequireExactlyOne} from './source/require-exactly-one';
18
18
  export type {RequireAllOrNone} from './source/require-all-or-none';
19
- export type {
20
- OmitIndexSignature,
21
- /**
22
- @deprecated Renamed to {@link OmitIndexSignature}.
23
- */
24
- OmitIndexSignature as RemoveIndexSignature,
25
- } from './source/omit-index-signature';
19
+ export type {OmitIndexSignature} from './source/omit-index-signature';
26
20
  export type {PickIndexSignature} from './source/pick-index-signature';
27
21
  export type {PartialDeep, PartialDeepOptions} from './source/partial-deep';
28
22
  export type {RequiredDeep} from './source/required-deep';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-fest",
3
- "version": "3.13.0",
3
+ "version": "4.0.0",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "types": "./index.d.ts",
14
14
  "engines": {
15
- "node": ">=14.16"
15
+ "node": ">=16"
16
16
  },
17
17
  "scripts": {
18
18
  "test": "xo && tsd && tsc && node script/test/source-files-extension.js"
@@ -38,7 +38,7 @@
38
38
  "expect-type": "^0.15.0",
39
39
  "tsd": "^0.28.1",
40
40
  "typescript": "^5.0.4",
41
- "xo": "^0.54.2"
41
+ "xo": "^0.55.0"
42
42
  },
43
43
  "xo": {
44
44
  "rules": {
package/readme.md CHANGED
@@ -64,7 +64,7 @@ PR welcome for additional commonly needed types and docs improvements. Read the
64
64
  npm install type-fest
65
65
  ```
66
66
 
67
- *Requires TypeScript >=4.7*
67
+ *Requires TypeScript >=5.1*
68
68
 
69
69
  ## Usage
70
70
 
@@ -235,8 +235,8 @@ Needed to handle the case of a single call signature with properties.
235
235
  Multiple call signatures cannot currently be supported due to a TypeScript limitation.
236
236
  @see https://github.com/microsoft/TypeScript/issues/29732
237
237
  */
238
- export type HasMultipleCallSignatures<T extends (...arguments: any[]) => unknown> =
239
- T extends {(...arguments: infer A): unknown; (...arguments: any[]): unknown}
238
+ export type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> =
239
+ T extends {(...arguments_: infer A): unknown; (...arguments_: any[]): unknown}
240
240
  ? unknown[] extends A
241
241
  ? false
242
242
  : true
@@ -18,11 +18,11 @@ typeof lastOf(array);
18
18
  @category Array
19
19
  @category Template literal
20
20
  */
21
- export type LastArrayElement<ValueType extends readonly unknown[]> =
22
- ValueType extends readonly [infer ElementType]
23
- ? ElementType
24
- : ValueType extends readonly [infer _, ...infer Tail]
25
- ? LastArrayElement<Tail>
26
- : ValueType extends ReadonlyArray<infer ElementType>
27
- ? ElementType
21
+ export type LastArrayElement<Elements extends readonly unknown[]>
22
+ = number extends Elements['length']
23
+ ? Elements extends ReadonlyArray<infer Element>
24
+ ? Element
25
+ : never
26
+ : Elements extends readonly [...any, infer Target]
27
+ ? Target
28
28
  : never;
@@ -505,7 +505,7 @@ declare namespace PackageJson {
505
505
  Engines that this package runs on.
506
506
  */
507
507
  engines?: {
508
- [EngineName in 'npm' | 'node' | string]?: string; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents
508
+ [EngineName in 'npm' | 'node' | string]?: string;
509
509
  };
510
510
 
511
511
  /**
@@ -69,7 +69,7 @@ export type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends
69
69
  ? PartialReadonlyMapDeep<KeyType, ValueType, Options>
70
70
  : T extends ReadonlySet<infer ItemType>
71
71
  ? PartialReadonlySetDeep<ItemType, Options>
72
- : T extends ((...arguments: any[]) => unknown)
72
+ : T extends ((...arguments_: any[]) => unknown)
73
73
  ? T | undefined
74
74
  : T extends object
75
75
  ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
@@ -55,7 +55,7 @@ export type PartialOnUndefinedDeep<T, Options extends PartialOnUndefinedDeepOpti
55
55
  /**
56
56
  Utility type to get the value type by key and recursively call `PartialOnUndefinedDeep` to transform sub-objects.
57
57
  */
58
- type PartialOnUndefinedDeepValue<T, Options extends PartialOnUndefinedDeepOptions> = T extends BuiltIns | ((...arguments: any[]) => unknown)
58
+ type PartialOnUndefinedDeepValue<T, Options extends PartialOnUndefinedDeepOptions> = T extends BuiltIns | ((...arguments_: any[]) => unknown)
59
59
  ? T
60
60
  : T extends ReadonlyArray<infer U> // Test if type is array or tuple
61
61
  ? Options['recurseIntoArrays'] extends true // Check if option is activated
@@ -38,12 +38,12 @@ Note that types containing overloaded functions are not made deeply readonly due
38
38
  */
39
39
  export type ReadonlyDeep<T> = T extends BuiltIns
40
40
  ? T
41
- : T extends (...arguments: any[]) => unknown
41
+ : T extends (...arguments_: any[]) => unknown
42
42
  ? {} extends ReadonlyObjectDeep<T>
43
43
  ? T
44
44
  : HasMultipleCallSignatures<T> extends true
45
45
  ? T
46
- : ((...arguments: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T>
46
+ : ((...arguments_: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T>
47
47
  : T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>>
48
48
  ? ReadonlyMapDeep<KeyType, ValueType>
49
49
  : T extends Readonly<ReadonlySet<infer ItemType>>
@@ -59,12 +59,12 @@ export type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>>
59
59
  ? WeakSet<RequiredDeep<ItemType>>
60
60
  : E extends Promise<infer ValueType>
61
61
  ? Promise<RequiredDeep<ValueType>>
62
- : E extends (...args: any[]) => unknown
62
+ : E extends (...arguments_: any[]) => unknown
63
63
  ? {} extends RequiredObjectDeep<E>
64
64
  ? E
65
65
  : HasMultipleCallSignatures<E> extends true
66
66
  ? E
67
- : ((...arguments: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E>
67
+ : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E>
68
68
  : E extends object
69
69
  ? E extends Array<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
70
70
  ? ItemType[] extends E // Test for arrays (non-tuples) specifically
@@ -51,7 +51,7 @@ export type Schema<ObjectType, ValueType> = ObjectType extends string
51
51
  ? ValueType
52
52
  : ObjectType extends unknown[]
53
53
  ? ValueType
54
- : ObjectType extends (...arguments: unknown[]) => unknown
54
+ : ObjectType extends (...arguments_: unknown[]) => unknown
55
55
  ? ValueType
56
56
  : ObjectType extends Date
57
57
  ? ValueType
@@ -32,12 +32,12 @@ Note that types containing overloaded functions are not made deeply writable due
32
32
  */
33
33
  export type WritableDeep<T> = T extends BuiltIns
34
34
  ? T
35
- : T extends (...arguments: any[]) => unknown
35
+ : T extends (...arguments_: any[]) => unknown
36
36
  ? {} extends WritableObjectDeep<T>
37
37
  ? T
38
38
  : HasMultipleCallSignatures<T> extends true
39
39
  ? T
40
- : ((...arguments: Parameters<T>) => ReturnType<T>) & WritableObjectDeep<T>
40
+ : ((...arguments_: Parameters<T>) => ReturnType<T>) & WritableObjectDeep<T>
41
41
  : T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>>
42
42
  ? WritableMapDeep<KeyType, ValueType>
43
43
  : T extends Readonly<ReadonlySet<infer ItemType>>