@kakasoo/deep-strict-types 1.0.25 → 1.0.26

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 (2) hide show
  1. package/README.md +55 -38
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # How To Use
2
+
2
3
  ![example](https://github.com/user-attachments/assets/28316425-8302-453e-b238-0c732606e6a7)
3
4
 
4
5
  ```bash
@@ -7,11 +8,13 @@ npm i @kakasoo/deep-strict-types
7
8
 
8
9
  # DeepStrictTypes
9
10
 
10
- **DeepStrictTypes** extends TypeScript utility types, enabling safe operations like `Omit` and `Pick` on nested objects or arrays by specifying the keys to be inferred. This allows for more strict and accurate type checks. **Now, you don't have to recombine numerous types daily to remove a single key from a nested object. You can quickly omit and pick the internal keys you want!**
11
+ **DeepStrictTypes** extends TypeScript utility types, enabling safe operations like `Omit` and `Pick` on deeply nested objects or arrays by specifying keys to be inferred. It provides strict and accurate type checks, simplifying tasks like removing a single key from a nested object without recombining multiple types. Quickly and precisely omit or pick the internal keys you need!
12
+
13
+ ## Key Features
11
14
 
12
- ## DeepStrictObjectKeys
15
+ ### `DeepStrictObjectKeys`
13
16
 
14
- `DeepStrictObjectKeys<T>` extracts all nested keys from an object `T`, preserving the structure of the nested object and returning the types of the keys. This is useful when you need to handle specific keys safely at deeper levels of an object.
17
+ Extract all nested keys from an object `T`, preserving its structure. Useful for safely handling specific keys at deeper levels of an object.
15
18
 
16
19
  ```typescript
17
20
  type Example = {
@@ -28,13 +31,13 @@ type Example = {
28
31
  type Keys = DeepStrictObjectKeys<Example>;
29
32
  ```
30
33
 
31
- In the case of an array, the inside is represented by the `[*]` symbol. Of course, the arrangement of the array, the arrangement of objects in the array, and even if the top object is an array, it is perfectly inferred.
34
+ In arrays, elements are represented with the `[*]` symbol, ensuring perfect inference even for nested structures.
32
35
 
33
- ## DeepStrictOmit
36
+ ### `DeepStrictOmit`
34
37
 
35
- `DeepStrictOmit<T, K>` creates a new type by excluding properties corresponding to the key K from object T, while preserving the nested structure. This type allows precise omission of keys even in deeply nested objects.
38
+ Create a new type by excluding properties corresponding to key `K` from object `T`, preserving the nested structure.
36
39
 
37
- ```ts
40
+ ```typescript
38
41
  type Example = {
39
42
  user: {
40
43
  name: string;
@@ -46,42 +49,30 @@ type Example = {
46
49
  type Omitted = DeepStrictOmit<Example, 'user.name'>;
47
50
  ```
48
51
 
49
- This is also useful for branding types. Below is an example of defining a branding type using a library called typia, in which DeepStrictOmit can also be safely used.
52
+ This is particularly effective for branded types. Below is an example using the `typia` library:
50
53
 
51
- ```ts
52
- test('TEST 1. apply DeepStrictOmit to primitive property type of branding type', () => {
54
+ ```typescript
55
+ test('Apply DeepStrictOmit to branding types', () => {
53
56
  type TestInterface = {
54
57
  id: string;
55
- title: string;
56
58
  thumbnails: {
57
- name: null | (string & MinLength<1> & MaxLength<255>);
58
- extension: null | (string & MinLength<1> & MaxLength<8>);
59
+ name: string & MinLength<1> & MaxLength<255>;
59
60
  url: string;
60
61
  }[];
61
62
  };
62
63
 
63
64
  type Question = DeepStrictOmit<TestInterface, 'id'>;
64
- type IsAnswer = Equal<
65
- Question,
66
- {
67
- title: string;
68
- thumbnails: {
69
- name: null | (string & MinLength<1> & MaxLength<255>);
70
- extension: null | (string & MinLength<1> & MaxLength<8>);
71
- url: string;
72
- }[];
73
- }
74
- >;
65
+ type IsAnswer = Equal<Question, { thumbnails: { name: string & MinLength<1> & MaxLength<255>; url: string }[] }>;
75
66
 
76
67
  ok(typia.random<IsAnswer>());
77
68
  });
78
69
  ```
79
70
 
80
- ## DeepStrictPick
71
+ ### `DeepStrictPick`
81
72
 
82
- `DeepStrictPick<T, K>` creates a new type by selecting only the properties corresponding to the key K from object T, while preserving the nested structure. It allows safely selecting specific keys even from deep objects.
73
+ Select properties corresponding to key `K` from object `T`, preserving the nested structure.
83
74
 
84
- ```ts
75
+ ```typescript
85
76
  type Example = {
86
77
  user: {
87
78
  name: string;
@@ -93,38 +84,64 @@ type Example = {
93
84
  type Picked = DeepStrictPick<Example, 'user.name'>;
94
85
  ```
95
86
 
96
- ## DeepStrictUnbrand
87
+ ### `DeepStrictUnbrand`
97
88
 
98
- DeepStrictUnbrand<T> removes branding from type T and applies it even to deeply nested objects. This makes handling complex branded types simpler by removing the branding for more straightforward use.
89
+ Remove branding from type `T`, even in deeply nested objects, simplifying the handling of branded types.
99
90
 
100
- ```ts
101
- type BrandedType = { brand: number & { type: 'won' } };
91
+ ```typescript
92
+ type BrandedType = { value: number & { unit: 'dollar' } };
102
93
 
103
94
  // Result: { value: number; }
104
95
  type Unbranded = DeepStrictUnbrand<BrandedType>;
105
96
  ```
106
97
 
107
- ## SubTypes for implementation
98
+ ### `GetType`
108
99
 
109
- ### ElementOf
100
+ Get the type of a specific key path from a nested object type `T`. This is useful for extracting the type of deeply nested properties safely.
110
101
 
111
- ElementOf<T> extracts the type of elements from an array type T. This is useful to explicitly define the element type of an array and perform operations on that element.
102
+ ```typescript
103
+ type Example = {
104
+ user: {
105
+ name: string;
106
+ address: {
107
+ city: string;
108
+ zip: number;
109
+ };
110
+ };
111
+ };
112
+
113
+ // Result: string
114
+ type CityType = GetType<Example, 'user.address.city'>;
115
+
116
+ // Result: { city: string; zip: number; }
117
+ type AddressType = GetType<Example, 'user.address'>;
118
+ ```
119
+
120
+ ## Utility SubTypes
112
121
 
113
- ```ts
122
+ ### `ElementOf`
123
+
124
+ Extract the type of elements from an array type `T`.
125
+
126
+ ```typescript
114
127
  type ArrayExample = string[];
115
128
 
116
129
  // Result: string
117
130
  type ElementType = ElementOf<ArrayExample>;
118
131
  ```
119
132
 
120
- ### Equal
133
+ ### `Equal`
121
134
 
122
- Equal<A, B> evaluates whether types A and B are the same and returns true or false. This is used to validate whether two types are identical.
135
+ Evaluate whether types `A` and `B` are the same, returning `true` or `false`. Useful for type validation.
123
136
 
124
- ```ts
137
+ ```typescript
125
138
  type A = { a: number };
126
139
  type B = { a: number };
127
140
 
128
141
  // Result: true
129
142
  type AreEqual = Equal<A, B>;
130
143
  ```
144
+
145
+ ---
146
+
147
+ This is just a part of the features provided by **DeepStrictTypes**, designed to enhance TypeScript's type manipulation capabilities and improve developer productivity. For more details, check out the library's full documentation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kakasoo/deep-strict-types",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -47,13 +47,13 @@
47
47
  "author": "kakasoo",
48
48
  "license": "ISC",
49
49
  "devDependencies": {
50
- "@samchon/shopping-api": "^0.12.1",
51
- "@types/node": "^22.10.2",
50
+ "@samchon/shopping-api": "^0.14.1",
51
+ "@types/node": "^22.10.10",
52
52
  "prettier": "^3.4.2",
53
53
  "rimraf": "^6.0.1",
54
54
  "ts-patch": "^3.3.0",
55
- "typescript": "^5.7.2",
56
- "typia": "^7.5.1"
55
+ "typescript": "^5.7.3",
56
+ "typia": "^7.6.0"
57
57
  },
58
58
  "repository": {
59
59
  "type": "git",