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 +1 -7
- package/package.json +3 -3
- package/readme.md +1 -1
- package/source/internal.d.ts +2 -2
- package/source/last-array-element.d.ts +7 -7
- package/source/package-json.d.ts +1 -1
- package/source/partial-deep.d.ts +1 -1
- package/source/partial-on-undefined-deep.d.ts +1 -1
- package/source/readonly-deep.d.ts +2 -2
- package/source/required-deep.d.ts +2 -2
- package/source/schema.d.ts +1 -1
- package/source/writable-deep.d.ts +2 -2
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
|
+
"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": ">=
|
|
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.
|
|
41
|
+
"xo": "^0.55.0"
|
|
42
42
|
},
|
|
43
43
|
"xo": {
|
|
44
44
|
"rules": {
|
package/readme.md
CHANGED
package/source/internal.d.ts
CHANGED
|
@@ -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 (...
|
|
239
|
-
T extends {(...
|
|
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<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
?
|
|
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;
|
package/source/package-json.d.ts
CHANGED
|
@@ -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;
|
|
508
|
+
[EngineName in 'npm' | 'node' | string]?: string;
|
|
509
509
|
};
|
|
510
510
|
|
|
511
511
|
/**
|
package/source/partial-deep.d.ts
CHANGED
|
@@ -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 ((...
|
|
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 | ((...
|
|
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 (...
|
|
41
|
+
: T extends (...arguments_: any[]) => unknown
|
|
42
42
|
? {} extends ReadonlyObjectDeep<T>
|
|
43
43
|
? T
|
|
44
44
|
: HasMultipleCallSignatures<T> extends true
|
|
45
45
|
? T
|
|
46
|
-
: ((...
|
|
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 (...
|
|
62
|
+
: E extends (...arguments_: any[]) => unknown
|
|
63
63
|
? {} extends RequiredObjectDeep<E>
|
|
64
64
|
? E
|
|
65
65
|
: HasMultipleCallSignatures<E> extends true
|
|
66
66
|
? E
|
|
67
|
-
: ((...
|
|
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
|
package/source/schema.d.ts
CHANGED
|
@@ -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 (...
|
|
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 (...
|
|
35
|
+
: T extends (...arguments_: any[]) => unknown
|
|
36
36
|
? {} extends WritableObjectDeep<T>
|
|
37
37
|
? T
|
|
38
38
|
: HasMultipleCallSignatures<T> extends true
|
|
39
39
|
? T
|
|
40
|
-
: ((...
|
|
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>>
|