@jakubmazanec/ts-utils 2.1.0-265acad → 2.1.0-2d1145f
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/dist/types/DeepPartial.d.ts +5 -5
- package/dist/types/DeepPartial.js.map +1 -1
- package/dist/types/DeepReadonly.d.ts +3 -3
- package/dist/types/DeepReadonly.js.map +1 -1
- package/dist/types/UnionToIntersection.d.ts +1 -1
- package/dist/types/UnionToIntersection.js.map +1 -1
- package/dist/types/Writable.d.ts +1 -1
- package/dist/types/Writable.js +1 -1
- package/dist/types/Writable.js.map +1 -1
- package/dist/utils/assert.d.ts +1 -1
- package/dist/utils/assert.js +1 -1
- package/dist/utils/assert.js.map +1 -1
- package/package.json +1 -1
- package/src/types/DeepPartial.ts +5 -5
- package/src/types/DeepReadonly.ts +3 -3
- package/src/types/UnionToIntersection.ts +1 -1
- package/src/types/Writable.ts +1 -1
- package/src/utils/assert.ts +1 -1
|
@@ -32,27 +32,27 @@ import type { Primitive } from './Primitive.js';
|
|
|
32
32
|
*/
|
|
33
33
|
export type DeepPartial<T> = T extends Date | Primitive | RegExp ? T : T extends Map<infer KeyType, infer ValueType> ? DeepPartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? DeepPartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? DeepPartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? DeepPartialReadonlySet<ItemType> : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends Array<infer I> ? I[] extends T ? Array<DeepPartial<I | undefined>> : DeepPartialObject<T> : DeepPartialObject<T> : unknown;
|
|
34
34
|
/**
|
|
35
|
-
* Helper type for {@
|
|
35
|
+
* Helper type for {@link DeepPartial}.
|
|
36
36
|
*/
|
|
37
37
|
interface DeepPartialMap<KeyType, ValueType> extends Map<DeepPartial<KeyType>, DeepPartial<ValueType>> {
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Helper type for {@
|
|
40
|
+
* Helper type for {@link DeepPartial}.
|
|
41
41
|
*/
|
|
42
42
|
interface DeepPartialSet<T> extends Set<DeepPartial<T>> {
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Helper type for {@
|
|
45
|
+
* Helper type for {@link DeepPartial}.
|
|
46
46
|
*/
|
|
47
47
|
interface DeepPartialReadonlyMap<KeyType, ValueType> extends ReadonlyMap<DeepPartial<KeyType>, DeepPartial<ValueType>> {
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Helper type for {@
|
|
50
|
+
* Helper type for {@link DeepPartial}.
|
|
51
51
|
*/
|
|
52
52
|
interface DeepPartialReadonlySet<T> extends ReadonlySet<DeepPartial<T>> {
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* Helper type for {@
|
|
55
|
+
* Helper type for {@link DeepPartial}.
|
|
56
56
|
*/
|
|
57
57
|
type DeepPartialObject<ObjectType extends object> = {
|
|
58
58
|
[KeyType in keyof ObjectType]?: DeepPartial<ObjectType[KeyType]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/DeepPartial.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-interface -- needed */\n\nimport type {Primitive} from './Primitive.js';\n\n/**\n * Same as built-in `Partial`, but works recursively. Useful when 1) you have a config object to which you need to merge another object, which would be a deep partial of a default object, or 2) you need to test or mock complex object, but most of its keys would be redundant for this purpose.\n *\n * ```TypeScript\n * import { DeepPartial } from '@ori/ts-utils';\n * import { UiSettings } from './UiSettings';\n *\n * let settings: UiSettings = {\n * lineNumbers: true,\n * scrollbar: {\n * useShadows: false,\n * vertical: 'visible',\n * horizontal: 'auto',\n * },\n * minimap: {\n * enabled: false,\n * },\n * folding: {\n * enabled: true,\n * },\n * };\n *\n * function updateSettings(newSettings: DeepPartial<UiSettings>) {\n * return { ...settings, ...newSettings };\n * }\n *\n * settings = updateSettings({ minimap: { enabled: true } });\n * ```\n *\n * @typeParam T Base for the new type\n */\nexport type DeepPartial<T> = T extends Date | Primitive | RegExp\n ? T\n : T extends Map<infer KeyType, infer ValueType>\n ? DeepPartialMap<KeyType, ValueType>\n : T extends Set<infer ItemType>\n ? DeepPartialSet<ItemType>\n : T extends ReadonlyMap<infer KeyType, infer ValueType>\n ? DeepPartialReadonlyMap<KeyType, ValueType>\n : T extends ReadonlySet<infer ItemType>\n ? DeepPartialReadonlySet<ItemType>\n : T extends (...args: any[]) => unknown\n ? T | undefined\n : T extends object\n ? T extends Array<infer I> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156\n ? I[] extends T // Test for arrays (non-tuples) specifically\n ? Array<DeepPartial<I | undefined>> // Recreate relevant array type to prevent eager evaluation of circular reference\n : DeepPartialObject<T> // Tuples behave properly\n : DeepPartialObject<T>\n : unknown;\n\n/**\n * Helper type for {@
|
|
1
|
+
{"version":3,"sources":["../../src/types/DeepPartial.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-interface -- needed */\n\nimport type {Primitive} from './Primitive.js';\n\n/**\n * Same as built-in `Partial`, but works recursively. Useful when 1) you have a config object to which you need to merge another object, which would be a deep partial of a default object, or 2) you need to test or mock complex object, but most of its keys would be redundant for this purpose.\n *\n * ```TypeScript\n * import { DeepPartial } from '@ori/ts-utils';\n * import { UiSettings } from './UiSettings';\n *\n * let settings: UiSettings = {\n * lineNumbers: true,\n * scrollbar: {\n * useShadows: false,\n * vertical: 'visible',\n * horizontal: 'auto',\n * },\n * minimap: {\n * enabled: false,\n * },\n * folding: {\n * enabled: true,\n * },\n * };\n *\n * function updateSettings(newSettings: DeepPartial<UiSettings>) {\n * return { ...settings, ...newSettings };\n * }\n *\n * settings = updateSettings({ minimap: { enabled: true } });\n * ```\n *\n * @typeParam T Base for the new type\n */\nexport type DeepPartial<T> = T extends Date | Primitive | RegExp\n ? T\n : T extends Map<infer KeyType, infer ValueType>\n ? DeepPartialMap<KeyType, ValueType>\n : T extends Set<infer ItemType>\n ? DeepPartialSet<ItemType>\n : T extends ReadonlyMap<infer KeyType, infer ValueType>\n ? DeepPartialReadonlyMap<KeyType, ValueType>\n : T extends ReadonlySet<infer ItemType>\n ? DeepPartialReadonlySet<ItemType>\n : T extends (...args: any[]) => unknown\n ? T | undefined\n : T extends object\n ? T extends Array<infer I> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156\n ? I[] extends T // Test for arrays (non-tuples) specifically\n ? Array<DeepPartial<I | undefined>> // Recreate relevant array type to prevent eager evaluation of circular reference\n : DeepPartialObject<T> // Tuples behave properly\n : DeepPartialObject<T>\n : unknown;\n\n/**\n * Helper type for {@link DeepPartial}.\n */\ninterface DeepPartialMap<KeyType, ValueType>\n extends Map<DeepPartial<KeyType>, DeepPartial<ValueType>> {}\n\n/**\n * Helper type for {@link DeepPartial}.\n */\ninterface DeepPartialSet<T> extends Set<DeepPartial<T>> {}\n\n/**\n * Helper type for {@link DeepPartial}.\n */\ninterface DeepPartialReadonlyMap<KeyType, ValueType>\n extends ReadonlyMap<DeepPartial<KeyType>, DeepPartial<ValueType>> {}\n\n/**\n * Helper type for {@link DeepPartial}.\n */\ninterface DeepPartialReadonlySet<T> extends ReadonlySet<DeepPartial<T>> {}\n\n/**\n * Helper type for {@link DeepPartial}.\n */\ntype DeepPartialObject<ObjectType extends object> = {\n [KeyType in keyof ObjectType]?: DeepPartial<ObjectType[KeyType]>;\n};\n"],"names":[],"mappings":"AAAA,sGAAsG,GAEtG,WAgFE"}
|
|
@@ -18,15 +18,15 @@ import type { Primitive } from './Primitive.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export type DeepReadonly<T> = T extends Primitive | ((...args: any[]) => unknown) ? T : T extends ReadonlyMap<infer K, infer V> ? DeepReadonlyMap<K, V> : T extends ReadonlySet<infer I> ? DeepReadonlySet<I> : T extends object ? DeepReadonlyObject<T> : unknown;
|
|
20
20
|
/**
|
|
21
|
-
* Helper type for {@
|
|
21
|
+
* Helper type for {@link DeepReadonly}.
|
|
22
22
|
*/
|
|
23
23
|
type DeepReadonlyMap<K, V> = ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>;
|
|
24
24
|
/**
|
|
25
|
-
* Helper type for {@
|
|
25
|
+
* Helper type for {@link DeepReadonly}.
|
|
26
26
|
*/
|
|
27
27
|
type DeepReadonlySet<I> = ReadonlySet<DeepReadonly<I>>;
|
|
28
28
|
/**
|
|
29
|
-
* Helper type for {@
|
|
29
|
+
* Helper type for {@link DeepReadonly}.
|
|
30
30
|
*/
|
|
31
31
|
type DeepReadonlyObject<O extends object> = {
|
|
32
32
|
readonly [K in keyof O]: DeepReadonly<O[K]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/DeepReadonly.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- needed */\n\nimport type {Primitive} from './Primitive.js';\n\n/**\n * Same as built-in `Readonly`, but works recursively:\n *\n * ```TypeScript\n * import { DeepReadonly } from '@ori/ts-utils';\n *\n * const rawData = {\n * foo: ['bar'],\n * };\n *\n * const data: DeepReadonly<typeof rawData> = rawData;\n *\n * data.foo.push('bar'); // error TS2339: Property 'push' does not exist on type 'readonly string[]'\n * ```\n *\n * @typeParam T Base for the new type\n */\nexport type DeepReadonly<T> = T extends Primitive | ((...args: any[]) => unknown)\n ? T\n : T extends ReadonlyMap<infer K, infer V>\n ? DeepReadonlyMap<K, V>\n : T extends ReadonlySet<infer I>\n ? DeepReadonlySet<I>\n : T extends object\n ? DeepReadonlyObject<T>\n : unknown;\n\n/**\n * Helper type for {@
|
|
1
|
+
{"version":3,"sources":["../../src/types/DeepReadonly.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- needed */\n\nimport type {Primitive} from './Primitive.js';\n\n/**\n * Same as built-in `Readonly`, but works recursively:\n *\n * ```TypeScript\n * import { DeepReadonly } from '@ori/ts-utils';\n *\n * const rawData = {\n * foo: ['bar'],\n * };\n *\n * const data: DeepReadonly<typeof rawData> = rawData;\n *\n * data.foo.push('bar'); // error TS2339: Property 'push' does not exist on type 'readonly string[]'\n * ```\n *\n * @typeParam T Base for the new type\n */\nexport type DeepReadonly<T> = T extends Primitive | ((...args: any[]) => unknown)\n ? T\n : T extends ReadonlyMap<infer K, infer V>\n ? DeepReadonlyMap<K, V>\n : T extends ReadonlySet<infer I>\n ? DeepReadonlySet<I>\n : T extends object\n ? DeepReadonlyObject<T>\n : unknown;\n\n/**\n * Helper type for {@link DeepReadonly}.\n */\ntype DeepReadonlyMap<K, V> = ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>;\n\n/**\n * Helper type for {@link DeepReadonly}.\n */\ntype DeepReadonlySet<I> = ReadonlySet<DeepReadonly<I>>;\n\n/**\n * Helper type for {@link DeepReadonly}.\n */\ntype DeepReadonlyObject<O extends object> = {\n readonly [K in keyof O]: DeepReadonly<O[K]>;\n};\n"],"names":[],"mappings":"AAAA,+DAA+D,GAE/D,WA4CE"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export type UnionToIntersection<U> = boolean extends U ? UnionToIntersectionHelper<Exclude<U, boolean>> & boolean : UnionToIntersectionHelper<U>;
|
|
11
11
|
/**
|
|
12
|
-
* Helper type for {@
|
|
12
|
+
* Helper type for {@link UnionToIntersection}.
|
|
13
13
|
*/
|
|
14
14
|
type UnionToIntersectionHelper<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
15
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/UnionToIntersection.ts"],"sourcesContent":["/**\n * Converts union type to intersection type:\n *\n * ```TypeScript\n * type Result = UnionToIntersection<{ foo: string } | { bar: string }>; // `typeof Result` is `{foo: string} & {bar: string}`\n * ```\n *\n * @typeParam U Base for the new type\n */\nexport type UnionToIntersection<U> = boolean extends U\n ? UnionToIntersectionHelper<Exclude<U, boolean>> & boolean\n : UnionToIntersectionHelper<U>;\n\n/**\n * Helper type for {@
|
|
1
|
+
{"version":3,"sources":["../../src/types/UnionToIntersection.ts"],"sourcesContent":["/**\n * Converts union type to intersection type:\n *\n * ```TypeScript\n * type Result = UnionToIntersection<{ foo: string } | { bar: string }>; // `typeof Result` is `{foo: string} & {bar: string}`\n * ```\n *\n * @typeParam U Base for the new type\n */\nexport type UnionToIntersection<U> = boolean extends U\n ? UnionToIntersectionHelper<Exclude<U, boolean>> & boolean\n : UnionToIntersectionHelper<U>;\n\n/**\n * Helper type for {@link UnionToIntersection}.\n */\ntype UnionToIntersectionHelper<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n"],"names":[],"mappings":"AAAA;;;;;;;;CAQC,GACD,WAWU"}
|
package/dist/types/Writable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Create a new type that removes `readonly` from object types's keys. Inverse of {@
|
|
2
|
+
* Create a new type that removes `readonly` from object types's keys. Inverse of {@link Readonly<T>}.
|
|
3
3
|
*/
|
|
4
4
|
export type Writable<T> = {
|
|
5
5
|
-readonly [K in keyof T]: T[K];
|
package/dist/types/Writable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Create a new type that removes `readonly` from object types's keys. Inverse of {@
|
|
2
|
+
* Create a new type that removes `readonly` from object types's keys. Inverse of {@link Readonly<T>}.
|
|
3
3
|
*/ export { };
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=Writable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/Writable.ts"],"sourcesContent":["/**\n * Create a new type that removes `readonly` from object types's keys. Inverse of {@
|
|
1
|
+
{"version":3,"sources":["../../src/types/Writable.ts"],"sourcesContent":["/**\n * Create a new type that removes `readonly` from object types's keys. Inverse of {@link Readonly<T>}.\n */\nexport type Writable<T> = {\n -readonly [K in keyof T]: T[K];\n};\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAEE"}
|
package/dist/utils/assert.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class AssertionError extends Error {
|
|
|
8
8
|
constructor(message?: string);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A function that throws {@
|
|
11
|
+
* A function that throws {@link AssertionError} (with optional message defined with `errorMessage`) if
|
|
12
12
|
* `condition` is falsy.
|
|
13
13
|
* You can use it to narrow types:
|
|
14
14
|
*
|
package/dist/utils/assert.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* A function that throws {@
|
|
12
|
+
* A function that throws {@link AssertionError} (with optional message defined with `errorMessage`) if
|
|
13
13
|
* `condition` is falsy.
|
|
14
14
|
* You can use it to narrow types:
|
|
15
15
|
*
|
package/dist/utils/assert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/assert.ts"],"sourcesContent":["/**\n * A subclass of `Error` that indicates an assertion failure.\n */\nexport class AssertionError extends Error {\n /**\n * @param message Message added to the default error message\n */\n constructor(message?: string) {\n super(`Wrong assertion encountered${message ? `: \"${message}\"` : ''}!`);\n\n this.name = 'AssertionError';\n }\n}\n\n/**\n * A function that throws {@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/assert.ts"],"sourcesContent":["/**\n * A subclass of `Error` that indicates an assertion failure.\n */\nexport class AssertionError extends Error {\n /**\n * @param message Message added to the default error message\n */\n constructor(message?: string) {\n super(`Wrong assertion encountered${message ? `: \"${message}\"` : ''}!`);\n\n this.name = 'AssertionError';\n }\n}\n\n/**\n * A function that throws {@link AssertionError} (with optional message defined with `errorMessage`) if\n * `condition` is falsy.\n * You can use it to narrow types:\n *\n * ```TypeScript\n * interface Foo {\n * kind: 'Foo';\n * }\n *\n * interface Bar {\n * kind: 'Bar';\n * }\n *\n * declare const foobar: Foo | Bar;\n *\n * assert(is<Foo>(foobar, foobar.kind === 'Foo'));\n *\n * // `typeof foobar` is now `Foo`\n * ```\n *\n * @param condition Condition we're asserting isn't falsy\n * @param errorMessage Message for the `AssertionError`\n */\nexport function assert(condition: unknown, errorMessage?: string): asserts condition {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we don't mind here\n if (!condition) {\n throw new AssertionError(errorMessage);\n }\n}\n"],"names":["AssertionError","Error","constructor","message","name","assert","condition","errorMessage"],"mappings":"AAAA;;CAEC,GACD,OAAO,MAAMA,uBAAuBC;IAClC;;GAEC,GACDC,YAAYC,OAAgB,CAAE;QAC5B,KAAK,CAAC,CAAC,2BAA2B,EAAEA,UAAU,CAAC,GAAG,EAAEA,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;QAEtE,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASC,OAAOC,SAAkB,EAAEC,YAAqB;IAC9D,+FAA+F;IAC/F,IAAI,CAACD,WAAW;QACd,MAAM,IAAIN,eAAeO;IAC3B;AACF"}
|
package/package.json
CHANGED
package/src/types/DeepPartial.ts
CHANGED
|
@@ -54,29 +54,29 @@ export type DeepPartial<T> = T extends Date | Primitive | RegExp
|
|
|
54
54
|
: unknown;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Helper type for {@
|
|
57
|
+
* Helper type for {@link DeepPartial}.
|
|
58
58
|
*/
|
|
59
59
|
interface DeepPartialMap<KeyType, ValueType>
|
|
60
60
|
extends Map<DeepPartial<KeyType>, DeepPartial<ValueType>> {}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* Helper type for {@
|
|
63
|
+
* Helper type for {@link DeepPartial}.
|
|
64
64
|
*/
|
|
65
65
|
interface DeepPartialSet<T> extends Set<DeepPartial<T>> {}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* Helper type for {@
|
|
68
|
+
* Helper type for {@link DeepPartial}.
|
|
69
69
|
*/
|
|
70
70
|
interface DeepPartialReadonlyMap<KeyType, ValueType>
|
|
71
71
|
extends ReadonlyMap<DeepPartial<KeyType>, DeepPartial<ValueType>> {}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Helper type for {@
|
|
74
|
+
* Helper type for {@link DeepPartial}.
|
|
75
75
|
*/
|
|
76
76
|
interface DeepPartialReadonlySet<T> extends ReadonlySet<DeepPartial<T>> {}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* Helper type for {@
|
|
79
|
+
* Helper type for {@link DeepPartial}.
|
|
80
80
|
*/
|
|
81
81
|
type DeepPartialObject<ObjectType extends object> = {
|
|
82
82
|
[KeyType in keyof ObjectType]?: DeepPartial<ObjectType[KeyType]>;
|
|
@@ -30,17 +30,17 @@ export type DeepReadonly<T> = T extends Primitive | ((...args: any[]) => unknown
|
|
|
30
30
|
: unknown;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Helper type for {@
|
|
33
|
+
* Helper type for {@link DeepReadonly}.
|
|
34
34
|
*/
|
|
35
35
|
type DeepReadonlyMap<K, V> = ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Helper type for {@
|
|
38
|
+
* Helper type for {@link DeepReadonly}.
|
|
39
39
|
*/
|
|
40
40
|
type DeepReadonlySet<I> = ReadonlySet<DeepReadonly<I>>;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Helper type for {@
|
|
43
|
+
* Helper type for {@link DeepReadonly}.
|
|
44
44
|
*/
|
|
45
45
|
type DeepReadonlyObject<O extends object> = {
|
|
46
46
|
readonly [K in keyof O]: DeepReadonly<O[K]>;
|
|
@@ -12,7 +12,7 @@ export type UnionToIntersection<U> = boolean extends U
|
|
|
12
12
|
: UnionToIntersectionHelper<U>;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Helper type for {@
|
|
15
|
+
* Helper type for {@link UnionToIntersection}.
|
|
16
16
|
*/
|
|
17
17
|
type UnionToIntersectionHelper<U> = (U extends unknown ? (k: U) => void : never) extends (
|
|
18
18
|
k: infer I,
|
package/src/types/Writable.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Create a new type that removes `readonly` from object types's keys. Inverse of {@
|
|
2
|
+
* Create a new type that removes `readonly` from object types's keys. Inverse of {@link Readonly<T>}.
|
|
3
3
|
*/
|
|
4
4
|
export type Writable<T> = {
|
|
5
5
|
-readonly [K in keyof T]: T[K];
|
package/src/utils/assert.ts
CHANGED
|
@@ -13,7 +13,7 @@ export class AssertionError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* A function that throws {@
|
|
16
|
+
* A function that throws {@link AssertionError} (with optional message defined with `errorMessage`) if
|
|
17
17
|
* `condition` is falsy.
|
|
18
18
|
* You can use it to narrow types:
|
|
19
19
|
*
|