type-fest 4.40.1 → 5.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 +174 -152
- package/package.json +20 -44
- package/readme.md +46 -68
- package/source/all-extend.d.ts +115 -0
- package/source/all-union-fields.d.ts +12 -12
- package/source/and.d.ts +60 -8
- package/source/array-slice.d.ts +11 -11
- package/source/array-splice.d.ts +4 -4
- package/source/array-tail.d.ts +40 -48
- package/source/arrayable.d.ts +2 -2
- package/source/asyncify.d.ts +1 -1
- package/source/basic.d.ts +1 -33
- package/source/camel-case.d.ts +6 -6
- package/source/camel-cased-properties-deep.d.ts +7 -7
- package/source/camel-cased-properties.d.ts +4 -4
- package/source/characters.d.ts +60 -0
- package/source/conditional-except.d.ts +4 -4
- package/source/conditional-keys.d.ts +33 -19
- package/source/conditional-pick-deep.d.ts +9 -9
- package/source/conditional-pick.d.ts +3 -3
- package/source/conditional-simplify-deep.d.ts +71 -0
- package/source/conditional-simplify.d.ts +36 -20
- package/source/delimiter-case.d.ts +9 -12
- package/source/delimiter-cased-properties-deep.d.ts +4 -4
- package/source/delimiter-cased-properties.d.ts +3 -3
- package/source/distributed-omit.d.ts +1 -1
- package/source/distributed-pick.d.ts +1 -1
- package/source/enforce-optional.d.ts +1 -1
- package/source/entries.d.ts +1 -1
- package/source/exact.d.ts +6 -6
- package/source/except.d.ts +2 -2
- package/source/exclude-strict.d.ts +45 -0
- package/source/extends-strict.d.ts +42 -0
- package/source/extract-strict.d.ts +45 -0
- package/source/find-global-type.d.ts +1 -1
- package/source/fixed-length-array.d.ts +2 -2
- package/source/get.d.ts +15 -14
- package/source/globals/index.d.ts +1 -0
- package/source/{observable-like.d.ts → globals/observable-like.d.ts} +10 -0
- package/source/greater-than-or-equal.d.ts +1 -1
- package/source/greater-than.d.ts +37 -32
- 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/if-any.d.ts +3 -1
- package/source/if-empty-object.d.ts +3 -1
- package/source/if-never.d.ts +3 -1
- package/source/if-null.d.ts +3 -1
- package/source/if-unknown.d.ts +3 -1
- package/source/if.d.ts +65 -0
- package/source/includes.d.ts +1 -1
- package/source/int-closed-range.d.ts +2 -2
- package/source/int-range.d.ts +6 -4
- package/source/internal/array.d.ts +54 -22
- package/source/internal/characters.d.ts +0 -4
- package/source/internal/index.d.ts +8 -8
- package/source/internal/keys.d.ts +24 -23
- package/source/internal/numeric.d.ts +45 -15
- package/source/internal/object.d.ts +58 -29
- package/source/internal/string.d.ts +4 -14
- package/source/internal/tuple.d.ts +4 -4
- package/source/internal/type.d.ts +42 -25
- package/source/is-any.d.ts +0 -4
- package/source/is-float.d.ts +1 -3
- package/source/is-integer.d.ts +4 -4
- package/source/is-literal.d.ts +44 -28
- package/source/is-lowercase.d.ts +36 -0
- package/source/is-nullable.d.ts +28 -0
- package/source/is-optional-key-of.d.ts +49 -0
- package/source/is-optional.d.ts +26 -0
- package/source/is-readonly-key-of.d.ts +53 -0
- package/source/is-required-key-of.d.ts +49 -0
- package/source/is-tuple.d.ts +15 -14
- package/source/is-undefined.d.ts +20 -0
- package/source/is-union.d.ts +37 -0
- package/source/is-unknown.d.ts +1 -1
- package/source/is-uppercase.d.ts +36 -0
- package/source/is-writable-key-of.d.ts +49 -0
- package/source/json-value.d.ts +31 -0
- package/source/jsonifiable.d.ts +1 -1
- package/source/jsonify.d.ts +18 -14
- package/source/kebab-case.d.ts +3 -3
- package/source/kebab-cased-properties-deep.d.ts +4 -4
- package/source/kebab-cased-properties.d.ts +4 -4
- package/source/{string-key-of.d.ts → key-as-string.d.ts} +5 -5
- package/source/keys-of-union.d.ts +1 -1
- package/source/less-than-or-equal.d.ts +1 -1
- package/source/less-than.d.ts +6 -2
- package/source/literal-to-primitive-deep.d.ts +2 -2
- package/source/literal-union.d.ts +1 -1
- package/source/merge-deep.d.ts +43 -34
- package/source/merge.d.ts +5 -5
- package/source/multidimensional-array.d.ts +2 -2
- package/source/multidimensional-readonly-array.d.ts +2 -2
- package/source/non-empty-object.d.ts +2 -2
- package/source/numeric.d.ts +4 -4
- package/source/omit-deep.d.ts +11 -11
- package/source/opaque.d.ts +1 -1
- package/source/optional-keys-of.d.ts +10 -5
- package/source/or.d.ts +67 -7
- package/source/override-properties.d.ts +1 -1
- package/source/package-json.d.ts +78 -78
- package/source/partial-deep.d.ts +22 -21
- package/source/partial-on-undefined-deep.d.ts +5 -4
- package/source/pascal-case.d.ts +13 -6
- package/source/pascal-cased-properties-deep.d.ts +11 -3
- package/source/pascal-cased-properties.d.ts +7 -3
- package/source/paths.d.ts +42 -39
- package/source/pick-deep.d.ts +6 -6
- package/source/readonly-deep.d.ts +2 -2
- package/source/readonly-keys-of.d.ts +10 -4
- package/source/remove-prefix.d.ts +128 -0
- package/source/replace.d.ts +1 -1
- package/source/require-all-or-none.d.ts +12 -2
- package/source/require-at-least-one.d.ts +16 -2
- package/source/require-exactly-one.d.ts +12 -0
- package/source/require-one-or-none.d.ts +13 -3
- package/source/required-deep.d.ts +26 -32
- package/source/required-keys-of.d.ts +4 -4
- package/source/schema.d.ts +74 -74
- package/source/screaming-snake-case.d.ts +4 -4
- package/source/set-field-type.d.ts +2 -2
- package/source/set-non-nullable-deep.d.ts +83 -0
- package/source/set-optional.d.ts +11 -6
- package/source/set-parameter-type.d.ts +7 -7
- package/source/set-readonly.d.ts +12 -10
- package/source/set-required-deep.d.ts +12 -12
- package/source/set-required.d.ts +15 -9
- package/source/set-return-type.d.ts +1 -1
- package/source/shared-union-fields-deep.d.ts +10 -10
- package/source/shared-union-fields.d.ts +5 -4
- package/source/simplify-deep.d.ts +3 -3
- package/source/single-key-object.d.ts +4 -3
- package/source/snake-case.d.ts +3 -3
- package/source/snake-cased-properties-deep.d.ts +4 -4
- package/source/snake-cased-properties.d.ts +4 -4
- package/source/split.d.ts +9 -9
- package/source/spread.d.ts +3 -3
- package/source/string-repeat.d.ts +2 -2
- package/source/string-slice.d.ts +3 -3
- package/source/structured-cloneable.d.ts +25 -25
- package/source/subtract.d.ts +3 -3
- package/source/sum.d.ts +3 -3
- package/source/tagged-union.d.ts +1 -1
- package/source/tagged.d.ts +3 -1
- package/source/trim.d.ts +1 -1
- package/source/tsconfig-json.d.ts +2 -1
- package/source/tuple-to-object.d.ts +5 -4
- package/source/undefined-on-partial-deep.d.ts +1 -1
- package/source/union-to-tuple.d.ts +2 -2
- package/source/value-of.d.ts +1 -1
- package/source/words.d.ts +5 -5
- package/source/writable-deep.d.ts +1 -1
- package/source/writable-keys-of.d.ts +5 -6
- package/source/writable.d.ts +4 -4
package/source/merge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {OmitIndexSignature} from './omit-index-signature';
|
|
2
|
-
import type {PickIndexSignature} from './pick-index-signature';
|
|
3
|
-
import type {Simplify} from './simplify';
|
|
1
|
+
import type {OmitIndexSignature} from './omit-index-signature.d.ts';
|
|
2
|
+
import type {PickIndexSignature} from './pick-index-signature.d.ts';
|
|
3
|
+
import type {Simplify} from './simplify.d.ts';
|
|
4
4
|
|
|
5
5
|
// Merges two objects without worrying about index signatures.
|
|
6
6
|
type SimpleMerge<Destination, Source> = {
|
|
@@ -43,6 +43,6 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
43
43
|
*/
|
|
44
44
|
export type Merge<Destination, Source> =
|
|
45
45
|
Simplify<
|
|
46
|
-
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
|
|
47
|
-
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
|
|
46
|
+
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
|
|
47
|
+
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
|
|
48
48
|
>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {HasRequiredKeys} from './has-required-keys';
|
|
2
|
-
import type {RequireAtLeastOne} from './require-at-least-one';
|
|
1
|
+
import type {HasRequiredKeys} from './has-required-keys.d.ts';
|
|
2
|
+
import type {RequireAtLeastOne} from './require-at-least-one.d.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
Represents an object with at least 1 non-optional key.
|
package/source/numeric.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {IsFloat} from './is-float';
|
|
2
|
-
import type {IsInteger} from './is-integer';
|
|
1
|
+
import type {IsFloat} from './is-float.d.ts';
|
|
2
|
+
import type {IsInteger} from './is-integer.d.ts';
|
|
3
3
|
|
|
4
4
|
export type Numeric = number | bigint;
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277)
|
|
|
15
15
|
@category Numeric
|
|
16
16
|
*/
|
|
17
17
|
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
18
|
-
// eslint-disable-next-line
|
|
18
|
+
// eslint-disable-next-line no-loss-of-precision
|
|
19
19
|
export type PositiveInfinity = 1e999;
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -28,7 +28,7 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277)
|
|
|
28
28
|
@category Numeric
|
|
29
29
|
*/
|
|
30
30
|
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
31
|
-
// eslint-disable-next-line
|
|
31
|
+
// eslint-disable-next-line no-loss-of-precision
|
|
32
32
|
export type NegativeInfinity = -1e999;
|
|
33
33
|
|
|
34
34
|
/**
|
package/source/omit-deep.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {ArraySplice} from './array-splice';
|
|
2
|
-
import type {ExactKey, IsArrayReadonly, NonRecursiveType, SetArrayAccess, ToString} from './internal';
|
|
3
|
-
import type {IsEqual} from './is-equal';
|
|
4
|
-
import type {IsNever} from './is-never';
|
|
5
|
-
import type {LiteralUnion} from './literal-union';
|
|
6
|
-
import type {Paths} from './paths';
|
|
7
|
-
import type {SimplifyDeep} from './simplify-deep';
|
|
8
|
-
import type {UnionToTuple} from './union-to-tuple';
|
|
9
|
-
import type {UnknownArray} from './unknown-array';
|
|
1
|
+
import type {ArraySplice} from './array-splice.d.ts';
|
|
2
|
+
import type {ExactKey, IsArrayReadonly, NonRecursiveType, SetArrayAccess, ToString} from './internal/index.d.ts';
|
|
3
|
+
import type {IsEqual} from './is-equal.d.ts';
|
|
4
|
+
import type {IsNever} from './is-never.d.ts';
|
|
5
|
+
import type {LiteralUnion} from './literal-union.d.ts';
|
|
6
|
+
import type {Paths} from './paths.d.ts';
|
|
7
|
+
import type {SimplifyDeep} from './simplify-deep.d.ts';
|
|
8
|
+
import type {UnionToTuple} from './union-to-tuple.d.ts';
|
|
9
|
+
import type {UnknownArray} from './unknown-array.d.ts';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
Omit properties from a deeply-nested object.
|
|
@@ -92,8 +92,8 @@ type AddressInfo = OmitDeep<Info1, 'address.1.foo'>;
|
|
|
92
92
|
*/
|
|
93
93
|
export type OmitDeep<T, PathUnion extends LiteralUnion<Paths<T>, string>> =
|
|
94
94
|
SimplifyDeep<
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
OmitDeepHelper<T, UnionToTuple<PathUnion>>,
|
|
96
|
+
UnknownArray>;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
Internal helper for {@link OmitDeep}.
|
package/source/opaque.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './tagged';
|
|
1
|
+
export type * from './tagged.d.ts';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {IsOptionalKeyOf} from './is-optional-key-of.d.ts';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
Extract all optional keys from the given type.
|
|
3
5
|
|
|
@@ -31,9 +33,12 @@ const update2: UpdateOperation<User> = {
|
|
|
31
33
|
|
|
32
34
|
@category Utilities
|
|
33
35
|
*/
|
|
34
|
-
export type OptionalKeysOf<
|
|
35
|
-
|
|
36
|
-
? (keyof {
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
export type OptionalKeysOf<Type extends object> =
|
|
37
|
+
Type extends unknown // For distributing `Type`
|
|
38
|
+
? (keyof {[Key in keyof Type as
|
|
39
|
+
IsOptionalKeyOf<Type, Key> extends false
|
|
40
|
+
? never
|
|
41
|
+
: Key
|
|
42
|
+
]: never
|
|
43
|
+
}) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
39
44
|
: never; // Should never happen
|
package/source/or.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {If} from './if.d.ts';
|
|
2
|
+
import type {IsNever} from './is-never.d.ts';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
Returns a boolean for whether either of two given types are true.
|
|
@@ -9,17 +10,76 @@ Use-case: Constructing complex conditional types where multiple conditions must
|
|
|
9
10
|
```
|
|
10
11
|
import type {Or} from 'type-fest';
|
|
11
12
|
|
|
12
|
-
Or<true, false>;
|
|
13
|
+
type TT = Or<true, false>;
|
|
13
14
|
//=> true
|
|
14
15
|
|
|
15
|
-
Or<
|
|
16
|
+
type TF = Or<true, false>;
|
|
17
|
+
//=> true
|
|
18
|
+
|
|
19
|
+
type FT = Or<false, true>;
|
|
20
|
+
//=> true
|
|
21
|
+
|
|
22
|
+
type FF = Or<false, false>;
|
|
23
|
+
//=> false
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
27
|
+
For example, `And<false, boolean>` expands to `And<false, true> | And<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
28
|
+
@example
|
|
29
|
+
```
|
|
30
|
+
import type {And} from 'type-fest';
|
|
31
|
+
|
|
32
|
+
type A = Or<false, boolean>;
|
|
33
|
+
//=> boolean
|
|
34
|
+
|
|
35
|
+
type B = Or<boolean, false>;
|
|
36
|
+
//=> boolean
|
|
37
|
+
|
|
38
|
+
type C = Or<true, boolean>;
|
|
39
|
+
//=> true
|
|
40
|
+
|
|
41
|
+
type D = Or<boolean, true>;
|
|
42
|
+
//=> true
|
|
43
|
+
|
|
44
|
+
type E = Or<boolean, boolean>;
|
|
45
|
+
//=> boolean
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
49
|
+
|
|
50
|
+
@example
|
|
51
|
+
```
|
|
52
|
+
import type {Or} from 'type-fest';
|
|
53
|
+
|
|
54
|
+
type A = Or<true, never>;
|
|
55
|
+
//=> true
|
|
56
|
+
|
|
57
|
+
type B = Or<never, true>;
|
|
58
|
+
//=> true
|
|
59
|
+
|
|
60
|
+
type C = Or<false, never>;
|
|
61
|
+
//=> false
|
|
62
|
+
|
|
63
|
+
type D = Or<never, false>;
|
|
64
|
+
//=> false
|
|
65
|
+
|
|
66
|
+
type E = Or<boolean, never>;
|
|
67
|
+
//=> boolean
|
|
68
|
+
|
|
69
|
+
type F = Or<never, boolean>;
|
|
70
|
+
//=> boolean
|
|
71
|
+
|
|
72
|
+
type G = Or<never, never>;
|
|
16
73
|
//=> false
|
|
17
74
|
```
|
|
18
75
|
|
|
19
76
|
@see {@link And}
|
|
20
77
|
*/
|
|
21
|
-
export type Or<A extends boolean, B extends boolean> =
|
|
22
|
-
|
|
23
|
-
|
|
78
|
+
export type Or<A extends boolean, B extends boolean> =
|
|
79
|
+
_Or<If<IsNever<A>, false, A>, If<IsNever<B>, false, B>>; // `never` is treated as `false`
|
|
80
|
+
|
|
81
|
+
export type _Or<A extends boolean, B extends boolean> = A extends true
|
|
82
|
+
? true
|
|
83
|
+
: B extends true
|
|
24
84
|
? true
|
|
25
|
-
:
|
|
85
|
+
: false;
|
package/source/package-json.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {LiteralUnion} from './literal-union';
|
|
2
|
-
import type {JsonObject, JsonValue} from './
|
|
1
|
+
import type {LiteralUnion} from './literal-union.d.ts';
|
|
2
|
+
import type {JsonObject, JsonValue} from './json-value.d.ts';
|
|
3
3
|
|
|
4
4
|
declare namespace PackageJson {
|
|
5
5
|
/**
|
|
@@ -211,7 +211,7 @@ declare namespace PackageJson {
|
|
|
211
211
|
/**
|
|
212
212
|
A mapping of conditions and the paths to which they resolve.
|
|
213
213
|
*/
|
|
214
|
-
type ExportConditions = {
|
|
214
|
+
type ExportConditions = {
|
|
215
215
|
[condition: string]: Exports;
|
|
216
216
|
};
|
|
217
217
|
|
|
@@ -219,15 +219,15 @@ declare namespace PackageJson {
|
|
|
219
219
|
Entry points of a module, optionally with conditions and subpath exports.
|
|
220
220
|
*/
|
|
221
221
|
export type Exports =
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
| null
|
|
223
|
+
| string
|
|
224
|
+
| Array<string | ExportConditions>
|
|
225
|
+
| ExportConditions;
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
Import map entries of a module, optionally with conditions and subpath imports.
|
|
229
229
|
*/
|
|
230
|
-
export type Imports = {
|
|
230
|
+
export type Imports = {
|
|
231
231
|
[key: `#${string}`]: Exports;
|
|
232
232
|
};
|
|
233
233
|
|
|
@@ -242,19 +242,19 @@ declare namespace PackageJson {
|
|
|
242
242
|
A module ID with untranspiled code that is the primary entry point to the program.
|
|
243
243
|
*/
|
|
244
244
|
esnext?:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
245
|
+
| string
|
|
246
|
+
| {
|
|
247
|
+
[moduleName: string]: string | undefined;
|
|
248
|
+
main?: string;
|
|
249
|
+
browser?: string;
|
|
250
|
+
};
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
253
|
A hint to JavaScript bundlers or component tools when packaging modules for client side use.
|
|
254
254
|
*/
|
|
255
255
|
browser?:
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
| string
|
|
257
|
+
| Partial<Record<string, string | false>>;
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
260
|
Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.
|
|
@@ -426,8 +426,8 @@ declare namespace PackageJson {
|
|
|
426
426
|
The executable files that should be installed into the `PATH`.
|
|
427
427
|
*/
|
|
428
428
|
bin?:
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
| string
|
|
430
|
+
| Partial<Record<string, string>>;
|
|
431
431
|
|
|
432
432
|
/**
|
|
433
433
|
Filenames to put in place for the `man` program to find.
|
|
@@ -443,18 +443,18 @@ declare namespace PackageJson {
|
|
|
443
443
|
Location for the code repository.
|
|
444
444
|
*/
|
|
445
445
|
repository?:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
446
|
+
| string
|
|
447
|
+
| {
|
|
448
|
+
type: string;
|
|
449
|
+
url: string;
|
|
450
450
|
|
|
451
|
-
|
|
451
|
+
/**
|
|
452
452
|
Relative path to package.json if it is placed in non-root directory (for example if it is part of a monorepo).
|
|
453
453
|
|
|
454
454
|
[Read more.](https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md)
|
|
455
455
|
*/
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
directory?: string;
|
|
457
|
+
};
|
|
458
458
|
|
|
459
459
|
/**
|
|
460
460
|
Script commands that are run at various times in the lifecycle of the package. The key is the lifecycle event, and the value is the command to run at that point.
|
|
@@ -517,50 +517,50 @@ declare namespace PackageJson {
|
|
|
517
517
|
Operating systems the module runs on.
|
|
518
518
|
*/
|
|
519
519
|
os?: Array<LiteralUnion<
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
520
|
+
| 'aix'
|
|
521
|
+
| 'darwin'
|
|
522
|
+
| 'freebsd'
|
|
523
|
+
| 'linux'
|
|
524
|
+
| 'openbsd'
|
|
525
|
+
| 'sunos'
|
|
526
|
+
| 'win32'
|
|
527
|
+
| '!aix'
|
|
528
|
+
| '!darwin'
|
|
529
|
+
| '!freebsd'
|
|
530
|
+
| '!linux'
|
|
531
|
+
| '!openbsd'
|
|
532
|
+
| '!sunos'
|
|
533
|
+
| '!win32',
|
|
534
|
+
string
|
|
535
535
|
>>;
|
|
536
536
|
|
|
537
537
|
/**
|
|
538
538
|
CPU architectures the module runs on.
|
|
539
539
|
*/
|
|
540
540
|
cpu?: Array<LiteralUnion<
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
541
|
+
| 'arm'
|
|
542
|
+
| 'arm64'
|
|
543
|
+
| 'ia32'
|
|
544
|
+
| 'mips'
|
|
545
|
+
| 'mipsel'
|
|
546
|
+
| 'ppc'
|
|
547
|
+
| 'ppc64'
|
|
548
|
+
| 's390'
|
|
549
|
+
| 's390x'
|
|
550
|
+
| 'x32'
|
|
551
|
+
| 'x64'
|
|
552
|
+
| '!arm'
|
|
553
|
+
| '!arm64'
|
|
554
|
+
| '!ia32'
|
|
555
|
+
| '!mips'
|
|
556
|
+
| '!mipsel'
|
|
557
|
+
| '!ppc'
|
|
558
|
+
| '!ppc64'
|
|
559
|
+
| '!s390'
|
|
560
|
+
| '!s390x'
|
|
561
|
+
| '!x32'
|
|
562
|
+
| '!x64',
|
|
563
|
+
string
|
|
564
564
|
>>;
|
|
565
565
|
|
|
566
566
|
/**
|
|
@@ -583,20 +583,20 @@ declare namespace PackageJson {
|
|
|
583
583
|
/**
|
|
584
584
|
Describes and notifies consumers of a package's monetary support information.
|
|
585
585
|
|
|
586
|
-
[Read more.](https://github.com/npm/rfcs/blob/
|
|
586
|
+
[Read more.](https://github.com/npm/rfcs/blob/main/implemented/0017-add-funding-support.md)
|
|
587
587
|
*/
|
|
588
588
|
funding?: string | {
|
|
589
589
|
/**
|
|
590
590
|
The type of funding.
|
|
591
591
|
*/
|
|
592
592
|
type?: LiteralUnion<
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
593
|
+
| 'github'
|
|
594
|
+
| 'opencollective'
|
|
595
|
+
| 'patreon'
|
|
596
|
+
| 'individual'
|
|
597
|
+
| 'foundation'
|
|
598
|
+
| 'corporation',
|
|
599
|
+
string
|
|
600
600
|
>;
|
|
601
601
|
|
|
602
602
|
/**
|
|
@@ -667,10 +667,10 @@ Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-j
|
|
|
667
667
|
@category File
|
|
668
668
|
*/
|
|
669
669
|
export type PackageJson =
|
|
670
|
-
JsonObject &
|
|
671
|
-
PackageJson.NodeJsStandard &
|
|
672
|
-
PackageJson.PackageJsonStandard &
|
|
673
|
-
PackageJson.NonStandardEntryPoints &
|
|
674
|
-
PackageJson.TypeScriptConfiguration &
|
|
675
|
-
PackageJson.YarnConfiguration &
|
|
676
|
-
PackageJson.JSPMConfiguration;
|
|
670
|
+
JsonObject &
|
|
671
|
+
PackageJson.NodeJsStandard &
|
|
672
|
+
PackageJson.PackageJsonStandard &
|
|
673
|
+
PackageJson.NonStandardEntryPoints &
|
|
674
|
+
PackageJson.TypeScriptConfiguration &
|
|
675
|
+
PackageJson.YarnConfiguration &
|
|
676
|
+
PackageJson.JSPMConfiguration;
|
package/source/partial-deep.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {ApplyDefaultOptions, BuiltIns} from './internal';
|
|
2
|
-
import type {IsNever} from './is-never';
|
|
1
|
+
import type {ApplyDefaultOptions, BuiltIns} from './internal/index.d.ts';
|
|
2
|
+
import type {IsNever} from './is-never.d.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
@see {@link PartialDeep}
|
|
@@ -18,10 +18,10 @@ export type PartialDeepOptions = {
|
|
|
18
18
|
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
19
19
|
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
20
20
|
|
|
21
|
-
@default
|
|
21
|
+
@default false
|
|
22
22
|
|
|
23
23
|
@example
|
|
24
|
-
You can
|
|
24
|
+
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
25
25
|
|
|
26
26
|
```
|
|
27
27
|
import type {PartialDeep} from 'type-fest';
|
|
@@ -30,10 +30,9 @@ export type PartialDeepOptions = {
|
|
|
30
30
|
languages: string[];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays:
|
|
33
|
+
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
34
34
|
|
|
35
|
-
partialSettings.languages = [undefined]; //
|
|
36
|
-
partialSettings.languages = []; // Ok
|
|
35
|
+
partialSettings.languages = [undefined]; // OK
|
|
37
36
|
```
|
|
38
37
|
*/
|
|
39
38
|
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
@@ -41,7 +40,7 @@ export type PartialDeepOptions = {
|
|
|
41
40
|
|
|
42
41
|
type DefaultPartialDeepOptions = {
|
|
43
42
|
recurseIntoArrays: false;
|
|
44
|
-
allowUndefinedInNonTupleArrays:
|
|
43
|
+
allowUndefinedInNonTupleArrays: false;
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
/**
|
|
@@ -55,19 +54,19 @@ Use-cases:
|
|
|
55
54
|
```
|
|
56
55
|
import type {PartialDeep} from 'type-fest';
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
let settings = {
|
|
59
58
|
textEditor: {
|
|
60
59
|
fontSize: 14,
|
|
61
60
|
fontColor: '#000000',
|
|
62
|
-
fontWeight: 400
|
|
61
|
+
fontWeight: 400,
|
|
63
62
|
},
|
|
64
63
|
autocomplete: false,
|
|
65
|
-
autosave: true
|
|
64
|
+
autosave: true,
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
const applySavedSettings = (savedSettings: PartialDeep<
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
68
|
+
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
69
|
+
);
|
|
71
70
|
|
|
72
71
|
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
73
72
|
```
|
|
@@ -77,13 +76,15 @@ By default, this does not affect elements in array and tuple types. You can chan
|
|
|
77
76
|
```
|
|
78
77
|
import type {PartialDeep} from 'type-fest';
|
|
79
78
|
|
|
80
|
-
type
|
|
81
|
-
|
|
82
|
-
}
|
|
79
|
+
type Shape = {
|
|
80
|
+
dimensions: [number, number];
|
|
81
|
+
};
|
|
83
82
|
|
|
84
|
-
const
|
|
85
|
-
|
|
83
|
+
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
84
|
+
dimensions: [], // OK
|
|
86
85
|
};
|
|
86
|
+
|
|
87
|
+
partialShape.dimensions = [15]; // OK
|
|
87
88
|
```
|
|
88
89
|
|
|
89
90
|
@see {@link PartialDeepOptions}
|
|
@@ -147,5 +148,5 @@ type PartialObjectDeep<ObjectType extends object, Options extends Required<Parti
|
|
|
147
148
|
(ObjectType extends (...arguments_: any) => unknown
|
|
148
149
|
? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType>
|
|
149
150
|
: {}) & ({
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
|
|
152
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {ApplyDefaultOptions, BuiltIns, LiteralKeyOf} from './internal';
|
|
3
|
-
import type {
|
|
1
|
+
import type {If} from './if.d.ts';
|
|
2
|
+
import type {ApplyDefaultOptions, BuiltIns, LiteralKeyOf} from './internal/index.d.ts';
|
|
3
|
+
import type {IsUnknown} from './is-unknown.d.ts';
|
|
4
|
+
import type {Merge} from './merge.d.ts';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
@see PartialOnUndefinedDeep
|
|
@@ -55,7 +56,7 @@ export type PartialOnUndefinedDeep<T, Options extends PartialOnUndefinedDeepOpti
|
|
|
55
56
|
_PartialOnUndefinedDeep<T, ApplyDefaultOptions<PartialOnUndefinedDeepOptions, DefaultPartialOnUndefinedDeepOptions, Options>>;
|
|
56
57
|
|
|
57
58
|
type _PartialOnUndefinedDeep<T, Options extends Required<PartialOnUndefinedDeepOptions>> = T extends Record<any, any> | undefined
|
|
58
|
-
? {[KeyType in keyof T as undefined extends T[KeyType] ?
|
|
59
|
+
? {[KeyType in keyof T as undefined extends T[KeyType] ? If<IsUnknown<T[KeyType]>, never, KeyType> : never]?: PartialOnUndefinedDeepValue<T[KeyType], Options>} extends infer U // Make a partial type with all value types accepting undefined (and set them optional)
|
|
59
60
|
? Merge<{[KeyType in keyof T as KeyType extends LiteralKeyOf<U> ? never : KeyType]: PartialOnUndefinedDeepValue<T[KeyType], Options>}, U> // Join all remaining keys not treated in U
|
|
60
61
|
: never // Should not happen
|
|
61
62
|
: T;
|
package/source/pascal-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {CamelCase, CamelCaseOptions, DefaultCamelCaseOptions} from './camel-case';
|
|
2
|
-
import type {ApplyDefaultOptions} from './internal';
|
|
1
|
+
import type {CamelCase, CamelCaseOptions, DefaultCamelCaseOptions} from './camel-case.d.ts';
|
|
2
|
+
import type {ApplyDefaultOptions} from './internal/index.d.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
Converts a string literal to pascal-case.
|
|
@@ -11,10 +11,11 @@ import type {PascalCase} from 'type-fest';
|
|
|
11
11
|
// Simple
|
|
12
12
|
|
|
13
13
|
const someVariable: PascalCase<'foo-bar'> = 'FooBar';
|
|
14
|
+
const preserveConsecutiveUppercase: PascalCase<'foo-BAR-baz', {preserveConsecutiveUppercase: true}> = 'FooBARBaz';
|
|
14
15
|
|
|
15
16
|
// Advanced
|
|
16
17
|
|
|
17
|
-
type
|
|
18
|
+
type PascalCasedProperties<T> = {
|
|
18
19
|
[K in keyof T as PascalCase<K>]: T[K]
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -22,12 +23,18 @@ interface RawOptions {
|
|
|
22
23
|
'dry-run': boolean;
|
|
23
24
|
'full_family_name': string;
|
|
24
25
|
foo: number;
|
|
25
|
-
|
|
26
|
+
BAR: string;
|
|
27
|
+
QUZ_QUX: number;
|
|
28
|
+
'OTHER-FIELD': boolean;
|
|
29
|
+
};
|
|
26
30
|
|
|
27
|
-
const dbResult:
|
|
31
|
+
const dbResult: PascalCasedProperties<RawOptions> = {
|
|
28
32
|
DryRun: true,
|
|
29
33
|
FullFamilyName: 'bar.js',
|
|
30
|
-
Foo: 123
|
|
34
|
+
Foo: 123,
|
|
35
|
+
Bar: 'foo',
|
|
36
|
+
QuzQux: 6,
|
|
37
|
+
OtherField: false,
|
|
31
38
|
};
|
|
32
39
|
```
|
|
33
40
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {CamelCaseOptions, DefaultCamelCaseOptions} from './camel-case';
|
|
2
|
-
import type {ApplyDefaultOptions} from './internal';
|
|
3
|
-
import type {PascalCase} from './pascal-case';
|
|
1
|
+
import type {CamelCaseOptions, DefaultCamelCaseOptions} from './camel-case.d.ts';
|
|
2
|
+
import type {ApplyDefaultOptions} from './internal/index.d.ts';
|
|
3
|
+
import type {PascalCase} from './pascal-case.d.ts';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
Convert object properties to pascal case recursively.
|
|
@@ -40,6 +40,14 @@ const result: PascalCasedPropertiesDeep<UserWithFriends> = {
|
|
|
40
40
|
},
|
|
41
41
|
],
|
|
42
42
|
};
|
|
43
|
+
|
|
44
|
+
const preserveConsecutiveUppercase: PascalCasedPropertiesDeep<{fooBAR: {fooBARBiz: [{fooBARBaz: string}]}}, {preserveConsecutiveUppercase: true}> = {
|
|
45
|
+
FooBAR: {
|
|
46
|
+
FooBARBiz: [{
|
|
47
|
+
FooBARBaz: 'string',
|
|
48
|
+
}],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
43
51
|
```
|
|
44
52
|
|
|
45
53
|
@category Change case
|