@infra-blocks/types 0.7.0 → 0.8.0-alpha.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/lib/cjs/index.d.ts +20 -0
- package/lib/cjs/index.js +24 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.d.ts +20 -0
- package/lib/esm/index.js +22 -0
- package/lib/esm/index.js.map +1 -1
- package/package.json +1 -1
package/lib/cjs/index.d.ts
CHANGED
|
@@ -50,3 +50,23 @@ export type TransitivePartial<T> = {
|
|
|
50
50
|
export type KeyOfType<T, U> = {
|
|
51
51
|
[P in keyof T]: T[P] extends U ? P : never;
|
|
52
52
|
}[keyof T];
|
|
53
|
+
/**
|
|
54
|
+
* A function for forcing exhaustiveness in switch statements or if-else chains.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* type BigType = "penus" | "penii";
|
|
58
|
+
* let x: BigType = "penus";
|
|
59
|
+
* switch (x) {
|
|
60
|
+
* case "penus":
|
|
61
|
+
* // handle penus
|
|
62
|
+
* break;
|
|
63
|
+
* case "penii":
|
|
64
|
+
* // handle penii
|
|
65
|
+
* break;
|
|
66
|
+
* default:
|
|
67
|
+
* unreachable(x); // This will not compile if the switch is not exhaustive.
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* @param value - The value to validate against never.
|
|
71
|
+
*/
|
|
72
|
+
export declare function unreachable(value: never): never;
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,7 +14,31 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.unreachable = void 0;
|
|
17
18
|
__exportStar(require("./func.js"), exports);
|
|
18
19
|
__exportStar(require("./guard.js"), exports);
|
|
19
20
|
__exportStar(require("./events.js"), exports);
|
|
21
|
+
/**
|
|
22
|
+
* A function for forcing exhaustiveness in switch statements or if-else chains.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* type BigType = "penus" | "penii";
|
|
26
|
+
* let x: BigType = "penus";
|
|
27
|
+
* switch (x) {
|
|
28
|
+
* case "penus":
|
|
29
|
+
* // handle penus
|
|
30
|
+
* break;
|
|
31
|
+
* case "penii":
|
|
32
|
+
* // handle penii
|
|
33
|
+
* break;
|
|
34
|
+
* default:
|
|
35
|
+
* unreachable(x); // This will not compile if the switch is not exhaustive.
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* @param value - The value to validate against never.
|
|
39
|
+
*/
|
|
40
|
+
function unreachable(value) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
exports.unreachable = unreachable;
|
|
20
44
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAyD5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAFD,kCAEC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -50,3 +50,23 @@ export type TransitivePartial<T> = {
|
|
|
50
50
|
export type KeyOfType<T, U> = {
|
|
51
51
|
[P in keyof T]: T[P] extends U ? P : never;
|
|
52
52
|
}[keyof T];
|
|
53
|
+
/**
|
|
54
|
+
* A function for forcing exhaustiveness in switch statements or if-else chains.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* type BigType = "penus" | "penii";
|
|
58
|
+
* let x: BigType = "penus";
|
|
59
|
+
* switch (x) {
|
|
60
|
+
* case "penus":
|
|
61
|
+
* // handle penus
|
|
62
|
+
* break;
|
|
63
|
+
* case "penii":
|
|
64
|
+
* // handle penii
|
|
65
|
+
* break;
|
|
66
|
+
* default:
|
|
67
|
+
* unreachable(x); // This will not compile if the switch is not exhaustive.
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* @param value - The value to validate against never.
|
|
71
|
+
*/
|
|
72
|
+
export declare function unreachable(value: never): never;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
export * from "./func.js";
|
|
2
2
|
export * from "./guard.js";
|
|
3
3
|
export * from "./events.js";
|
|
4
|
+
/**
|
|
5
|
+
* A function for forcing exhaustiveness in switch statements or if-else chains.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* type BigType = "penus" | "penii";
|
|
9
|
+
* let x: BigType = "penus";
|
|
10
|
+
* switch (x) {
|
|
11
|
+
* case "penus":
|
|
12
|
+
* // handle penus
|
|
13
|
+
* break;
|
|
14
|
+
* case "penii":
|
|
15
|
+
* // handle penii
|
|
16
|
+
* break;
|
|
17
|
+
* default:
|
|
18
|
+
* unreachable(x); // This will not compile if the switch is not exhaustive.
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* @param value - The value to validate against never.
|
|
22
|
+
*/
|
|
23
|
+
export function unreachable(value) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
4
26
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAyD5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC"}
|