type-fest 5.0.1 → 5.1.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 +5 -0
- package/package.json +2 -1
- package/readme.md +18 -10
- package/source/all-extend.d.ts +3 -1
- package/source/all-union-fields.d.ts +2 -0
- package/source/and.d.ts +2 -0
- package/source/array-indices.d.ts +2 -0
- package/source/array-slice.d.ts +2 -0
- package/source/array-splice.d.ts +7 -4
- package/source/array-tail.d.ts +3 -1
- package/source/array-values.d.ts +2 -0
- package/source/arrayable.d.ts +2 -0
- package/source/async-return-type.d.ts +2 -0
- package/source/asyncify.d.ts +2 -0
- package/source/basic.d.ts +2 -0
- package/source/camel-case.d.ts +4 -2
- package/source/camel-cased-properties-deep.d.ts +4 -2
- package/source/camel-cased-properties.d.ts +4 -2
- package/source/characters.d.ts +2 -0
- package/source/conditional-except.d.ts +2 -0
- package/source/conditional-keys.d.ts +2 -0
- package/source/conditional-pick-deep.d.ts +2 -0
- package/source/conditional-pick.d.ts +2 -0
- package/source/conditional-simplify-deep.d.ts +2 -0
- package/source/conditional-simplify.d.ts +2 -0
- package/source/delimiter-case.d.ts +5 -3
- package/source/delimiter-cased-properties-deep.d.ts +4 -2
- package/source/delimiter-cased-properties.d.ts +4 -2
- package/source/distributed-omit.d.ts +2 -0
- package/source/distributed-pick.d.ts +2 -0
- package/source/empty-object.d.ts +2 -0
- package/source/entries.d.ts +7 -5
- package/source/entry.d.ts +10 -8
- package/source/exact.d.ts +2 -0
- package/source/except.d.ts +3 -1
- package/source/exclude-rest-element.d.ts +37 -0
- package/source/exclude-strict.d.ts +2 -0
- package/source/extends-strict.d.ts +2 -0
- package/source/extract-rest-element.d.ts +29 -0
- package/source/extract-strict.d.ts +2 -0
- package/source/find-global-type.d.ts +2 -0
- package/source/fixed-length-array.d.ts +67 -21
- package/source/get.d.ts +5 -3
- package/source/global-this.d.ts +2 -0
- package/source/globals/index.d.ts +2 -0
- package/source/globals/observable-like.d.ts +5 -0
- package/source/greater-than-or-equal.d.ts +2 -0
- package/source/greater-than.d.ts +2 -0
- package/source/has-optional-keys.d.ts +2 -0
- package/source/has-readonly-keys.d.ts +2 -0
- package/source/has-required-keys.d.ts +2 -0
- package/source/has-writable-keys.d.ts +2 -0
- package/source/if-any.d.ts +2 -0
- package/source/if-empty-object.d.ts +2 -0
- package/source/if-never.d.ts +2 -0
- package/source/if-null.d.ts +2 -0
- package/source/if-unknown.d.ts +2 -0
- package/source/if.d.ts +2 -0
- package/source/includes.d.ts +2 -0
- package/source/int-closed-range.d.ts +2 -0
- package/source/int-range.d.ts +7 -5
- package/source/internal/array.d.ts +2 -0
- package/source/internal/characters.d.ts +2 -0
- package/source/{enforce-optional.d.ts → internal/enforce-optional.d.ts} +3 -1
- package/source/internal/index.d.ts +3 -0
- package/source/internal/keys.d.ts +2 -0
- package/source/internal/numeric.d.ts +2 -0
- package/source/internal/object.d.ts +2 -0
- package/source/internal/string.d.ts +4 -2
- package/source/internal/tuple.d.ts +2 -13
- package/source/internal/type.d.ts +2 -0
- package/source/invariant-of.d.ts +2 -0
- package/source/is-any.d.ts +2 -0
- package/source/is-equal.d.ts +15 -0
- package/source/is-float.d.ts +2 -0
- package/source/is-integer.d.ts +2 -0
- package/source/is-literal.d.ts +4 -2
- package/source/is-lowercase.d.ts +2 -0
- package/source/is-never.d.ts +2 -0
- package/source/is-null.d.ts +2 -0
- package/source/is-nullable.d.ts +2 -0
- package/source/is-optional-key-of.d.ts +2 -0
- package/source/is-optional.d.ts +2 -0
- package/source/is-readonly-key-of.d.ts +2 -0
- package/source/is-required-key-of.d.ts +2 -0
- package/source/is-tuple.d.ts +2 -0
- package/source/is-undefined.d.ts +2 -0
- package/source/is-union.d.ts +2 -0
- package/source/is-unknown.d.ts +2 -0
- package/source/is-uppercase.d.ts +2 -0
- package/source/is-writable-key-of.d.ts +2 -0
- package/source/iterable-element.d.ts +2 -0
- package/source/join.d.ts +2 -0
- package/source/json-value.d.ts +3 -1
- package/source/jsonifiable.d.ts +2 -0
- package/source/jsonify.d.ts +2 -0
- package/source/kebab-case.d.ts +4 -2
- package/source/kebab-cased-properties-deep.d.ts +4 -2
- package/source/kebab-cased-properties.d.ts +4 -2
- package/source/key-as-string.d.ts +2 -0
- package/source/keys-of-union.d.ts +2 -0
- package/source/last-array-element.d.ts +3 -1
- package/source/less-than-or-equal.d.ts +2 -0
- package/source/less-than.d.ts +2 -0
- package/source/literal-to-primitive-deep.d.ts +2 -0
- package/source/literal-to-primitive.d.ts +2 -0
- package/source/literal-union.d.ts +3 -1
- package/source/merge-deep.d.ts +3 -1
- package/source/merge-exclusive.d.ts +1 -0
- package/source/merge.d.ts +2 -0
- package/source/multidimensional-array.d.ts +2 -0
- package/source/multidimensional-readonly-array.d.ts +2 -0
- package/source/non-empty-object.d.ts +2 -0
- package/source/non-empty-string.d.ts +2 -0
- package/source/non-empty-tuple.d.ts +2 -0
- package/source/numeric.d.ts +7 -5
- package/source/omit-deep.d.ts +2 -0
- package/source/omit-index-signature.d.ts +2 -0
- package/source/opaque.d.ts +2 -0
- package/source/optional-keys-of.d.ts +2 -0
- package/source/or.d.ts +2 -0
- package/source/override-properties.d.ts +2 -0
- package/source/package-json.d.ts +18 -16
- package/source/partial-deep.d.ts +20 -17
- package/source/partial-on-undefined-deep.d.ts +2 -0
- package/source/pascal-case.d.ts +5 -3
- package/source/pascal-cased-properties-deep.d.ts +4 -2
- package/source/pascal-cased-properties.d.ts +4 -2
- package/source/paths.d.ts +2 -0
- package/source/pick-deep.d.ts +8 -5
- package/source/pick-index-signature.d.ts +2 -0
- package/source/primitive.d.ts +2 -0
- package/source/promisable.d.ts +2 -0
- package/source/readonly-deep.d.ts +6 -4
- package/source/readonly-keys-of.d.ts +2 -0
- package/source/readonly-tuple.d.ts +6 -15
- package/source/remove-prefix.d.ts +4 -2
- package/source/replace.d.ts +3 -1
- package/source/require-all-or-none.d.ts +2 -0
- package/source/require-at-least-one.d.ts +2 -0
- package/source/require-exactly-one.d.ts +2 -0
- package/source/require-one-or-none.d.ts +2 -0
- package/source/required-deep.d.ts +4 -1
- package/source/required-keys-of.d.ts +2 -0
- package/source/schema.d.ts +2 -0
- package/source/screaming-snake-case.d.ts +4 -2
- package/source/set-field-type.d.ts +3 -1
- package/source/set-non-nullable-deep.d.ts +2 -0
- package/source/set-non-nullable.d.ts +2 -0
- package/source/set-optional.d.ts +2 -0
- package/source/set-parameter-type.d.ts +2 -0
- package/source/set-readonly.d.ts +2 -0
- package/source/set-required-deep.d.ts +2 -0
- package/source/set-required.d.ts +2 -0
- package/source/set-return-type.d.ts +2 -0
- package/source/shared-union-fields-deep.d.ts +2 -0
- package/source/shared-union-fields.d.ts +2 -0
- package/source/simplify-deep.d.ts +2 -0
- package/source/simplify.d.ts +2 -0
- package/source/single-key-object.d.ts +2 -0
- package/source/snake-case.d.ts +4 -2
- package/source/snake-cased-properties-deep.d.ts +4 -2
- package/source/snake-cased-properties.d.ts +4 -2
- package/source/split-on-rest-element.d.ts +106 -0
- package/source/split.d.ts +3 -1
- package/source/spread.d.ts +2 -0
- package/source/string-repeat.d.ts +2 -0
- package/source/string-slice.d.ts +2 -0
- package/source/stringified.d.ts +2 -0
- package/source/structured-cloneable.d.ts +2 -0
- package/source/subtract.d.ts +6 -3
- package/source/sum.d.ts +5 -2
- package/source/tagged-union.d.ts +2 -0
- package/source/tagged.d.ts +3 -0
- package/source/trim.d.ts +2 -0
- package/source/tsconfig-json.d.ts +54 -25
- package/source/tuple-of.d.ts +78 -0
- package/source/tuple-to-object.d.ts +2 -0
- package/source/tuple-to-union.d.ts +2 -0
- package/source/typed-array.d.ts +2 -0
- package/source/undefined-on-partial-deep.d.ts +2 -0
- package/source/union-to-intersection.d.ts +3 -1
- package/source/union-to-tuple.d.ts +2 -0
- package/source/unknown-array.d.ts +2 -0
- package/source/unknown-map.d.ts +2 -0
- package/source/unknown-record.d.ts +2 -0
- package/source/unknown-set.d.ts +2 -0
- package/source/value-of.d.ts +2 -0
- package/source/words.d.ts +4 -2
- package/source/writable-deep.d.ts +5 -4
- package/source/writable-keys-of.d.ts +2 -0
- package/source/writable.d.ts +2 -0
- package/source/xor.d.ts +83 -0
|
@@ -1,43 +1,89 @@
|
|
|
1
|
+
import type {Except} from './except.d.ts';
|
|
2
|
+
import type {TupleOf} from './tuple-of.d.ts';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
Methods to exclude.
|
|
3
6
|
*/
|
|
4
7
|
type ArrayLengthMutationKeys = 'splice' | 'push' | 'pop' | 'shift' | 'unshift';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
|
-
Create a type that represents an array of the given type and length. The
|
|
10
|
+
Create a type that represents an array of the given type and length. The `Array` prototype methods that manipulate its length are excluded from the resulting type.
|
|
11
|
+
|
|
12
|
+
The problem with the built-in tuple type is that it allows mutating methods like `push`, `pop` etc, which can cause issues, like in the following example:
|
|
13
|
+
|
|
14
|
+
@example
|
|
15
|
+
```
|
|
16
|
+
const color: [number, number, number] = [255, 128, 64];
|
|
17
|
+
|
|
18
|
+
function toHex([r, g, b]: readonly [number, number, number]) {
|
|
19
|
+
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
color.pop(); // Allowed
|
|
23
|
+
|
|
24
|
+
console.log(toHex(color)); // Compiles fine, but fails at runtime since index `2` no longer contains a `number`.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`ArrayLengthMutationKeys` solves this problem by excluding methods like `push`, `pop` etc from the resulting type.
|
|
28
|
+
|
|
29
|
+
@example
|
|
30
|
+
```
|
|
31
|
+
import type {FixedLengthArray} from 'type-fest';
|
|
32
|
+
|
|
33
|
+
const color: FixedLengthArray<number, 3> = [255, 128, 64];
|
|
8
34
|
|
|
9
|
-
|
|
35
|
+
color.pop();
|
|
36
|
+
//=> Error: Property 'pop' does not exist on type 'FixedLengthArray<number, 3>'.
|
|
37
|
+
```
|
|
10
38
|
|
|
11
39
|
Use-cases:
|
|
12
40
|
- Declaring fixed-length tuples or arrays with a large number of items.
|
|
13
|
-
- Creating a range union (for example, `0 | 1 | 2 | 3 | 4` from the keys of such a type) without having to resort to recursive types.
|
|
14
41
|
- Creating an array of coordinates with a static length, for example, length of 3 for a 3D vector.
|
|
15
42
|
|
|
16
|
-
Note: This type does not prevent out-of-bounds access. Prefer `ReadonlyTuple` unless you need mutability.
|
|
17
|
-
|
|
18
43
|
@example
|
|
19
44
|
```
|
|
20
|
-
|
|
45
|
+
let color: FixedLengthArray<number, 3> = [255, 128, 64];
|
|
21
46
|
|
|
22
|
-
|
|
47
|
+
const red = color[0];
|
|
48
|
+
//=> number
|
|
49
|
+
const green = color[1];
|
|
50
|
+
//=> number
|
|
51
|
+
const blue = color[2];
|
|
52
|
+
//=> number
|
|
23
53
|
|
|
24
|
-
const
|
|
54
|
+
const alpha = color[3];
|
|
55
|
+
//=> Error: Property '3' does not exist on type 'FixedLengthArray<number, 3>'.
|
|
25
56
|
|
|
26
|
-
|
|
27
|
-
|
|
57
|
+
// You can write to valid indices.
|
|
58
|
+
color[0] = 128;
|
|
59
|
+
color[1] = 64;
|
|
60
|
+
color[2] = 32;
|
|
28
61
|
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
// But you cannot write to out-of-bounds indices.
|
|
63
|
+
color[3] = 0.5;
|
|
64
|
+
//=> Error: Property '3' does not exist on type 'FixedLengthArray<number, 3>'.
|
|
65
|
+
|
|
66
|
+
color.push(0.5);
|
|
67
|
+
//=> Error: Property 'push' does not exist on type 'FixedLengthArray<number, 3>'.
|
|
68
|
+
|
|
69
|
+
color = [0, 128, 255, 0.5];
|
|
70
|
+
//=> Error: Type '[number, number, number, number]' is not assignable to type 'FixedLengthArray<number, 3>'. Types of property 'length' are incompatible.
|
|
71
|
+
|
|
72
|
+
color.length = 4;
|
|
73
|
+
//=> Error: Cannot assign to 'length' because it is a read-only property.
|
|
74
|
+
|
|
75
|
+
function toHex([r, g, b]: readonly [number, number, number]) {
|
|
76
|
+
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log(toHex(color)); // `FixedLengthArray<number, 3>` is assignable to `readonly [number, number, number]`.
|
|
31
80
|
```
|
|
32
81
|
|
|
33
82
|
@category Array
|
|
34
|
-
@see ReadonlyTuple
|
|
35
83
|
*/
|
|
36
|
-
export type FixedLengthArray<Element, Length extends number
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
readonly length: Length;
|
|
43
|
-
};
|
|
84
|
+
export type FixedLengthArray<Element, Length extends number> =
|
|
85
|
+
Except<TupleOf<Length, Element>, ArrayLengthMutationKeys | number | 'length'>
|
|
86
|
+
& {readonly length: Length}
|
|
87
|
+
& (number extends Length ? {[n: number]: Element} : {}); // Add `number` index signature only for non-tuple arrays.
|
|
88
|
+
|
|
89
|
+
export {};
|
package/source/get.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type {ApplyDefaultOptions, ToString} from './internal/index.d.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type {_LiteralStringUnion} from './literal-union.d.ts';
|
|
3
3
|
import type {Paths} from './paths.d.ts';
|
|
4
4
|
import type {Split} from './split.d.ts';
|
|
5
5
|
import type {KeyAsString} from './key-as-string.d.ts';
|
|
6
6
|
import type {DigitCharacter} from './characters.d.ts';
|
|
7
7
|
|
|
8
|
-
type GetOptions = {
|
|
8
|
+
export type GetOptions = {
|
|
9
9
|
/**
|
|
10
10
|
Include `undefined` in the return type when accessing properties.
|
|
11
11
|
|
|
@@ -210,7 +210,7 @@ export type Get<
|
|
|
210
210
|
BaseType,
|
|
211
211
|
Path extends
|
|
212
212
|
| readonly string[]
|
|
213
|
-
|
|
|
213
|
+
| _LiteralStringUnion<ToString<Paths<BaseType, {bracketNotation: false; maxRecursionDepth: 2}> | Paths<BaseType, {bracketNotation: true; maxRecursionDepth: 2}>>>,
|
|
214
214
|
Options extends GetOptions = {},
|
|
215
215
|
> =
|
|
216
216
|
GetWithPath<
|
|
@@ -218,3 +218,5 @@ export type Get<
|
|
|
218
218
|
Path extends string ? ToPath<Path> : Path,
|
|
219
219
|
ApplyDefaultOptions<GetOptions, DefaultGetOptions, Options>
|
|
220
220
|
>;
|
|
221
|
+
|
|
222
|
+
export {};
|
package/source/global-this.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ As well, some guidance on making an `Observable` to not include `closed` propert
|
|
|
16
16
|
|
|
17
17
|
@category Observable
|
|
18
18
|
*/
|
|
19
|
+
// eslint-disable-next-line type-fest/require-exported-types
|
|
19
20
|
export type Unsubscribable = {
|
|
20
21
|
unsubscribe(): void;
|
|
21
22
|
};
|
|
@@ -38,6 +39,7 @@ type OnComplete = () => void;
|
|
|
38
39
|
/**
|
|
39
40
|
@category Observable
|
|
40
41
|
*/
|
|
42
|
+
// eslint-disable-next-line type-fest/require-exported-types
|
|
41
43
|
export type Observer<ValueType> = {
|
|
42
44
|
next: OnNext<ValueType>;
|
|
43
45
|
error: OnError;
|
|
@@ -67,7 +69,10 @@ But `Observable` implementations have evolved to preferring case 2 and some impl
|
|
|
67
69
|
|
|
68
70
|
@category Observable
|
|
69
71
|
*/
|
|
72
|
+
// eslint-disable-next-line type-fest/require-exported-types
|
|
70
73
|
export type ObservableLike<ValueType = unknown> = {
|
|
71
74
|
subscribe(observer?: Partial<Observer<ValueType>>): Unsubscribable;
|
|
72
75
|
[Symbol.observable](): ObservableLike<ValueType>;
|
|
73
76
|
};
|
|
77
|
+
|
|
78
|
+
export {};
|
package/source/greater-than.d.ts
CHANGED
package/source/if-any.d.ts
CHANGED
package/source/if-never.d.ts
CHANGED
package/source/if-null.d.ts
CHANGED
package/source/if-unknown.d.ts
CHANGED
package/source/if.d.ts
CHANGED
package/source/includes.d.ts
CHANGED
package/source/int-range.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {TupleOf} from './tuple-of.d.ts';
|
|
2
2
|
import type {Subtract} from './subtract.d.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -44,14 +44,16 @@ type PrivateIntRange<
|
|
|
44
44
|
// The gap between each number, gap = step - 1
|
|
45
45
|
Gap extends number = Subtract<Step, 1>,
|
|
46
46
|
// The final `List` is `[...StartLengthTuple, ...[number, ...GapLengthTuple], ...[number, ...GapLengthTuple], ... ...]`, so can initialize the `List` with `[...StartLengthTuple]`
|
|
47
|
-
List extends unknown[] =
|
|
48
|
-
EndLengthTuple extends unknown[] =
|
|
47
|
+
List extends unknown[] = TupleOf<Start, never>,
|
|
48
|
+
EndLengthTuple extends unknown[] = TupleOf<End>,
|
|
49
49
|
> = Gap extends 0 ?
|
|
50
50
|
// Handle the case that without `Step`
|
|
51
51
|
List['length'] extends End // The result of "List[length] === End"
|
|
52
52
|
? Exclude<List[number], never> // All unused elements are `never`, so exclude them
|
|
53
53
|
: PrivateIntRange<Start, End, Step, Gap, [...List, List['length'] ]>
|
|
54
54
|
// Handle the case that with `Step`
|
|
55
|
-
: List extends [...(infer U), ...EndLengthTuple] // The result of "List[length] >= End", because the `...
|
|
55
|
+
: List extends [...(infer U), ...EndLengthTuple] // The result of "List[length] >= End", because the `...TupleOf<Gap, never>` maybe make `List` too long.
|
|
56
56
|
? Exclude<List[number], never>
|
|
57
|
-
: PrivateIntRange<Start, End, Step, Gap, [...List, List['length'], ...
|
|
57
|
+
: PrivateIntRange<Start, End, Step, Gap, [...List, List['length'], ...TupleOf<Gap, never>]>;
|
|
58
|
+
|
|
59
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {Simplify} from '
|
|
1
|
+
import type {Simplify} from '../simplify.d.ts';
|
|
2
2
|
|
|
3
3
|
// Returns `never` if the key is optional otherwise return the key type.
|
|
4
4
|
type RequiredFilter<Type, Key extends keyof Type> = undefined extends Type[Key]
|
|
@@ -45,3 +45,5 @@ export type EnforceOptional<ObjectType> = Simplify<{
|
|
|
45
45
|
} & {
|
|
46
46
|
[Key in keyof ObjectType as OptionalFilter<ObjectType, Key>]?: Exclude<ObjectType[Key], undefined>
|
|
47
47
|
}>;
|
|
48
|
+
|
|
49
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type {TupleOf} from '../tuple-of.d.ts';
|
|
1
2
|
import type {NegativeInfinity, PositiveInfinity} from '../numeric.d.ts';
|
|
2
3
|
import type {Trim} from '../trim.d.ts';
|
|
3
4
|
import type {Whitespace} from './characters.d.ts';
|
|
4
|
-
import type {BuildTuple} from './tuple.d.ts';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
Return a string representation of the given string or number.
|
|
@@ -171,7 +171,7 @@ PositiveNumericStringGt<'1', '500'>;
|
|
|
171
171
|
*/
|
|
172
172
|
export type PositiveNumericStringGt<A extends string, B extends string> = A extends B
|
|
173
173
|
? false
|
|
174
|
-
: [
|
|
174
|
+
: [TupleOf<StringLength<A>, 0>, TupleOf<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]]
|
|
175
175
|
? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]]
|
|
176
176
|
? 0 extends Remain['length']
|
|
177
177
|
? SameLengthPositiveNumericStringGt<A, B>
|
|
@@ -198,3 +198,5 @@ type PositiveNumericCharacterGt<A extends string, B extends string> = NumericStr
|
|
|
198
198
|
: false
|
|
199
199
|
: never
|
|
200
200
|
: never;
|
|
201
|
+
|
|
202
|
+
export {};
|
|
@@ -30,19 +30,6 @@ export type TupleLength<T extends UnknownArray> =
|
|
|
30
30
|
: T['length']
|
|
31
31
|
: never; // Should never happen
|
|
32
32
|
|
|
33
|
-
/**
|
|
34
|
-
Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
|
|
35
|
-
|
|
36
|
-
If `<Fill>` is not provided, it will default to `unknown`.
|
|
37
|
-
|
|
38
|
-
@link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
39
|
-
*/
|
|
40
|
-
export type BuildTuple<L extends number, Fill = unknown, T extends readonly unknown[] = []> = number extends L
|
|
41
|
-
? Fill[]
|
|
42
|
-
: L extends T['length']
|
|
43
|
-
? T
|
|
44
|
-
: BuildTuple<L, Fill, [...T, Fill]>;
|
|
45
|
-
|
|
46
33
|
/**
|
|
47
34
|
Returns the maximum value from a tuple of integers.
|
|
48
35
|
|
|
@@ -88,3 +75,5 @@ export type TupleMin<A extends number[], Result extends number = PositiveInfinit
|
|
|
88
75
|
? TupleMin<R, F>
|
|
89
76
|
: TupleMin<R, Result>
|
|
90
77
|
: Result;
|
|
78
|
+
|
|
79
|
+
export {};
|
package/source/invariant-of.d.ts
CHANGED
package/source/is-any.d.ts
CHANGED
package/source/is-equal.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type {IsNever} from './is-never.d.ts';
|
|
1
2
|
/**
|
|
2
3
|
Returns a boolean for whether the two given types are equal.
|
|
3
4
|
|
|
@@ -25,7 +26,21 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
25
26
|
@category Utilities
|
|
26
27
|
*/
|
|
27
28
|
export type IsEqual<A, B> =
|
|
29
|
+
[A, B] extends [infer AA, infer BB]
|
|
30
|
+
? [AA] extends [never]
|
|
31
|
+
? [BB] extends [never]
|
|
32
|
+
? true
|
|
33
|
+
: false
|
|
34
|
+
: [BB] extends [never]
|
|
35
|
+
? false
|
|
36
|
+
: _IsEqual<AA, BB>
|
|
37
|
+
: false;
|
|
38
|
+
|
|
39
|
+
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
40
|
+
type _IsEqual<A, B> =
|
|
28
41
|
(<G>() => G extends A & G | G ? 1 : 2) extends
|
|
29
42
|
(<G>() => G extends B & G | G ? 1 : 2)
|
|
30
43
|
? true
|
|
31
44
|
: false;
|
|
45
|
+
|
|
46
|
+
export {};
|
package/source/is-float.d.ts
CHANGED
package/source/is-integer.d.ts
CHANGED
package/source/is-literal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {Primitive} from './primitive.d.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type {_Numeric} from './numeric.d.ts';
|
|
3
3
|
import type {CollapseLiterals, IfNotAnyOrNever, IsNotFalse, IsPrimitive} from './internal/index.d.ts';
|
|
4
4
|
import type {IsNever} from './is-never.d.ts';
|
|
5
5
|
import type {TagContainer, UnwrapTagged} from './tagged.d.ts';
|
|
@@ -173,7 +173,7 @@ endsWith('abc123', end);
|
|
|
173
173
|
@category Type Guard
|
|
174
174
|
@category Utilities
|
|
175
175
|
*/
|
|
176
|
-
export type IsNumericLiteral<T> = LiteralChecks<T,
|
|
176
|
+
export type IsNumericLiteral<T> = LiteralChecks<T, _Numeric>;
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
Returns a boolean for whether the given type is a `true` or `false` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
@@ -310,3 +310,5 @@ export type IsLiteral<T> =
|
|
|
310
310
|
IsPrimitive<T> extends true
|
|
311
311
|
? IsNotFalse<IsLiteralUnion<T>>
|
|
312
312
|
: false;
|
|
313
|
+
|
|
314
|
+
export {};
|
package/source/is-lowercase.d.ts
CHANGED
package/source/is-never.d.ts
CHANGED
package/source/is-null.d.ts
CHANGED
package/source/is-nullable.d.ts
CHANGED
package/source/is-optional.d.ts
CHANGED
package/source/is-tuple.d.ts
CHANGED
package/source/is-undefined.d.ts
CHANGED
package/source/is-union.d.ts
CHANGED
package/source/is-unknown.d.ts
CHANGED
package/source/is-uppercase.d.ts
CHANGED
package/source/join.d.ts
CHANGED
package/source/json-value.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ This type can be useful to enforce some input to be JSON-compatible or as a supe
|
|
|
5
5
|
|
|
6
6
|
@category JSON
|
|
7
7
|
*/
|
|
8
|
-
export type JsonObject = {[Key in string]: JsonValue}
|
|
8
|
+
export type JsonObject = {[Key in string]: JsonValue};
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
Matches a JSON array.
|
|
@@ -29,3 +29,5 @@ Matches any valid JSON value.
|
|
|
29
29
|
@category JSON
|
|
30
30
|
*/
|
|
31
31
|
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
32
|
+
|
|
33
|
+
export {};
|
package/source/jsonifiable.d.ts
CHANGED