type-fest 3.13.1 → 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/jsonify.d.ts +15 -5
- package/source/last-array-element.d.ts +7 -7
- package/source/package-json.d.ts +1 -1
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/jsonify.d.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type {JsonPrimitive, JsonValue} from './basic';
|
|
2
2
|
import type {EmptyObject} from './empty-object';
|
|
3
3
|
import type {UndefinedToOptional} from './internal';
|
|
4
|
+
import type {IsAny} from './is-any';
|
|
5
|
+
import type {IsNever} from './is-never';
|
|
4
6
|
import type {NegativeInfinity, PositiveInfinity} from './numeric';
|
|
5
7
|
import type {TypedArray} from './typed-array';
|
|
6
|
-
import type {IsAny} from './is-any';
|
|
7
8
|
|
|
8
9
|
// Note: The return value has to be `any` and not `unknown` so it can match `void`.
|
|
9
10
|
type NotJsonable = ((...arguments_: any[]) => any) | undefined | symbol;
|
|
10
11
|
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
type FilterNonNever<T extends unknown[]> = T extends [infer F, ...infer R]
|
|
13
|
+
? IsNever<F> extends true
|
|
14
|
+
? FilterNonNever<R>
|
|
15
|
+
: [F, ...FilterNonNever<R>]
|
|
16
|
+
: IsNever<T[number]> extends true
|
|
17
|
+
? []
|
|
18
|
+
: T;
|
|
19
|
+
|
|
20
|
+
// Handles tuples and arrays
|
|
21
|
+
type JsonifyList<T extends unknown[]> = T extends [infer F, ...infer R]
|
|
22
|
+
? FilterNonNever<[Jsonify<F>, ...JsonifyList<R>]>
|
|
23
|
+
: Array<Jsonify<T[number]>>;
|
|
14
24
|
|
|
15
25
|
type FilterJsonableKeys<T extends object> = {
|
|
16
26
|
[Key in keyof T]: T[Key] extends NotJsonable ? never : Key;
|
|
@@ -107,7 +117,7 @@ export type Jsonify<T> = IsAny<T> extends true
|
|
|
107
117
|
: T extends []
|
|
108
118
|
? []
|
|
109
119
|
: T extends [unknown, ...unknown[]]
|
|
110
|
-
?
|
|
120
|
+
? JsonifyList<T>
|
|
111
121
|
: T extends ReadonlyArray<infer U>
|
|
112
122
|
? Array<U extends NotJsonable ? null : Jsonify<U>>
|
|
113
123
|
: T extends object
|
|
@@ -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
|
/**
|