@infra-blocks/types 0.25.0 → 0.26.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.
@@ -24,3 +24,24 @@ export * from "./types.js";
24
24
  * @param value - The value to validate against never.
25
25
  */
26
26
  export declare function unreachable(value: never): never;
27
+ /**
28
+ * A function to mark a value as trusted for a type cast that can leverage inference.
29
+ *
30
+ * It is 100% the same as doing a type cast. Sometimes it's going to look nicer and
31
+ * look more compact, sometimes you're better off with writing the cast.
32
+ *
33
+ * @example
34
+ * type BullshitType = {
35
+ * contentz?: string;
36
+ * };
37
+ * const value: BullshitType = {
38
+ * contentz: "toto",
39
+ * };
40
+ * const content: string = trusted(value.contentz);
41
+ * content.toUpperCase();
42
+ *
43
+ * @param value - The value to type cast.
44
+ *
45
+ * @returns The value, casted as the parametric type.
46
+ */
47
+ export declare function trusted<T>(value: unknown): T;
package/lib/cjs/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.unreachable = unreachable;
18
+ exports.trusted = trusted;
18
19
  __exportStar(require("./func.js"), exports);
19
20
  __exportStar(require("./guard.js"), exports);
20
21
  __exportStar(require("./predicates.js"), exports);
@@ -43,4 +44,27 @@ __exportStar(require("./types.js"), exports);
43
44
  function unreachable(value) {
44
45
  return value;
45
46
  }
47
+ /**
48
+ * A function to mark a value as trusted for a type cast that can leverage inference.
49
+ *
50
+ * It is 100% the same as doing a type cast. Sometimes it's going to look nicer and
51
+ * look more compact, sometimes you're better off with writing the cast.
52
+ *
53
+ * @example
54
+ * type BullshitType = {
55
+ * contentz?: string;
56
+ * };
57
+ * const value: BullshitType = {
58
+ * contentz: "toto",
59
+ * };
60
+ * const content: string = trusted(value.contentz);
61
+ * content.toUpperCase();
62
+ *
63
+ * @param value - The value to type cast.
64
+ *
65
+ * @returns The value, casted as the parametric type.
66
+ */
67
+ function trusted(value) {
68
+ return value;
69
+ }
46
70
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA0BA,kCAEC;AA5BD,4CAA0B;AAC1B,6CAA2B;AAC3B,kDAAgC;AAChC,6CAA2B;AAE3B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA0BA,kCAEC;AAsBD,0BAEC;AApDD,4CAA0B;AAC1B,6CAA2B;AAC3B,kDAAgC;AAChC,6CAA2B;AAE3B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
@@ -24,3 +24,24 @@ export * from "./types.js";
24
24
  * @param value - The value to validate against never.
25
25
  */
26
26
  export declare function unreachable(value: never): never;
27
+ /**
28
+ * A function to mark a value as trusted for a type cast that can leverage inference.
29
+ *
30
+ * It is 100% the same as doing a type cast. Sometimes it's going to look nicer and
31
+ * look more compact, sometimes you're better off with writing the cast.
32
+ *
33
+ * @example
34
+ * type BullshitType = {
35
+ * contentz?: string;
36
+ * };
37
+ * const value: BullshitType = {
38
+ * contentz: "toto",
39
+ * };
40
+ * const content: string = trusted(value.contentz);
41
+ * content.toUpperCase();
42
+ *
43
+ * @param value - The value to type cast.
44
+ *
45
+ * @returns The value, casted as the parametric type.
46
+ */
47
+ export declare function trusted<T>(value: unknown): T;
package/lib/esm/index.js CHANGED
@@ -26,4 +26,27 @@ export * from "./types.js";
26
26
  export function unreachable(value) {
27
27
  return value;
28
28
  }
29
+ /**
30
+ * A function to mark a value as trusted for a type cast that can leverage inference.
31
+ *
32
+ * It is 100% the same as doing a type cast. Sometimes it's going to look nicer and
33
+ * look more compact, sometimes you're better off with writing the cast.
34
+ *
35
+ * @example
36
+ * type BullshitType = {
37
+ * contentz?: string;
38
+ * };
39
+ * const value: BullshitType = {
40
+ * contentz: "toto",
41
+ * };
42
+ * const content: string = trusted(value.contentz);
43
+ * content.toUpperCase();
44
+ *
45
+ * @param value - The value to type cast.
46
+ *
47
+ * @returns The value, casted as the parametric type.
48
+ */
49
+ export function trusted(value) {
50
+ return value;
51
+ }
29
52
  //# sourceMappingURL=index.js.map
@@ -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,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/types",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Typescript types utility package.",
5
5
  "keywords": [
6
6
  "type",