@augment-vir/core 32.1.0 → 32.2.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.
Files changed (93) hide show
  1. package/dist/augments/error/ensure-error.d.ts +1 -1
  2. package/dist/augments/json/json-compatible.d.ts +2 -1
  3. package/dist/augments/json/json-value.d.ts +46 -0
  4. package/dist/augments/json/json-value.js +1 -0
  5. package/dist/augments/json/jsonify.d.ts +41 -0
  6. package/dist/augments/json/jsonify.js +1 -0
  7. package/dist/augments/number/infinity.d.ts +22 -0
  8. package/dist/augments/number/infinity.js +1 -0
  9. package/dist/augments/object/object-keys.d.ts +1 -1
  10. package/dist/augments/object/required-keys.d.ts +5 -5
  11. package/dist/augments/type/apply-default-options.d.ts +24 -0
  12. package/dist/augments/type/apply-default-options.js +1 -0
  13. package/dist/augments/type/built-in-type.d.ts +28 -0
  14. package/dist/augments/type/built-in-type.js +1 -0
  15. package/dist/augments/type/conditional-type.d.ts +25 -0
  16. package/dist/augments/type/conditional-type.js +1 -0
  17. package/dist/augments/type/constructor-type.d.ts +51 -0
  18. package/dist/augments/type/constructor-type.js +1 -0
  19. package/dist/augments/type/distributed-omit.d.ts +13 -0
  20. package/dist/augments/type/distributed-omit.js +1 -0
  21. package/dist/augments/type/empty-object.d.ts +27 -0
  22. package/dist/augments/type/empty-object.js +1 -0
  23. package/dist/augments/type/exact.d.ts +23 -0
  24. package/dist/augments/type/exact.js +1 -0
  25. package/dist/augments/type/except.d.ts +40 -0
  26. package/dist/augments/type/except.js +1 -0
  27. package/dist/augments/type/exclude-exactly.d.ts +27 -0
  28. package/dist/augments/type/exclude-exactly.js +1 -0
  29. package/dist/augments/type/is-unknown.d.ts +22 -0
  30. package/dist/augments/type/is-unknown.js +1 -0
  31. package/dist/augments/type/keys-of-union.d.ts +14 -0
  32. package/dist/augments/type/keys-of-union.js +1 -0
  33. package/dist/augments/type/literal-union.d.ts +13 -0
  34. package/dist/augments/type/literal-union.js +1 -0
  35. package/dist/augments/type/merge.d.ts +20 -0
  36. package/dist/augments/type/merge.js +1 -0
  37. package/dist/augments/type/non-empty-string.d.ts +9 -0
  38. package/dist/augments/type/non-empty-string.js +1 -0
  39. package/dist/augments/type/omit-deep.d.ts +373 -0
  40. package/dist/augments/type/omit-deep.js +1 -0
  41. package/dist/augments/type/omit-index-signature.d.ts +28 -0
  42. package/dist/augments/type/omit-index-signature.js +2 -0
  43. package/dist/augments/type/optional-keys-of.d.ts +25 -0
  44. package/dist/augments/type/optional-keys-of.js +1 -0
  45. package/dist/augments/type/package-json.d.ts +177 -0
  46. package/dist/augments/type/package-json.js +1 -0
  47. package/dist/augments/type/partial-deep.d.ts +52 -0
  48. package/dist/augments/type/partial-deep.js +1 -0
  49. package/dist/augments/type/primitive-type.d.ts +11 -0
  50. package/dist/augments/type/primitive-type.js +1 -0
  51. package/dist/augments/type/promisable.d.ts +11 -0
  52. package/dist/augments/type/promisable.js +1 -0
  53. package/dist/augments/type/readonly-deep.d.ts +30 -0
  54. package/dist/augments/type/readonly-deep.js +1 -0
  55. package/dist/augments/type/readonly-keys-of.d.ts +20 -0
  56. package/dist/augments/type/readonly-keys-of.js +1 -0
  57. package/dist/augments/type/require-keys.d.ts +47 -0
  58. package/dist/augments/type/require-keys.js +1 -0
  59. package/dist/augments/type/require-one-or-none.d.ts +18 -0
  60. package/dist/augments/type/require-one-or-none.js +1 -0
  61. package/dist/augments/type/set-optional.d.ts +19 -0
  62. package/dist/augments/type/set-optional.js +1 -0
  63. package/dist/augments/type/set-required.d.ts +47 -0
  64. package/dist/augments/type/set-required.js +1 -0
  65. package/dist/augments/type/simplify.d.ts +14 -0
  66. package/dist/augments/type/simplify.js +1 -0
  67. package/dist/augments/type/subtract.d.ts +177 -0
  68. package/dist/augments/type/subtract.js +1 -0
  69. package/dist/augments/type/tagged.d.ts +30 -0
  70. package/dist/augments/type/tagged.js +1 -0
  71. package/dist/augments/type/type-checks.d.ts +33 -0
  72. package/dist/augments/type/type-checks.js +8 -0
  73. package/dist/augments/type/typed-array.d.ts +13 -0
  74. package/dist/augments/type/typed-array.js +1 -0
  75. package/dist/augments/type/undefined-to-optional.d.ts +27 -0
  76. package/dist/augments/type/undefined-to-optional.js +1 -0
  77. package/dist/augments/type/union-member.d.ts +14 -0
  78. package/dist/augments/type/union-member.js +1 -0
  79. package/dist/augments/type/union-to-intersection.d.ts +11 -0
  80. package/dist/augments/type/union-to-intersection.js +1 -0
  81. package/dist/augments/type/union-to-tuple.d.ts +21 -0
  82. package/dist/augments/type/union-to-tuple.js +1 -0
  83. package/dist/augments/type/unknown-array.d.ts +11 -0
  84. package/dist/augments/type/unknown-array.js +1 -0
  85. package/dist/augments/type/writable-deep.d.ts +32 -0
  86. package/dist/augments/type/writable-deep.js +1 -0
  87. package/dist/augments/type/writable-keys-of.d.ts +12 -0
  88. package/dist/augments/type/writable-keys-of.js +1 -0
  89. package/dist/augments/type/writable.d.ts +29 -0
  90. package/dist/augments/type/writable.js +1 -0
  91. package/dist/index.d.ts +43 -0
  92. package/dist/index.js +43 -0
  93. package/package.json +2 -3
@@ -1,4 +1,4 @@
1
- import { type Constructor } from 'type-fest';
1
+ import { type Constructor } from '../type/constructor-type.js';
2
2
  /**
3
3
  * Either returns the input if it's already an Error instance or converts it into an Error instance.
4
4
  *
@@ -1,4 +1,5 @@
1
- import { type Jsonify, type Primitive } from 'type-fest';
1
+ import { type Primitive } from '../type/primitive-type.js';
2
+ import { type Jsonify } from './jsonify.js';
2
3
  /**
3
4
  * These are similar in purpose, name, and structure to type-fest's JsonValue types but these are
4
5
  * more permissive. The goal here is to allow any types that do not get serialized into just empty
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Matches a JSON object.
3
+ *
4
+ * Copied from the `JsonObject` type in the `type-fest` package so that this package's public types
5
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
6
+ *
7
+ * @category JSON
8
+ * @category Package : @augment-vir/common
9
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
+ */
11
+ export type JsonObject = {
12
+ [Key in string]: JsonValue;
13
+ };
14
+ /**
15
+ * Matches a JSON array.
16
+ *
17
+ * Copied from the `JsonArray` type in the `type-fest` package so that this package's public types
18
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
19
+ *
20
+ * @category JSON
21
+ * @category Package : @augment-vir/common
22
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
23
+ */
24
+ export type JsonArray = JsonValue[] | readonly JsonValue[];
25
+ /**
26
+ * Matches any valid JSON primitive value.
27
+ *
28
+ * Copied from the `JsonPrimitive` type in the `type-fest` package so that this package's public
29
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
30
+ *
31
+ * @category JSON
32
+ * @category Package : @augment-vir/common
33
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
34
+ */
35
+ export type JsonPrimitive = string | number | boolean | null;
36
+ /**
37
+ * Matches any valid JSON value.
38
+ *
39
+ * Copied from the `JsonValue` type in the `type-fest` package so that this package's public types
40
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
41
+ *
42
+ * @category JSON
43
+ * @category Package : @augment-vir/common
44
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
45
+ */
46
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import { type NegativeInfinity, type PositiveInfinity } from '../number/infinity.js';
2
+ import { type EmptyObject } from '../type/empty-object.js';
3
+ import { type IsUnknown } from '../type/is-unknown.js';
4
+ import { type IsAny, type IsNever } from '../type/type-checks.js';
5
+ import { type TypedArray } from '../type/typed-array.js';
6
+ import { type UndefinedToOptional } from '../type/undefined-to-optional.js';
7
+ import { type UnknownArray } from '../type/unknown-array.js';
8
+ import { type JsonPrimitive, type JsonValue } from './json-value.js';
9
+ type NotJsonable = ((...arguments_: any[]) => any) | undefined | symbol;
10
+ type NeverToNull<T> = IsNever<T> extends true ? null : T;
11
+ type UndefinedToNull<T> = T extends undefined ? null : T;
12
+ type JsonifyList<T extends UnknownArray> = T extends readonly [] ? [] : T extends readonly [
13
+ infer F,
14
+ ...infer R
15
+ ] ? [
16
+ F,
17
+ ...R
18
+ ] extends T ? [
19
+ NeverToNull<Jsonify<F>>,
20
+ ...JsonifyList<R>
21
+ ] : [NeverToNull<Jsonify<F>>] : IsUnknown<T[number]> extends true ? JsonValue[] : Array<T[number] extends NotJsonable ? null : Jsonify<UndefinedToNull<T[number]>>>;
22
+ type FilterJsonableKeys<T extends object> = {
23
+ [Key in keyof T]: T[Key] extends NotJsonable ? never : Key;
24
+ }[keyof T];
25
+ type JsonifyObject<T extends object> = {
26
+ [Key in keyof Pick<T, FilterJsonableKeys<T>>]: Jsonify<T[Key]>;
27
+ };
28
+ /**
29
+ * Transform a type to one that is assignable to the `JsonValue` type.
30
+ *
31
+ * Copied from the `Jsonify` type in the `type-fest` package so that this package's public types do
32
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
33
+ *
34
+ * @category JSON
35
+ * @category Package : @augment-vir/common
36
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
37
+ */
38
+ export type Jsonify<T> = IsAny<T> extends true ? any : T extends PositiveInfinity | NegativeInfinity ? null : T extends JsonPrimitive ? T : T extends {
39
+ toJSON(): infer J;
40
+ } ? (() => J) extends () => JsonValue ? J : Jsonify<J> : T extends Number ? number : T extends String ? string : T extends Boolean ? boolean : T extends Map<any, any> | Set<any> ? EmptyObject : T extends TypedArray ? Record<string, number> : T extends NotJsonable ? never : T extends UnknownArray ? JsonifyList<T> : T extends object ? JsonifyObject<UndefinedToOptional<T>> : IsUnknown<T> extends true ? JsonValue : never;
41
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Matches the hidden `Infinity` type.
3
+ *
4
+ * Copied from the `PositiveInfinity` type in the `type-fest` package so that this package's public
5
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
6
+ *
7
+ * @category Number
8
+ * @category Package : @augment-vir/common
9
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
+ */
11
+ export type PositiveInfinity = 1e999;
12
+ /**
13
+ * Matches the hidden `-Infinity` type.
14
+ *
15
+ * Copied from the `NegativeInfinity` type in the `type-fest` package so that this package's public
16
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
17
+ *
18
+ * @category Number
19
+ * @category Package : @augment-vir/common
20
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
21
+ */
22
+ export type NegativeInfinity = -1e999;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { type IsNever } from 'type-fest';
1
+ import { type IsNever } from '../type/type-checks.js';
2
2
  /**
3
3
  * Gets all keys of an object. This is similar to
4
4
  * [`Object.keys`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)
@@ -1,5 +1,5 @@
1
- import { type Except, type Simplify } from 'type-fest';
2
- export type { SetRequired } from 'type-fest';
1
+ import { type Except } from '../type/except.js';
2
+ import { type Simplify } from '../type/simplify.js';
3
3
  /**
4
4
  * Same as the Required<> built-in type helper but this requires that each property be present and
5
5
  * be not null.
@@ -50,9 +50,9 @@ export type SetOptionalWithUndefined<OriginalObjectGeneric, OptionalKeysGeneric
50
50
  * @category Package : @augment-vir/common
51
51
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
52
52
  */
53
- export type RequiredKeysOf<BaseType> = Exclude<{
54
- [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never;
55
- }[keyof BaseType], undefined>;
53
+ export type RequiredKeysOf<BaseType> = keyof {
54
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? Key : never]: never;
55
+ } & keyof BaseType;
56
56
  /**
57
57
  * Requires every part of an object, even the indexed keys. This is needed because
58
58
  * `Required<Partial<T>>` doesn't fully remove `| undefined` from indexed keys when the
@@ -0,0 +1,24 @@
1
+ import { type RequiredKeysOf } from '../object/required-keys.js';
2
+ import { type If } from './conditional-type.js';
3
+ import { type Merge } from './merge.js';
4
+ import { type OptionalKeysOf } from './optional-keys-of.js';
5
+ import { type Simplify } from './simplify.js';
6
+ import { type IsAny, type IsNever } from './type-checks.js';
7
+ /**
8
+ * Fill in the unspecified properties of an options object with their defaults.
9
+ *
10
+ * Copied from the `ApplyDefaultOptions` type in the `type-fest` package so that this package's
11
+ * public types do not depend on `type-fest` (see the note in `type-checks.ts`).
12
+ *
13
+ * @category Object
14
+ * @category Package : @augment-vir/common
15
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
16
+ */
17
+ export type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, {
18
+ [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key];
19
+ }> &
20
+ /**
21
+ * `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is
22
+ * always assignable to `Required<SomeOption>`.
23
+ */
24
+ Required<Options>>>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import { type Primitive } from './primitive-type.js';
2
+ /**
3
+ * Matches any primitive, `void`, `Date`, or `RegExp` value.
4
+ *
5
+ * Copied from the internal `BuiltIns` type in the `type-fest` package so that this package's public
6
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
7
+ *
8
+ * @category Type
9
+ * @category Package : @augment-vir/common
10
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
11
+ */
12
+ export type BuiltIns = Primitive | void | Date | RegExp;
13
+ /**
14
+ * Tests if the given function has multiple call signatures. Needed to handle the case of a single
15
+ * call signature with properties, as multiple call signatures cannot currently be supported due to
16
+ * a TypeScript limitation.
17
+ *
18
+ * Copied from the internal `HasMultipleCallSignatures` type in the `type-fest` package so that this
19
+ * package's public types do not depend on `type-fest` (see the note in `type-checks.ts`).
20
+ *
21
+ * @category Type
22
+ * @category Package : @augment-vir/common
23
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
24
+ */
25
+ export type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
26
+ (...arguments_: infer A): unknown;
27
+ (...arguments_: infer B): unknown;
28
+ } ? B extends A ? A extends B ? false : true : true : false;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { type IsAny, type IsNever } from './type-checks.js';
2
+ /**
3
+ * An if-else-like type that resolves depending on whether the given `boolean` type is `true` or
4
+ * `false`. Returns the else branch when the given type is `never`.
5
+ *
6
+ * Copied from the `If` type in the `type-fest` package so that this package's public types do not
7
+ * depend on `type-fest` (see the note in `type-checks.ts`).
8
+ *
9
+ * @category Type
10
+ * @category Package : @augment-vir/common
11
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
12
+ */
13
+ export type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
14
+ /**
15
+ * Resolves to `IfNotAnyOrNeverBranch` unless the given type is `any` or `never`, in which case the
16
+ * respective `IfAny` or `IfNever` branch is used.
17
+ *
18
+ * Copied from the `IfNotAnyOrNever` type in the `type-fest` package so that this package's public
19
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
20
+ *
21
+ * @category Type
22
+ * @category Package : @augment-vir/common
23
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
24
+ */
25
+ export type IfNotAnyOrNever<Type, IfNotAnyOrNeverBranch, IfAny = any, IfNever = never> = If<IsAny<Type>, IfAny, If<IsNever<Type>, IfNever, IfNotAnyOrNeverBranch>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Matches a class constructor.
3
+ *
4
+ * Copied from the `Constructor` type in the `type-fest` package so that this package's public types
5
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
6
+ *
7
+ * @category Function
8
+ * @category Package : @augment-vir/common
9
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
+ */
11
+ export type Constructor<T, Arguments extends unknown[] = any[]> = new (...constructorArguments: Arguments) => T;
12
+ /**
13
+ * Matches a class constructor with an abstract signature.
14
+ *
15
+ * Copied from the `AbstractConstructor` type in the `type-fest` package so that this package's
16
+ * public types do not depend on `type-fest` (see the note in `type-checks.ts`).
17
+ *
18
+ * @category Function
19
+ * @category Package : @augment-vir/common
20
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
21
+ */
22
+ export type AbstractConstructor<T, Arguments extends unknown[] = any[]> = abstract new (...constructorArguments: Arguments) => T;
23
+ /**
24
+ * Matches a
25
+ * [`class`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/class).
26
+ *
27
+ * Copied from the `Class` type in the `type-fest` package so that this package's public types do
28
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
29
+ *
30
+ * @category Function
31
+ * @category Package : @augment-vir/common
32
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
33
+ */
34
+ export type Class<T, Arguments extends unknown[] = any[]> = {
35
+ prototype: Pick<T, keyof T>;
36
+ new (...constructorArguments: Arguments): T;
37
+ };
38
+ /**
39
+ * Matches an [`abstract
40
+ * class`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes#abstract_classes).
41
+ *
42
+ * Copied from the `AbstractClass` type in the `type-fest` package so that this package's public
43
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
44
+ *
45
+ * @category Function
46
+ * @category Package : @augment-vir/common
47
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
48
+ */
49
+ export type AbstractClass<T, Arguments extends unknown[] = any[]> = AbstractConstructor<T, Arguments> & {
50
+ prototype: Pick<T, keyof T>;
51
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type KeysOfUnion } from './keys-of-union.js';
2
+ /**
3
+ * Omits keys from a type, distributing the operation over a union. Unlike the built-in `Omit`, this
4
+ * retains member-specific properties of each union member.
5
+ *
6
+ * Copied from the `DistributedOmit` type in the `type-fest` package so that this package's public
7
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
8
+ *
9
+ * @category Object
10
+ * @category Package : @augment-vir/common
11
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
12
+ */
13
+ export type DistributedOmit<ObjectType, KeyType extends KeysOfUnion<ObjectType>> = ObjectType extends unknown ? Omit<ObjectType, KeyType> : never;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ declare const emptyObjectSymbol: unique symbol;
2
+ /**
3
+ * Represents a strictly empty plain object, the `{}` value.
4
+ *
5
+ * Copied from the `EmptyObject` type in the `type-fest` package so that this package's public types
6
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
7
+ *
8
+ * @category Object
9
+ * @category Package : @augment-vir/common
10
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
11
+ */
12
+ export type EmptyObject = {
13
+ [emptyObjectSymbol]?: never;
14
+ };
15
+ /**
16
+ * Returns a boolean for whether the type is strictly equal to an empty plain object, the `{}`
17
+ * value.
18
+ *
19
+ * Copied from the `IsEmptyObject` type in the `type-fest` package so that this package's public
20
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
21
+ *
22
+ * @category Object
23
+ * @category Package : @augment-vir/common
24
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
25
+ */
26
+ export type IsEmptyObject<T> = T extends EmptyObject ? true : false;
27
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { type IsUnknown } from './is-unknown.js';
2
+ import { type KeysOfUnion } from './keys-of-union.js';
3
+ import { type Primitive } from './primitive-type.js';
4
+ import { type IsEqual } from './type-checks.js';
5
+ type ToString<T> = T extends string | number ? `${T}` : never;
6
+ type ArrayElementOf<T> = T extends readonly (infer ElementType)[] ? ElementType : never;
7
+ type ObjectValue<T, K> = K extends keyof T ? T[K] : ToString<K> extends keyof T ? T[ToString<K>] : K extends `${infer NumberK extends number}` ? NumberK extends keyof T ? T[NumberK] : never : never;
8
+ type ExactObject<ParameterType, InputType> = {
9
+ [Key in keyof ParameterType]: Exact<ParameterType[Key], ObjectValue<InputType, Key>>;
10
+ } & Record<Exclude<keyof InputType, KeysOfUnion<ParameterType>>, never>;
11
+ /**
12
+ * Create a type that does not allow extra properties, meaning it only allows properties that are
13
+ * explicitly declared.
14
+ *
15
+ * Copied from the `Exact` type in the `type-fest` package so that this package's public types do
16
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
17
+ *
18
+ * @category Object
19
+ * @category Package : @augment-vir/common
20
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
21
+ */
22
+ export type Exact<ParameterType, InputType> = IsEqual<ParameterType, InputType> extends true ? ParameterType : ParameterType extends Primitive ? ParameterType : IsUnknown<ParameterType> extends true ? unknown : ParameterType extends Function ? ParameterType : ParameterType extends unknown[] ? Array<Exact<ArrayElementOf<ParameterType>, ArrayElementOf<InputType>>> : ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElementOf<ParameterType>, ArrayElementOf<InputType>>> : ExactObject<ParameterType, InputType>;
23
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { type ApplyDefaultOptions } from './apply-default-options.js';
2
+ import { type IsEqual } from './type-checks.js';
3
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : KeyType extends ExcludeType ? never : KeyType;
4
+ /**
5
+ * Options for {@link Except}.
6
+ *
7
+ * Copied from the `ExceptOptions` type in the `type-fest` package so that this package's public
8
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
9
+ *
10
+ * @category Object
11
+ * @category Package : @augment-vir/common
12
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
13
+ */
14
+ export type ExceptOptions = {
15
+ /**
16
+ * Disallow assigning non-specified properties.
17
+ *
18
+ * @default false
19
+ */
20
+ requireExactProps?: boolean;
21
+ };
22
+ type DefaultExceptOptions = {
23
+ requireExactProps: false;
24
+ };
25
+ type ExceptHelper<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = {
26
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
27
+ } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
28
+ /**
29
+ * Create a type from an object type without certain keys. This is a stricter version of the
30
+ * built-in `Omit` type: it restricts the omitted keys to keys present on the given type.
31
+ *
32
+ * Copied from the `Except` type in the `type-fest` package so that this package's public types do
33
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
34
+ *
35
+ * @category Object
36
+ * @category Package : @augment-vir/common
37
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
38
+ */
39
+ export type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = ExceptHelper<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
40
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { type If, type IfNotAnyOrNever } from './conditional-type.js';
2
+ import { type IsAny, type IsEqual, type IsNever } from './type-checks.js';
3
+ type ExcludeExactlyMember<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unknown ? [
4
+ Delete extends unknown ? If<IsEqual<Union, Delete>, true, never> : never
5
+ ] extends [never] ? Union : never : never,
6
+ /**
7
+ * When `Delete` is `any` or `never`, return `Union`, because `Union` cannot be `any` or `never`
8
+ * here.
9
+ */
10
+ Union, Union>;
11
+ /**
12
+ * Exclude exactly the given type from a union, instead of excluding every member assignable to it
13
+ * the way the built-in `Exclude` does.
14
+ *
15
+ * Copied from the `ExcludeExactly` type in the `type-fest` package so that this package's public
16
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
17
+ *
18
+ * @category Type
19
+ * @category Package : @augment-vir/common
20
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
21
+ */
22
+ export type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, ExcludeExactlyMember<Union, Delete>,
23
+ /** When `Union` is `any`: if `Delete` is `any` return `never`, otherwise return `Union`. */
24
+ If<IsAny<Delete>, never, Union>,
25
+ /** When `Union` is `never`: if `Delete` is `never` return `never`, otherwise return `Union`. */
26
+ If<IsNever<Delete>, never, Union>>;
27
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Returns a boolean for whether the given type is `null`.
3
+ *
4
+ * Copied from the `IsNull` type in the `type-fest` package so that this package's public types do
5
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
6
+ *
7
+ * @category Type
8
+ * @category Package : @augment-vir/common
9
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
+ */
11
+ export type IsNull<T> = [T] extends [null] ? true : false;
12
+ /**
13
+ * Returns a boolean for whether the given type is `unknown`.
14
+ *
15
+ * Copied from the `IsUnknown` type in the `type-fest` package so that this package's public types
16
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
17
+ *
18
+ * @category Type
19
+ * @category Package : @augment-vir/common
20
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
21
+ */
22
+ export type IsUnknown<T> = unknown extends T ? (IsNull<T> extends false ? true : false) : false;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type UnionToIntersection } from './union-to-intersection.js';
2
+ /**
3
+ * Create a union of all keys from a given type, even those exclusive to specific union members.
4
+ * Unlike the native `keyof` keyword, which returns keys present in _all_ union members, this type
5
+ * returns keys from _any_ member.
6
+ *
7
+ * Copied from the `KeysOfUnion` type in the `type-fest` package so that this package's public types
8
+ * do not depend on `type-fest` (see the note in `type-checks.ts`).
9
+ *
10
+ * @category Object
11
+ * @category Package : @augment-vir/common
12
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
13
+ */
14
+ export type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type Primitive } from './primitive-type.js';
2
+ /**
3
+ * Create a union type by combining primitive types and literal types without sacrificing
4
+ * auto-completion in IDEs for the literal type part of the union.
5
+ *
6
+ * Copied from the `LiteralUnion` type in the `type-fest` package so that this package's public
7
+ * types do not depend on `type-fest` (see the note in `type-checks.ts`).
8
+ *
9
+ * @category Type
10
+ * @category Package : @augment-vir/common
11
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
12
+ */
13
+ export type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type If } from './conditional-type.js';
2
+ import { type OmitIndexSignature, type PickIndexSignature } from './omit-index-signature.js';
3
+ import { type Simplify } from './simplify.js';
4
+ import { type IsEqual } from './type-checks.js';
5
+ type SimpleMerge<Destination, Source> = Simplify<{
6
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
7
+ } & Source>;
8
+ type MergeNonEqual<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
9
+ /**
10
+ * Merge two types into a new type. Keys of the second type override keys of the first type.
11
+ *
12
+ * Copied from the `Merge` type in the `type-fest` package so that this package's public types do
13
+ * not depend on `type-fest` (see the note in `type-checks.ts`).
14
+ *
15
+ * @category Object
16
+ * @category Package : @augment-vir/common
17
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
18
+ */
19
+ export type Merge<Destination, Source> = Destination extends unknown ? Source extends unknown ? If<IsEqual<Destination, Source>, Destination, MergeNonEqual<Destination, Source>> : never : never;
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Blocks empty string literal types. Use this to constrain a string type parameter so that the
3
+ * empty string is rejected.
4
+ *
5
+ * @category Type
6
+ * @category Package : @augment-vir/common
7
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
8
+ */
9
+ export type NonEmptyString<T> = T extends '' ? never : T;
@@ -0,0 +1 @@
1
+ export {};