@infra-blocks/types 0.28.0 → 0.29.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.
@@ -1,5 +1,6 @@
1
1
  export * from "./func.js";
2
2
  export * from "./guard.js";
3
+ export * from "./keys.js";
3
4
  export * from "./predicates.js";
4
5
  export * from "./types.js";
5
6
  /**
package/lib/cjs/index.js CHANGED
@@ -19,6 +19,7 @@ exports.trusted = trusted;
19
19
  const node_assert_1 = require("node:assert");
20
20
  __exportStar(require("./func.js"), exports);
21
21
  __exportStar(require("./guard.js"), exports);
22
+ __exportStar(require("./keys.js"), exports);
22
23
  __exportStar(require("./predicates.js"), exports);
23
24
  __exportStar(require("./types.js"), exports);
24
25
  // TODO: Message type, that is either: undefined, a string, a string followed by format args or a function returning a string.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+BA,kCAEC;AAsBD,0BAEC;AAzDD,6CAAmC;AAEnC,4CAA0B;AAC1B,6CAA2B;AAC3B,kDAAgC;AAChC,6CAA2B;AAE3B,8HAA8H;AAC9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,WAAW,CAAC,CAAQ,EAAE,OAAgB;IACpD,IAAA,kBAAI,EAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgCA,kCAEC;AAsBD,0BAEC;AA1DD,6CAAmC;AAEnC,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,kDAAgC;AAChC,6CAA2B;AAE3B,8HAA8H;AAC9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,WAAW,CAAC,CAAQ,EAAE,OAAgB;IACpD,IAAA,kBAAI,EAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A convenience type mapping to extract keys of a type that extend a given type.
3
+ *
4
+ * For example, if you would like all the types of an object that are numbers, you could do
5
+ * `KeysOfType<TheType, number>`.
6
+ *
7
+ * @see https://github.com/microsoft/TypeScript/issues/34992
8
+ */
9
+ export type ExtendingKeys<T, U> = keyof {
10
+ [P in keyof T as T[P] extends U ? P : never]: P;
11
+ };
12
+ /**
13
+ * A mapped type remapping all keys of K to type V.
14
+ */
15
+ export type MapKeys<K, V> = {
16
+ [k in keyof K]: V;
17
+ };
18
+ /**
19
+ * A type utility useful to constrain types to have the same keys as M, without imposing
20
+ * restrictions on the value.
21
+ *
22
+ * It's an alias for MapKeys<M, unknown>.
23
+ */
24
+ export type SameKeys<M> = MapKeys<M, unknown>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * A convenience type mapping to extract keys of a type that extend a given type.
4
+ *
5
+ * For example, if you would like all the types of an object that are numbers, you could do
6
+ * `KeysOfType<TheType, number>`.
7
+ *
8
+ * @see https://github.com/microsoft/TypeScript/issues/34992
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
@@ -31,33 +31,12 @@ export type EnvironmentVariables = Record<string, string | undefined>;
31
31
  * Just aliasing {@link EnvironmentVariables} for brevity.
32
32
  */
33
33
  export type EnvVars = EnvironmentVariables;
34
- /**
35
- * A convenience type mapping to extract keys of a type that are of a given type.
36
- *
37
- * For example, if you would like all the types of an object that are numbers, you could do
38
- * KeyOfType<TheType, number>
39
- */
40
- export type KeyOfType<T, U> = {
41
- [P in keyof T]: T[P] extends U ? P : never;
42
- }[keyof T];
43
- /**
44
- * A mapped type remapping all keys of K to type V.
45
- */
46
- export type MapKeys<K, V> = {
47
- [k in keyof K]: V;
48
- };
49
34
  /**
50
35
  * Convenient type alias to regroup a type that can be T, null or undefined.
51
36
  *
52
37
  * Semantically the opposite of {@link NonNullable}.
53
38
  */
54
39
  export type Nullable<T> = T | null | undefined;
55
- /**
56
- * Convenient mapped type to selectively make some fields of a type optional.
57
- *
58
- * This is in contrast to the built-in `Partial` type which makes all fields optional.
59
- */
60
- export type Optional<T, K extends keyof T = keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
61
40
  /**
62
41
  * A utility type for tracking a phantom type parameter.
63
42
  */
@@ -68,13 +47,6 @@ export type Phantom<T> = {
68
47
  * A union type that includes all primitive types.
69
48
  */
70
49
  export type Primitive = bigint | boolean | null | number | string | symbol | undefined;
71
- /**
72
- * A type utility useful to constrain types to have the same keys as M, without imposing
73
- * restrictions on the value.
74
- *
75
- * It's an alias for MapKeys<M, unknown>.
76
- */
77
- export type SameKeys<M> = MapKeys<M, unknown>;
78
50
  /**
79
51
  * A type representing all types that can be used in a vanilla template literal.
80
52
  *
@@ -1,5 +1,6 @@
1
1
  export * from "./func.js";
2
2
  export * from "./guard.js";
3
+ export * from "./keys.js";
3
4
  export * from "./predicates.js";
4
5
  export * from "./types.js";
5
6
  /**
package/lib/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { fail } from "node:assert";
2
2
  export * from "./func.js";
3
3
  export * from "./guard.js";
4
+ export * from "./keys.js";
4
5
  export * from "./predicates.js";
5
6
  export * from "./types.js";
6
7
  // TODO: Message type, that is either: undefined, a string, a string followed by format args or a function returning a string.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAE3B,8HAA8H;AAC9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,WAAW,CAAC,CAAQ,EAAE,OAAgB;IACpD,IAAI,CAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAE3B,8HAA8H;AAC9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,WAAW,CAAC,CAAQ,EAAE,OAAgB;IACpD,IAAI,CAAC,OAAO,IAAI,2BAA2B,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAI,KAAc;IACvC,OAAO,KAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A convenience type mapping to extract keys of a type that extend a given type.
3
+ *
4
+ * For example, if you would like all the types of an object that are numbers, you could do
5
+ * `KeysOfType<TheType, number>`.
6
+ *
7
+ * @see https://github.com/microsoft/TypeScript/issues/34992
8
+ */
9
+ export type ExtendingKeys<T, U> = keyof {
10
+ [P in keyof T as T[P] extends U ? P : never]: P;
11
+ };
12
+ /**
13
+ * A mapped type remapping all keys of K to type V.
14
+ */
15
+ export type MapKeys<K, V> = {
16
+ [k in keyof K]: V;
17
+ };
18
+ /**
19
+ * A type utility useful to constrain types to have the same keys as M, without imposing
20
+ * restrictions on the value.
21
+ *
22
+ * It's an alias for MapKeys<M, unknown>.
23
+ */
24
+ export type SameKeys<M> = MapKeys<M, unknown>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A convenience type mapping to extract keys of a type that extend a given type.
3
+ *
4
+ * For example, if you would like all the types of an object that are numbers, you could do
5
+ * `KeysOfType<TheType, number>`.
6
+ *
7
+ * @see https://github.com/microsoft/TypeScript/issues/34992
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -31,33 +31,12 @@ export type EnvironmentVariables = Record<string, string | undefined>;
31
31
  * Just aliasing {@link EnvironmentVariables} for brevity.
32
32
  */
33
33
  export type EnvVars = EnvironmentVariables;
34
- /**
35
- * A convenience type mapping to extract keys of a type that are of a given type.
36
- *
37
- * For example, if you would like all the types of an object that are numbers, you could do
38
- * KeyOfType<TheType, number>
39
- */
40
- export type KeyOfType<T, U> = {
41
- [P in keyof T]: T[P] extends U ? P : never;
42
- }[keyof T];
43
- /**
44
- * A mapped type remapping all keys of K to type V.
45
- */
46
- export type MapKeys<K, V> = {
47
- [k in keyof K]: V;
48
- };
49
34
  /**
50
35
  * Convenient type alias to regroup a type that can be T, null or undefined.
51
36
  *
52
37
  * Semantically the opposite of {@link NonNullable}.
53
38
  */
54
39
  export type Nullable<T> = T | null | undefined;
55
- /**
56
- * Convenient mapped type to selectively make some fields of a type optional.
57
- *
58
- * This is in contrast to the built-in `Partial` type which makes all fields optional.
59
- */
60
- export type Optional<T, K extends keyof T = keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
61
40
  /**
62
41
  * A utility type for tracking a phantom type parameter.
63
42
  */
@@ -68,13 +47,6 @@ export type Phantom<T> = {
68
47
  * A union type that includes all primitive types.
69
48
  */
70
49
  export type Primitive = bigint | boolean | null | number | string | symbol | undefined;
71
- /**
72
- * A type utility useful to constrain types to have the same keys as M, without imposing
73
- * restrictions on the value.
74
- *
75
- * It's an alias for MapKeys<M, unknown>.
76
- */
77
- export type SameKeys<M> = MapKeys<M, unknown>;
78
50
  /**
79
51
  * A type representing all types that can be used in a vanilla template literal.
80
52
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/types",
3
- "version": "0.28.0",
3
+ "version": "0.29.0-alpha.0",
4
4
  "description": "Typescript types utility package.",
5
5
  "keywords": [
6
6
  "type",
@@ -44,7 +44,6 @@
44
44
  "@typescript-eslint/eslint-plugin": "^5.59.8",
45
45
  "@typescript-eslint/parser": "^5.59.8",
46
46
  "c8": "^8.0.0",
47
- "expect-type": "^1.3.0",
48
47
  "lefthook": "^2.0.8",
49
48
  "tsx": "^4.21.0",
50
49
  "typescript": "^5.9.3"