lay-sing 0.3.0 → 0.4.1

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 (141) hide show
  1. package/README.md +17 -17
  2. package/esm/main/expect/index.d.ts +30 -0
  3. package/esm/main/expect/index.d.ts.map +1 -0
  4. package/esm/main/expect/index.js +2 -0
  5. package/esm/main/expect/index.js.map +1 -0
  6. package/esm/main/expect/to/be.d.ts +23 -0
  7. package/esm/main/expect/to/be.d.ts.map +1 -0
  8. package/esm/main/expect/to/be.js +2 -0
  9. package/esm/main/expect/to/be.js.map +1 -0
  10. package/esm/main/expect/to/equal.d.ts +26 -0
  11. package/esm/main/expect/to/equal.d.ts.map +1 -0
  12. package/esm/main/expect/to/equal.js +2 -0
  13. package/esm/main/expect/to/equal.js.map +1 -0
  14. package/esm/main/expect/to/extend.d.ts +31 -0
  15. package/esm/main/expect/to/extend.d.ts.map +1 -0
  16. package/esm/main/expect/to/extend.js +2 -0
  17. package/esm/main/expect/to/extend.js.map +1 -0
  18. package/esm/main/expect/to/have-key.d.ts +38 -0
  19. package/esm/main/expect/to/have-key.d.ts.map +1 -0
  20. package/esm/main/expect/to/have-key.js +2 -0
  21. package/esm/main/expect/to/have-key.js.map +1 -0
  22. package/esm/main/expect/to/index.d.ts +15 -0
  23. package/esm/main/expect/to/index.d.ts.map +1 -0
  24. package/esm/main/expect/to/index.js +2 -0
  25. package/esm/main/expect/to/index.js.map +1 -0
  26. package/esm/main/expect/to/proper-extends.d.ts +21 -0
  27. package/esm/main/expect/to/proper-extends.d.ts.map +1 -0
  28. package/esm/main/expect/to/proper-extends.js +2 -0
  29. package/esm/main/expect/to/proper-extends.js.map +1 -0
  30. package/esm/main/index.d.ts +10 -8
  31. package/esm/main/index.d.ts.map +1 -1
  32. package/esm/main/index.js +20 -3
  33. package/esm/main/index.js.map +1 -1
  34. package/esm/utils/compare/exact.d.ts +8 -8
  35. package/esm/utils/compare/exact.js.map +1 -1
  36. package/esm/utils/index.d.ts +1 -0
  37. package/esm/utils/index.d.ts.map +1 -1
  38. package/esm/utils/index.js +1 -0
  39. package/esm/utils/index.js.map +1 -1
  40. package/esm/utils/logic/assert.d.ts +3 -3
  41. package/esm/utils/logic/assert.js.map +1 -1
  42. package/esm/utils/logic/boolean.d.ts +60 -0
  43. package/esm/utils/logic/boolean.d.ts.map +1 -0
  44. package/esm/utils/logic/boolean.js +2 -0
  45. package/esm/utils/logic/boolean.js.map +1 -0
  46. package/esm/utils/logic/index.d.ts +1 -0
  47. package/esm/utils/logic/index.d.ts.map +1 -1
  48. package/esm/utils/logic/index.js +1 -0
  49. package/esm/utils/logic/index.js.map +1 -1
  50. package/esm/utils/logic/switch.d.ts +1 -1
  51. package/esm/utils/logic/switch.js.map +1 -1
  52. package/esm/utils/misc.d.ts +34 -0
  53. package/esm/utils/misc.d.ts.map +1 -0
  54. package/esm/utils/misc.js +2 -0
  55. package/esm/utils/misc.js.map +1 -0
  56. package/esm/utils/object/keys.d.ts +12 -12
  57. package/esm/utils/object/keys.js.map +1 -1
  58. package/esm/utils/object/pick.d.ts +1 -1
  59. package/esm/utils/object/pick.js.map +1 -1
  60. package/esm/utils/object/props.d.ts +1 -1
  61. package/esm/utils/object/props.js.map +1 -1
  62. package/esm/utils/tuple/append.d.ts +2 -2
  63. package/esm/utils/tuple/append.js.map +1 -1
  64. package/esm/utils/tuple/concat.d.ts +2 -2
  65. package/esm/utils/tuple/concat.js.map +1 -1
  66. package/esm/utils/tuple/includes.d.ts +3 -3
  67. package/esm/utils/tuple/includes.js.map +1 -1
  68. package/package.json +1 -1
  69. package/script/main/expect/index.d.ts +30 -0
  70. package/script/main/expect/index.d.ts.map +1 -0
  71. package/script/main/{expect.js → expect/index.js} +1 -1
  72. package/script/main/expect/index.js.map +1 -0
  73. package/script/main/expect/to/be.d.ts +23 -0
  74. package/script/main/expect/to/be.d.ts.map +1 -0
  75. package/script/main/expect/to/be.js +3 -0
  76. package/script/main/expect/to/be.js.map +1 -0
  77. package/script/main/expect/to/equal.d.ts +26 -0
  78. package/script/main/expect/to/equal.d.ts.map +1 -0
  79. package/script/main/expect/to/equal.js +3 -0
  80. package/script/main/expect/to/equal.js.map +1 -0
  81. package/script/main/expect/to/extend.d.ts +31 -0
  82. package/script/main/expect/to/extend.d.ts.map +1 -0
  83. package/script/main/expect/to/extend.js +3 -0
  84. package/script/main/expect/to/extend.js.map +1 -0
  85. package/script/main/expect/to/have-key.d.ts +38 -0
  86. package/script/main/expect/to/have-key.d.ts.map +1 -0
  87. package/script/main/expect/to/have-key.js +3 -0
  88. package/script/main/expect/to/have-key.js.map +1 -0
  89. package/script/main/expect/to/index.d.ts +15 -0
  90. package/script/main/expect/to/index.d.ts.map +1 -0
  91. package/script/main/expect/to/index.js +3 -0
  92. package/script/main/expect/to/index.js.map +1 -0
  93. package/script/main/expect/to/proper-extends.d.ts +21 -0
  94. package/script/main/expect/to/proper-extends.d.ts.map +1 -0
  95. package/script/main/expect/to/proper-extends.js +3 -0
  96. package/script/main/expect/to/proper-extends.js.map +1 -0
  97. package/script/main/index.d.ts +10 -8
  98. package/script/main/index.d.ts.map +1 -1
  99. package/script/main/index.js +21 -5
  100. package/script/main/index.js.map +1 -1
  101. package/script/utils/compare/exact.d.ts +8 -8
  102. package/script/utils/compare/exact.js.map +1 -1
  103. package/script/utils/index.d.ts +1 -0
  104. package/script/utils/index.d.ts.map +1 -1
  105. package/script/utils/index.js +1 -0
  106. package/script/utils/index.js.map +1 -1
  107. package/script/utils/logic/assert.d.ts +3 -3
  108. package/script/utils/logic/assert.js.map +1 -1
  109. package/script/utils/logic/boolean.d.ts +60 -0
  110. package/script/utils/logic/boolean.d.ts.map +1 -0
  111. package/script/utils/logic/boolean.js +3 -0
  112. package/script/utils/logic/boolean.js.map +1 -0
  113. package/script/utils/logic/index.d.ts +1 -0
  114. package/script/utils/logic/index.d.ts.map +1 -1
  115. package/script/utils/logic/index.js +1 -0
  116. package/script/utils/logic/index.js.map +1 -1
  117. package/script/utils/logic/switch.d.ts +1 -1
  118. package/script/utils/logic/switch.js.map +1 -1
  119. package/script/utils/misc.d.ts +34 -0
  120. package/script/utils/misc.d.ts.map +1 -0
  121. package/script/utils/misc.js +3 -0
  122. package/script/utils/misc.js.map +1 -0
  123. package/script/utils/object/keys.d.ts +12 -12
  124. package/script/utils/object/keys.js.map +1 -1
  125. package/script/utils/object/pick.d.ts +1 -1
  126. package/script/utils/object/pick.js.map +1 -1
  127. package/script/utils/object/props.d.ts +1 -1
  128. package/script/utils/object/props.js.map +1 -1
  129. package/script/utils/tuple/append.d.ts +2 -2
  130. package/script/utils/tuple/append.js.map +1 -1
  131. package/script/utils/tuple/concat.d.ts +2 -2
  132. package/script/utils/tuple/concat.js.map +1 -1
  133. package/script/utils/tuple/includes.d.ts +3 -3
  134. package/script/utils/tuple/includes.js.map +1 -1
  135. package/esm/main/expect.d.ts +0 -293
  136. package/esm/main/expect.d.ts.map +0 -1
  137. package/esm/main/expect.js +0 -2
  138. package/esm/main/expect.js.map +0 -1
  139. package/script/main/expect.d.ts +0 -293
  140. package/script/main/expect.d.ts.map +0 -1
  141. package/script/main/expect.js.map +0 -1
@@ -1,293 +0,0 @@
1
- import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../utils/index.js';
2
- /**
3
- * Represents the result of a type assertion based on a boolean condition.
4
- *
5
- * - If `true`, the result has a `success` property;
6
- * - If `false`, the result has a `fail` property;
7
- * - Otherwise, the result is `never`
8
- *
9
- * @template B The boolean condition result (true or false)
10
- * @template R The type of the result value (default is void)
11
- */
12
- export type TypeAssertionResult<B extends boolean, R = void> = Exact<B, never> extends true ? never : [boolean] extends [B] ? never : [B] extends [true] ? {
13
- /**
14
- * This field exist only when this type assertion succeed
15
- *
16
- * If you expect this assertion to fail, use `.fail`
17
- */
18
- success: R;
19
- } : [B] extends [false] ? {
20
- /**
21
- * This field exist only when this type assertion failed
22
- *
23
- * If you expect this assertion to success, use `.success`
24
- */
25
- fail: R;
26
- } : never;
27
- type ExpectTypeMethods<T, H extends PropertyKey = never> = {
28
- /**
29
- * Tests if the current type is exactly the same as the provided type U.
30
- *
31
- * @template U The type to compare with
32
- *
33
- * @example
34
- * ```ts
35
- * import { expect } from '@leawind/lay-sing'
36
- *
37
- * expect<any>().toBe<any>().success
38
- * expect<never>().toBe<never>().success
39
- * expect<false>().toBe<true>().fail
40
- * ```
41
- */
42
- toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
43
- toBe<U>(_: U): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
44
- /**
45
- * Tests if the current type is mutually assignable with the provided type U.
46
- *
47
- * It's like:
48
- *
49
- * ```ts ignore
50
- * [T] extends [U] ? [U] extends [T] ? Yes : No : No
51
- * ```
52
- *
53
- * @template U The type to compare with
54
- *
55
- * @example
56
- * ```ts
57
- * import { expect } from '@leawind/lay-sing'
58
- *
59
- * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
60
- * expect<1>().toEqual<1 | 2>().fail
61
- * ```
62
- */
63
- toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
64
- toEqual<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
65
- /**
66
- * Tests if the current type T extends the provided type U.
67
- *
68
- * @template U The type to check extension against
69
- *
70
- * @example
71
- * ```ts
72
- * import { expect } from '@leawind/lay-sing'
73
- *
74
- * expect<3.14>().toExtend<number>().success
75
- * expect<2>().toExtend<string>().fail
76
- * expect<'hello'>().toExtend<string>().success
77
- * ```
78
- */
79
- toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
80
- toExtend<U>(_: U): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
81
- /**
82
- * Tests if the current type T properly extends the provided type U (extends but is not the same).
83
- *
84
- * @template U The type to check proper extension against
85
- *
86
- * @example
87
- * ```ts
88
- * import { expect } from '@leawind/lay-sing'
89
- *
90
- * expect<2>().toProperExtend<number>().success
91
- * expect<'a' | 'b'>().toProperExtend<string>().success
92
- * expect<number>().toProperExtend<number>().fail
93
- * ```
94
- */
95
- toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
96
- toProperExtend<U>(_: U): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
97
- /**
98
- * Tests if the current type `T` has a property with key `K`.
99
- *
100
- * @template K The property key to check for
101
- *
102
- * ### Behavior
103
- *
104
- * - For single keys: succeeds if the key exists in `T`
105
- * - For union types: succeeds only if **all** keys in the union exist in `T`
106
- *
107
- * ### Examples
108
- *
109
- * ```ts
110
- * import { expect } from '@leawind/lay-sing'
111
- *
112
- * type WithProp = { prop: string; another: number; may?: 5 }
113
- *
114
- * // Single key checks
115
- * expect<WithProp>().toHaveKey<'prop'>().success
116
- * expect<WithProp>().toHaveKey<'missing'>().fail
117
- *
118
- * // Union type checks
119
- * expect<WithProp>().toHaveKey<'prop' | 'another'>().success
120
- * expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail
121
- * ```
122
- */
123
- toHaveKey<K extends PropertyKey>(): IfTupleIncludes<[
124
- never,
125
- any
126
- ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
127
- toHaveKey<K extends PropertyKey>(_: K): IfTupleIncludes<[
128
- never,
129
- any
130
- ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
131
- };
132
- type ExpectFunction<T, H extends PropertyKey = never> = Exact<T, any> extends true ? unknown : Exact<T, never> extends true ? unknown : [T] extends [(...args: infer Args) => infer R] ? {
133
- argsType(): ExpectType<Args, H>;
134
- returnType(): ExpectType<R, H>;
135
- } : [T] extends [new (...args: infer Args) => infer R] ? {
136
- argsType(): ExpectType<Args, H>;
137
- returnType(): ExpectType<R, H>;
138
- } : unknown;
139
- /**
140
- * Type-level testing utility that allows checking various relationships between types.
141
- * Provides methods to test type equality, extension, properties, and more.
142
- *
143
- * @template T The type being tested
144
- * @template H Hidden property keys that are already used (internal tracking)
145
- *
146
- * @example
147
- * ```ts
148
- * import { expect } from '@leawind/lay-sing'
149
- *
150
- * // Test if two types are identical
151
- * expect<number>().toBe<number>().success
152
- * expect<number>().toBe<string>().fail
153
- * // Test if one type extends another
154
- * expect<2>().toExtend<number>().success
155
- * expect<2>().toExtend<string>().fail
156
- * // Test if type has a specific property
157
- * expect<{name: string}>().toHaveKey<'name'>().success
158
- * ```
159
- */
160
- export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMethods<T, H> & ExpectFunction<T, H> & {
161
- T: T;
162
- inspect: {
163
- [K in keyof T]: T[K];
164
- };
165
- } & SafePick<{
166
- /**
167
- * Tests if the current type extends the Number primitive type.
168
- * Available only if the current type extends number.
169
- *
170
- * @example
171
- * ```ts
172
- * import { expect } from '@leawind/lay-sing'
173
- *
174
- * expect<3.14>().toExtendNumber
175
- * ```
176
- */
177
- toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>;
178
- /**
179
- * Tests if the current type extends the String primitive type.
180
- * Available only if the current type extends string.
181
- *
182
- * @example
183
- * ```ts
184
- * import { expect } from '@leawind/lay-sing'
185
- *
186
- * expect<'hello'>().toExtendString
187
- * ```
188
- */
189
- toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>;
190
- /**
191
- * Tests if the current type extends the Boolean primitive type.
192
- * Available only if the current type extends boolean.
193
- *
194
- * @example
195
- * ```ts
196
- * import { expect } from '@leawind/lay-sing'
197
- *
198
- * expect<true>().toExtendBoolean
199
- * ```
200
- */
201
- toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>;
202
- }, If<Extends<T, number>, 'toExtendNumber'> | If<Extends<T, string>, 'toExtendString'> | If<Extends<T, boolean>, 'toExtendBoolean'>> & SafePick<{
203
- /**
204
- * Alias for {@link ExpectTypeMethods.toBe} where `U = any`
205
- *
206
- * ```ts
207
- * import { expect } from '@leawind/lay-sing'
208
- *
209
- * expect<any>().toBeAny
210
- * expect<any>().toBe<any>().success
211
- * ```
212
- */
213
- toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>;
214
- /**
215
- * Alias for {@link ExpectTypeMethods.toBe} where `U = never`
216
- *
217
- * ```ts
218
- * import { expect } from '@leawind/lay-sing'
219
- *
220
- * expect<never>().toBeNever
221
- * expect<never>().toBe<never>().success
222
- * ```
223
- */
224
- toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>;
225
- /**
226
- * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`
227
- *
228
- * ```ts
229
- * import { expect } from '@leawind/lay-sing'
230
- *
231
- * expect<unknown>().toBeUnknown
232
- * expect<unknown>().toBe<unknown>().success
233
- * ```
234
- */
235
- toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>;
236
- /**
237
- * Alias for {@link ExpectTypeMethods.toBe} where `U = void`
238
- *
239
- * ```ts
240
- * import { expect } from '@leawind/lay-sing'
241
- *
242
- * expect<void>().toBeVoid
243
- * expect<void>().toBe<void>().success
244
- * ```
245
- */
246
- toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>;
247
- /**
248
- * Alias for {@link ExpectTypeMethods.toBe} where `U = null`
249
- *
250
- * ```ts
251
- * import { expect } from '@leawind/lay-sing'
252
- *
253
- * expect<null>().toBeNull
254
- * expect<null>().toBe<null>().success
255
- * ```
256
- */
257
- toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>;
258
- /**
259
- * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`
260
- *
261
- * ```ts
262
- * import { expect } from '@leawind/lay-sing'
263
- *
264
- * expect<undefined>().toBeUndefined
265
- * expect<undefined>().toBe<undefined>().success
266
- * ```
267
- */
268
- toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>;
269
- /**
270
- * Alias for {@link ExpectTypeMethods.toBe} where `U = true`
271
- *
272
- * ```ts
273
- * import { expect } from '@leawind/lay-sing'
274
- *
275
- * expect<true>().toBeTrue
276
- * expect<true>().toBe<true>().success
277
- * ```
278
- */
279
- toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>;
280
- /**
281
- * Alias for {@link ExpectTypeMethods.toBe} where `U = false`
282
- *
283
- * ```ts
284
- * import { expect } from '@leawind/lay-sing'
285
- *
286
- * expect<false>().toBeFalse
287
- * expect<false>().toBe<false>().success
288
- * ```
289
- */
290
- toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>;
291
- }, If<Exact<T, any>, 'toBeAny'> | If<Exact<T, never>, 'toBeNever'> | If<Exact<T, unknown>, 'toBeUnknown'> | If<Exact<T, void>, 'toBeVoid'> | If<Exact<T, null>, 'toBeNull'> | If<Exact<T, undefined>, 'toBeUndefined'> | If<Exact<T, true>, 'toBeTrue'> | If<Exact<T, false>, 'toBeFalse'>>), H>;
292
- export {};
293
- //# sourceMappingURL=expect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/main/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,EAAE,EACF,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,IAAI,GAAG,KAAK,GAC/F,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,GAC7B,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;IACnB;;;;OAIG;IACH,OAAO,EAAE,CAAC,CAAA;CACX,GACD,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;IACpB;;;;OAIG;IACH,IAAI,EAA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AU,CAAC,GAC9B,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,CACnC,CACF,EACD,CAAC,CACF,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=expect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/main/expect.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Exact,\n Extends,\n If,\n IfTupleIncludes,\n MutuallyAssignable,\n ProperExtend,\n SafePick,\n} from '../utils/index.js'\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n *\n * - If `true`, the result has a `success` property;\n * - If `false`, the result has a `fail` property;\n * - Otherwise, the result is `never`\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\nexport type TypeAssertionResult<B extends boolean, R = void> = Exact<B, never> extends true ? never\n : [boolean] extends [B] ? never\n : [B] extends [true] ? {\n /**\n * This field exist only when this type assertion succeed\n *\n * If you expect this assertion to fail, use `.fail`\n */\n success: R\n }\n : [B] extends [false] ? {\n /**\n * This field exist only when this type assertion failed\n *\n * If you expect this assertion to success, use `.success`\n */\n fail: R\n }\n : never\n\ntype ExpectTypeMethods<T, H extends PropertyKey = never> = {\n /**\n * Tests if the current type is exactly the same as the provided type U.\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>\n toBe<U>(_: U): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success\n * expect<1>().toEqual<1 | 2>().fail\n * ```\n */\n toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>\n toEqual<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>\n toExtend<U>(_: U): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>\n toProperExtend<U>(_: U): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type `T` has a property with key `K`.\n *\n * @template K The property key to check for\n *\n * ### Behavior\n *\n * - For single keys: succeeds if the key exists in `T`\n * - For union types: succeeds only if **all** keys in the union exist in `T`\n *\n * ### Examples\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type WithProp = { prop: string; another: number; may?: 5 }\n *\n * // Single key checks\n * expect<WithProp>().toHaveKey<'prop'>().success\n * expect<WithProp>().toHaveKey<'missing'>().fail\n *\n * // Union type checks\n * expect<WithProp>().toHaveKey<'prop' | 'another'>().success\n * expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail\n * ```\n */\n toHaveKey<K extends PropertyKey>(): IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>\n >\n toHaveKey<K extends PropertyKey>(_: K): IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>\n >\n}\n\ntype ExpectFunction<T, H extends PropertyKey = never> = Exact<T, any> extends true ? unknown\n : Exact<T, never> extends true ? unknown\n : [T] extends [(...args: infer Args) => infer R] ? {\n argsType(): ExpectType<Args, H>\n returnType(): ExpectType<R, H>\n }\n : [T] extends [new (...args: infer Args) => infer R] ? {\n argsType(): ExpectType<Args, H>\n returnType(): ExpectType<R, H>\n }\n : unknown\n\n/**\n * Type-level testing utility that allows checking various relationships between types.\n * Provides methods to test type equality, extension, properties, and more.\n *\n * @template T The type being tested\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * // Test if two types are identical\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<2>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * // Test if type has a specific property\n * expect<{name: string}>().toHaveKey<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & ExpectTypeMethods<T, H>\n & ExpectFunction<T, H>\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n }\n & SafePick<\n {\n /**\n * Tests if the current type extends the Number primitive type.\n * Available only if the current type extends number.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().toExtendNumber\n * ```\n */\n toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>\n\n /**\n * Tests if the current type extends the String primitive type.\n * Available only if the current type extends string.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<'hello'>().toExtendString\n * ```\n */\n toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>\n\n /**\n * Tests if the current type extends the Boolean primitive type.\n * Available only if the current type extends boolean.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<true>().toExtendBoolean\n * ```\n */\n toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>\n },\n | If<Extends<T, number>, 'toExtendNumber'>\n | If<Extends<T, string>, 'toExtendString'>\n | If<Extends<T, boolean>, 'toExtendBoolean'>\n >\n & SafePick<\n {\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = any`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<any>().toBeAny\n * expect<any>().toBe<any>().success\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = never`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<never>().toBeNever\n * expect<never>().toBe<never>().success\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<unknown>().toBeUnknown\n * expect<unknown>().toBe<unknown>().success\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = void`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<void>().toBeVoid\n * expect<void>().toBe<void>().success\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = null`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<null>().toBeNull\n * expect<null>().toBe<null>().success\n * ```\n */\n toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<undefined>().toBeUndefined\n * expect<undefined>().toBe<undefined>().success\n * ```\n */\n toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = true`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<true>().toBeTrue\n * expect<true>().toBe<true>().success\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = false`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<false>().toBeFalse\n * expect<false>().toBe<false>().success\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Exact<T, any>, 'toBeAny'>\n | If<Exact<T, never>, 'toBeNever'>\n | If<Exact<T, unknown>, 'toBeUnknown'>\n | If<Exact<T, void>, 'toBeVoid'>\n | If<Exact<T, null>, 'toBeNull'>\n | If<Exact<T, undefined>, 'toBeUndefined'>\n | If<Exact<T, true>, 'toBeTrue'>\n | If<Exact<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n"]}
@@ -1,293 +0,0 @@
1
- import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../utils/index.js';
2
- /**
3
- * Represents the result of a type assertion based on a boolean condition.
4
- *
5
- * - If `true`, the result has a `success` property;
6
- * - If `false`, the result has a `fail` property;
7
- * - Otherwise, the result is `never`
8
- *
9
- * @template B The boolean condition result (true or false)
10
- * @template R The type of the result value (default is void)
11
- */
12
- export type TypeAssertionResult<B extends boolean, R = void> = Exact<B, never> extends true ? never : [boolean] extends [B] ? never : [B] extends [true] ? {
13
- /**
14
- * This field exist only when this type assertion succeed
15
- *
16
- * If you expect this assertion to fail, use `.fail`
17
- */
18
- success: R;
19
- } : [B] extends [false] ? {
20
- /**
21
- * This field exist only when this type assertion failed
22
- *
23
- * If you expect this assertion to success, use `.success`
24
- */
25
- fail: R;
26
- } : never;
27
- type ExpectTypeMethods<T, H extends PropertyKey = never> = {
28
- /**
29
- * Tests if the current type is exactly the same as the provided type U.
30
- *
31
- * @template U The type to compare with
32
- *
33
- * @example
34
- * ```ts
35
- * import { expect } from '@leawind/lay-sing'
36
- *
37
- * expect<any>().toBe<any>().success
38
- * expect<never>().toBe<never>().success
39
- * expect<false>().toBe<true>().fail
40
- * ```
41
- */
42
- toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
43
- toBe<U>(_: U): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
44
- /**
45
- * Tests if the current type is mutually assignable with the provided type U.
46
- *
47
- * It's like:
48
- *
49
- * ```ts ignore
50
- * [T] extends [U] ? [U] extends [T] ? Yes : No : No
51
- * ```
52
- *
53
- * @template U The type to compare with
54
- *
55
- * @example
56
- * ```ts
57
- * import { expect } from '@leawind/lay-sing'
58
- *
59
- * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
60
- * expect<1>().toEqual<1 | 2>().fail
61
- * ```
62
- */
63
- toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
64
- toEqual<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
65
- /**
66
- * Tests if the current type T extends the provided type U.
67
- *
68
- * @template U The type to check extension against
69
- *
70
- * @example
71
- * ```ts
72
- * import { expect } from '@leawind/lay-sing'
73
- *
74
- * expect<3.14>().toExtend<number>().success
75
- * expect<2>().toExtend<string>().fail
76
- * expect<'hello'>().toExtend<string>().success
77
- * ```
78
- */
79
- toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
80
- toExtend<U>(_: U): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
81
- /**
82
- * Tests if the current type T properly extends the provided type U (extends but is not the same).
83
- *
84
- * @template U The type to check proper extension against
85
- *
86
- * @example
87
- * ```ts
88
- * import { expect } from '@leawind/lay-sing'
89
- *
90
- * expect<2>().toProperExtend<number>().success
91
- * expect<'a' | 'b'>().toProperExtend<string>().success
92
- * expect<number>().toProperExtend<number>().fail
93
- * ```
94
- */
95
- toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
96
- toProperExtend<U>(_: U): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
97
- /**
98
- * Tests if the current type `T` has a property with key `K`.
99
- *
100
- * @template K The property key to check for
101
- *
102
- * ### Behavior
103
- *
104
- * - For single keys: succeeds if the key exists in `T`
105
- * - For union types: succeeds only if **all** keys in the union exist in `T`
106
- *
107
- * ### Examples
108
- *
109
- * ```ts
110
- * import { expect } from '@leawind/lay-sing'
111
- *
112
- * type WithProp = { prop: string; another: number; may?: 5 }
113
- *
114
- * // Single key checks
115
- * expect<WithProp>().toHaveKey<'prop'>().success
116
- * expect<WithProp>().toHaveKey<'missing'>().fail
117
- *
118
- * // Union type checks
119
- * expect<WithProp>().toHaveKey<'prop' | 'another'>().success
120
- * expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail
121
- * ```
122
- */
123
- toHaveKey<K extends PropertyKey>(): IfTupleIncludes<[
124
- never,
125
- any
126
- ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
127
- toHaveKey<K extends PropertyKey>(_: K): IfTupleIncludes<[
128
- never,
129
- any
130
- ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
131
- };
132
- type ExpectFunction<T, H extends PropertyKey = never> = Exact<T, any> extends true ? unknown : Exact<T, never> extends true ? unknown : [T] extends [(...args: infer Args) => infer R] ? {
133
- argsType(): ExpectType<Args, H>;
134
- returnType(): ExpectType<R, H>;
135
- } : [T] extends [new (...args: infer Args) => infer R] ? {
136
- argsType(): ExpectType<Args, H>;
137
- returnType(): ExpectType<R, H>;
138
- } : unknown;
139
- /**
140
- * Type-level testing utility that allows checking various relationships between types.
141
- * Provides methods to test type equality, extension, properties, and more.
142
- *
143
- * @template T The type being tested
144
- * @template H Hidden property keys that are already used (internal tracking)
145
- *
146
- * @example
147
- * ```ts
148
- * import { expect } from '@leawind/lay-sing'
149
- *
150
- * // Test if two types are identical
151
- * expect<number>().toBe<number>().success
152
- * expect<number>().toBe<string>().fail
153
- * // Test if one type extends another
154
- * expect<2>().toExtend<number>().success
155
- * expect<2>().toExtend<string>().fail
156
- * // Test if type has a specific property
157
- * expect<{name: string}>().toHaveKey<'name'>().success
158
- * ```
159
- */
160
- export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMethods<T, H> & ExpectFunction<T, H> & {
161
- T: T;
162
- inspect: {
163
- [K in keyof T]: T[K];
164
- };
165
- } & SafePick<{
166
- /**
167
- * Tests if the current type extends the Number primitive type.
168
- * Available only if the current type extends number.
169
- *
170
- * @example
171
- * ```ts
172
- * import { expect } from '@leawind/lay-sing'
173
- *
174
- * expect<3.14>().toExtendNumber
175
- * ```
176
- */
177
- toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>;
178
- /**
179
- * Tests if the current type extends the String primitive type.
180
- * Available only if the current type extends string.
181
- *
182
- * @example
183
- * ```ts
184
- * import { expect } from '@leawind/lay-sing'
185
- *
186
- * expect<'hello'>().toExtendString
187
- * ```
188
- */
189
- toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>;
190
- /**
191
- * Tests if the current type extends the Boolean primitive type.
192
- * Available only if the current type extends boolean.
193
- *
194
- * @example
195
- * ```ts
196
- * import { expect } from '@leawind/lay-sing'
197
- *
198
- * expect<true>().toExtendBoolean
199
- * ```
200
- */
201
- toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>;
202
- }, If<Extends<T, number>, 'toExtendNumber'> | If<Extends<T, string>, 'toExtendString'> | If<Extends<T, boolean>, 'toExtendBoolean'>> & SafePick<{
203
- /**
204
- * Alias for {@link ExpectTypeMethods.toBe} where `U = any`
205
- *
206
- * ```ts
207
- * import { expect } from '@leawind/lay-sing'
208
- *
209
- * expect<any>().toBeAny
210
- * expect<any>().toBe<any>().success
211
- * ```
212
- */
213
- toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>;
214
- /**
215
- * Alias for {@link ExpectTypeMethods.toBe} where `U = never`
216
- *
217
- * ```ts
218
- * import { expect } from '@leawind/lay-sing'
219
- *
220
- * expect<never>().toBeNever
221
- * expect<never>().toBe<never>().success
222
- * ```
223
- */
224
- toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>;
225
- /**
226
- * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`
227
- *
228
- * ```ts
229
- * import { expect } from '@leawind/lay-sing'
230
- *
231
- * expect<unknown>().toBeUnknown
232
- * expect<unknown>().toBe<unknown>().success
233
- * ```
234
- */
235
- toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>;
236
- /**
237
- * Alias for {@link ExpectTypeMethods.toBe} where `U = void`
238
- *
239
- * ```ts
240
- * import { expect } from '@leawind/lay-sing'
241
- *
242
- * expect<void>().toBeVoid
243
- * expect<void>().toBe<void>().success
244
- * ```
245
- */
246
- toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>;
247
- /**
248
- * Alias for {@link ExpectTypeMethods.toBe} where `U = null`
249
- *
250
- * ```ts
251
- * import { expect } from '@leawind/lay-sing'
252
- *
253
- * expect<null>().toBeNull
254
- * expect<null>().toBe<null>().success
255
- * ```
256
- */
257
- toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>;
258
- /**
259
- * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`
260
- *
261
- * ```ts
262
- * import { expect } from '@leawind/lay-sing'
263
- *
264
- * expect<undefined>().toBeUndefined
265
- * expect<undefined>().toBe<undefined>().success
266
- * ```
267
- */
268
- toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>;
269
- /**
270
- * Alias for {@link ExpectTypeMethods.toBe} where `U = true`
271
- *
272
- * ```ts
273
- * import { expect } from '@leawind/lay-sing'
274
- *
275
- * expect<true>().toBeTrue
276
- * expect<true>().toBe<true>().success
277
- * ```
278
- */
279
- toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>;
280
- /**
281
- * Alias for {@link ExpectTypeMethods.toBe} where `U = false`
282
- *
283
- * ```ts
284
- * import { expect } from '@leawind/lay-sing'
285
- *
286
- * expect<false>().toBeFalse
287
- * expect<false>().toBe<false>().success
288
- * ```
289
- */
290
- toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>;
291
- }, If<Exact<T, any>, 'toBeAny'> | If<Exact<T, never>, 'toBeNever'> | If<Exact<T, unknown>, 'toBeUnknown'> | If<Exact<T, void>, 'toBeVoid'> | If<Exact<T, null>, 'toBeNull'> | If<Exact<T, undefined>, 'toBeUndefined'> | If<Exact<T, true>, 'toBeTrue'> | If<Exact<T, false>, 'toBeFalse'>>), H>;
292
- export {};
293
- //# sourceMappingURL=expect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/main/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,EAAE,EACF,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,IAAI,GAAG,KAAK,GAC/F,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,GAC7B,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;IACnB;;;;OAIG;IACH,OAAO,EAAE,CAAC,CAAA;CACX,GACD,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG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AAC,EAAE,IAAI,CAAC,EAAE,UAAU,CAAC,GAC9B,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,CACnC,CACF,EACD,CAAC,CACF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/main/expect.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Exact,\n Extends,\n If,\n IfTupleIncludes,\n MutuallyAssignable,\n ProperExtend,\n SafePick,\n} from '../utils/index.js'\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n *\n * - If `true`, the result has a `success` property;\n * - If `false`, the result has a `fail` property;\n * - Otherwise, the result is `never`\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\nexport type TypeAssertionResult<B extends boolean, R = void> = Exact<B, never> extends true ? never\n : [boolean] extends [B] ? never\n : [B] extends [true] ? {\n /**\n * This field exist only when this type assertion succeed\n *\n * If you expect this assertion to fail, use `.fail`\n */\n success: R\n }\n : [B] extends [false] ? {\n /**\n * This field exist only when this type assertion failed\n *\n * If you expect this assertion to success, use `.success`\n */\n fail: R\n }\n : never\n\ntype ExpectTypeMethods<T, H extends PropertyKey = never> = {\n /**\n * Tests if the current type is exactly the same as the provided type U.\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>\n toBe<U>(_: U): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success\n * expect<1>().toEqual<1 | 2>().fail\n * ```\n */\n toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>\n toEqual<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>\n toExtend<U>(_: U): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>\n toProperExtend<U>(_: U): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type `T` has a property with key `K`.\n *\n * @template K The property key to check for\n *\n * ### Behavior\n *\n * - For single keys: succeeds if the key exists in `T`\n * - For union types: succeeds only if **all** keys in the union exist in `T`\n *\n * ### Examples\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type WithProp = { prop: string; another: number; may?: 5 }\n *\n * // Single key checks\n * expect<WithProp>().toHaveKey<'prop'>().success\n * expect<WithProp>().toHaveKey<'missing'>().fail\n *\n * // Union type checks\n * expect<WithProp>().toHaveKey<'prop' | 'another'>().success\n * expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail\n * ```\n */\n toHaveKey<K extends PropertyKey>(): IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>\n >\n toHaveKey<K extends PropertyKey>(_: K): IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>\n >\n}\n\ntype ExpectFunction<T, H extends PropertyKey = never> = Exact<T, any> extends true ? unknown\n : Exact<T, never> extends true ? unknown\n : [T] extends [(...args: infer Args) => infer R] ? {\n argsType(): ExpectType<Args, H>\n returnType(): ExpectType<R, H>\n }\n : [T] extends [new (...args: infer Args) => infer R] ? {\n argsType(): ExpectType<Args, H>\n returnType(): ExpectType<R, H>\n }\n : unknown\n\n/**\n * Type-level testing utility that allows checking various relationships between types.\n * Provides methods to test type equality, extension, properties, and more.\n *\n * @template T The type being tested\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * // Test if two types are identical\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<2>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * // Test if type has a specific property\n * expect<{name: string}>().toHaveKey<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & ExpectTypeMethods<T, H>\n & ExpectFunction<T, H>\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n }\n & SafePick<\n {\n /**\n * Tests if the current type extends the Number primitive type.\n * Available only if the current type extends number.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().toExtendNumber\n * ```\n */\n toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>\n\n /**\n * Tests if the current type extends the String primitive type.\n * Available only if the current type extends string.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<'hello'>().toExtendString\n * ```\n */\n toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>\n\n /**\n * Tests if the current type extends the Boolean primitive type.\n * Available only if the current type extends boolean.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<true>().toExtendBoolean\n * ```\n */\n toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>\n },\n | If<Extends<T, number>, 'toExtendNumber'>\n | If<Extends<T, string>, 'toExtendString'>\n | If<Extends<T, boolean>, 'toExtendBoolean'>\n >\n & SafePick<\n {\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = any`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<any>().toBeAny\n * expect<any>().toBe<any>().success\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = never`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<never>().toBeNever\n * expect<never>().toBe<never>().success\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<unknown>().toBeUnknown\n * expect<unknown>().toBe<unknown>().success\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = void`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<void>().toBeVoid\n * expect<void>().toBe<void>().success\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = null`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<null>().toBeNull\n * expect<null>().toBe<null>().success\n * ```\n */\n toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<undefined>().toBeUndefined\n * expect<undefined>().toBe<undefined>().success\n * ```\n */\n toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = true`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<true>().toBeTrue\n * expect<true>().toBe<true>().success\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = false`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<false>().toBeFalse\n * expect<false>().toBe<false>().success\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Exact<T, any>, 'toBeAny'>\n | If<Exact<T, never>, 'toBeNever'>\n | If<Exact<T, unknown>, 'toBeUnknown'>\n | If<Exact<T, void>, 'toBeVoid'>\n | If<Exact<T, null>, 'toBeNull'>\n | If<Exact<T, undefined>, 'toBeUndefined'>\n | If<Exact<T, true>, 'toBeTrue'>\n | If<Exact<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n"]}