type-fest 2.11.0 → 2.11.1
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/package.json +1 -1
- package/source/readonly-deep.d.ts +26 -5
package/package.json
CHANGED
|
@@ -34,11 +34,17 @@ data.foo.push('bar');
|
|
|
34
34
|
@category Set
|
|
35
35
|
@category Map
|
|
36
36
|
*/
|
|
37
|
-
export type ReadonlyDeep<T> = T extends BuiltIns
|
|
37
|
+
export type ReadonlyDeep<T> = T extends BuiltIns
|
|
38
38
|
? T
|
|
39
|
-
: T extends
|
|
39
|
+
: T extends (...arguments: any[]) => unknown
|
|
40
|
+
? {} extends ReadonlyObjectDeep<T>
|
|
41
|
+
? T
|
|
42
|
+
: HasMultipleCallSignatures<T> extends true
|
|
43
|
+
? T
|
|
44
|
+
: ((...arguments: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T>
|
|
45
|
+
: T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>>
|
|
40
46
|
? ReadonlyMapDeep<KeyType, ValueType>
|
|
41
|
-
: T extends ReadonlySet<infer ItemType
|
|
47
|
+
: T extends Readonly<ReadonlySet<infer ItemType>>
|
|
42
48
|
? ReadonlySetDeep<ItemType>
|
|
43
49
|
: T extends object
|
|
44
50
|
? ReadonlyObjectDeep<T>
|
|
@@ -48,13 +54,13 @@ export type ReadonlyDeep<T> = T extends BuiltIns | ((...arguments: any[]) => unk
|
|
|
48
54
|
Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
|
|
49
55
|
*/
|
|
50
56
|
interface ReadonlyMapDeep<KeyType, ValueType>
|
|
51
|
-
extends ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType
|
|
57
|
+
extends Readonly<ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>>> {}
|
|
52
58
|
|
|
53
59
|
/**
|
|
54
60
|
Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
|
|
55
61
|
*/
|
|
56
62
|
interface ReadonlySetDeep<ItemType>
|
|
57
|
-
extends ReadonlySet<ReadonlyDeep<ItemType
|
|
63
|
+
extends Readonly<ReadonlySet<ReadonlyDeep<ItemType>>> {}
|
|
58
64
|
|
|
59
65
|
/**
|
|
60
66
|
Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
|
|
@@ -62,3 +68,18 @@ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper fo
|
|
|
62
68
|
type ReadonlyObjectDeep<ObjectType extends object> = {
|
|
63
69
|
readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
|
|
64
70
|
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
Test if the given function has multiple call signatures.
|
|
74
|
+
|
|
75
|
+
Needed to handle the case of a single call signature with properties.
|
|
76
|
+
|
|
77
|
+
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
78
|
+
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
79
|
+
*/
|
|
80
|
+
type HasMultipleCallSignatures<T extends (...arguments: any[]) => unknown> =
|
|
81
|
+
T extends {(...arguments: infer A): unknown; (...arguments: any[]): unknown}
|
|
82
|
+
? unknown[] extends A
|
|
83
|
+
? false
|
|
84
|
+
: true
|
|
85
|
+
: false;
|