@deessejs/type-testing 0.2.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @deessejs/type-testing
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: add type utility helpers
8
+
9
+ Add new type utilities for compile-time type testing:
10
+
11
+ ### Property Modifiers
12
+ - IsReadonly<T> - Check if all properties are readonly
13
+ - IsRequired<T> - Check if all properties are required
14
+ - IsPublic<T, K> - Check if property is public
15
+ - IsPrivate<T, K> - Check if property is private
16
+ - IsProtected<T, K> - Check if property is protected
17
+
18
+ ### Deep Type Manipulation
19
+ - DeepReadonly<T> - Make all properties readonly recursively
20
+ - DeepPartial<T> - Make all properties optional recursively
21
+ - RequiredKeys<T> - Get keys of required properties
22
+ - OptionalKeys<T> - Get keys of optional properties
23
+
24
+ ### Function Types
25
+ - IsConstructor<T> - Check if type is a constructor
26
+ - IsAbstract<T> - Check if type is abstract
27
+
28
+ ### Other
29
+ - IsNeverEqual<T, U> - Check if T and U are both never
30
+
3
31
  ## 0.2.0
4
32
 
5
33
  ### Minor Changes
package/README.md CHANGED
@@ -139,6 +139,27 @@ HasProperty<{ a: string }, 'b'> // false
139
139
  PropertyType<{ a: string }, 'a'> // string
140
140
  ```
141
141
 
142
+ ### Property Modifiers
143
+
144
+ ```typescript
145
+ import { IsReadonly, IsRequired, IsPublic, IsPrivate, IsProtected } from '@deessejs/type-testing'
146
+
147
+ // Check if all properties are readonly
148
+ IsReadonly<{ readonly a: string }> // true
149
+ IsReadonly<{ a: string }> // false
150
+
151
+ // Check if all properties are required
152
+ IsRequired<{ a: string }> // true
153
+ IsRequired<{ a?: string }> // false
154
+
155
+ // Check property visibility (uses naming convention)
156
+ IsPublic<{ a: string }, 'a'> // true
157
+ IsPrivate<{ __private: string }, '__private'> // true
158
+ IsProtected<{ _protected: string }, '_protected'> // true
159
+ ```
160
+
161
+ > **Note**: `IsPublic`, `IsPrivate`, and `IsProtected` use TypeScript's private field naming convention (`__` prefix) and common JavaScript convention (`_` prefix for protected). These are naming-convention-based checks, not actual TypeScript access modifiers (which don't exist for object properties).
162
+
142
163
  ### Function Types
143
164
 
144
165
  ```typescript
@@ -164,6 +185,51 @@ Length<['a', 'b', 'c']> // 3
164
185
  Length<[]> // 0
165
186
  ```
166
187
 
188
+ ### Deep Type Manipulation
189
+
190
+ ```typescript
191
+ import { DeepReadonly, DeepPartial, RequiredKeys, OptionalKeys } from '@deessejs/type-testing'
192
+
193
+ // Make all properties readonly recursively
194
+ DeepReadonly<{ a: string; b: { c: number } }>
195
+ // { readonly a: string; readonly b: { readonly c: number } }
196
+
197
+ // Make all properties optional recursively
198
+ DeepPartial<{ a: string; b: { c: number } }>
199
+ // { a?: string; b?: { c?: number } | undefined }
200
+
201
+ // Get keys of required properties
202
+ RequiredKeys<{ a: string; b?: number }> // 'a'
203
+
204
+ // Get keys of optional properties
205
+ OptionalKeys<{ a: string; b?: number }> // 'b'
206
+ ```
207
+
208
+ ### Constructor & Abstract Types
209
+
210
+ ```typescript
211
+ import { IsConstructor, IsAbstract } from '@deessejs/type-testing'
212
+
213
+ class Foo {}
214
+ abstract class Bar {}
215
+
216
+ IsConstructor<typeof Foo> // true
217
+ IsConstructor<Foo> // false (instance)
218
+ IsAbstract<typeof Bar> // true
219
+ IsAbstract<typeof Foo> // false
220
+ ```
221
+
222
+ ### Special Equality
223
+
224
+ ```typescript
225
+ import { IsNeverEqual } from '@deessejs/type-testing'
226
+
227
+ // Check if both types are never
228
+ // Differs from Equal<never, never> which returns false
229
+ IsNeverEqual<never, never> // true
230
+ IsNeverEqual<any, any> // false (any is not never)
231
+ ```
232
+
167
233
  ## Runtime Type Checking
168
234
 
169
235
  The library also provides runtime type checking utilities:
@@ -308,6 +374,7 @@ expectFalse<true>() // compile error
308
374
  | `Equal<T, U>` | Strict equality check |
309
375
  | `NotEqual<T, U>` | Inequality check |
310
376
  | `SimpleEqual<T, U>` | Simple equality for plain types |
377
+ | `IsNeverEqual<T, U>` | Check if both types are `never` |
311
378
  | `IsAny<T>` | Check if type is `any` |
312
379
  | `IsNever<T>` | Check if type is `never` |
313
380
  | `IsUnknown<T>` | Check if type is `unknown` |
@@ -323,9 +390,20 @@ expectFalse<true>() // compile error
323
390
  | `IsUninhabited<T>` | Check if type has no values |
324
391
  | `HasProperty<T, K>` | Check if type has property K |
325
392
  | `PropertyType<T, K>` | Get type of property K |
393
+ | `IsReadonly<T>` | Check if all properties are readonly |
394
+ | `IsRequired<T>` | Check if all properties are required |
395
+ | `IsPublic<T, K>` | Check if property is public |
396
+ | `IsPrivate<T, K>` | Check if property is private (naming convention) |
397
+ | `IsProtected<T, K>` | Check if property is protected (naming convention) |
398
+ | `DeepReadonly<T>` | Make all properties readonly recursively |
399
+ | `DeepPartial<T>` | Make all properties optional recursively |
400
+ | `RequiredKeys<T>` | Get keys of required properties |
401
+ | `OptionalKeys<T>` | Get keys of optional properties |
326
402
  | `Parameters<T>` | Get function parameters as tuple |
327
403
  | `ReturnType<T>` | Get function return type |
328
404
  | `Parameter<T, N>` | Get parameter at index N |
405
+ | `IsConstructor<T>` | Check if type is a constructor |
406
+ | `IsAbstract<T>` | Check if type is abstract |
329
407
  | `Length<T>` | Get tuple/array length |
330
408
  | `ExpectTrue<T>` | Assert T is true |
331
409
  | `ExpectEqual<T, U>` | Assert T equals U |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/type-testing",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/public/icon.png CHANGED
Binary file