lay-sing 0.1.1 → 0.1.2

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 (125) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +94 -79
  3. package/esm/main/array.d.ts +0 -0
  4. package/esm/main/array.d.ts.map +0 -0
  5. package/esm/main/array.js +0 -0
  6. package/esm/main/array.js.map +0 -0
  7. package/esm/main/async.d.ts +0 -0
  8. package/esm/main/async.d.ts.map +0 -0
  9. package/esm/main/async.js +0 -0
  10. package/esm/main/async.js.map +0 -0
  11. package/esm/main/boolean.d.ts +0 -0
  12. package/esm/main/boolean.d.ts.map +0 -0
  13. package/esm/main/boolean.js +0 -0
  14. package/esm/main/boolean.js.map +0 -0
  15. package/esm/main/control.d.ts +0 -0
  16. package/esm/main/control.d.ts.map +0 -0
  17. package/esm/main/control.js +0 -0
  18. package/esm/main/control.js.map +0 -0
  19. package/esm/main/doc.d.ts +0 -0
  20. package/esm/main/doc.d.ts.map +0 -0
  21. package/esm/main/doc.js +0 -0
  22. package/esm/main/doc.js.map +0 -0
  23. package/esm/main/function.d.ts +0 -0
  24. package/esm/main/function.d.ts.map +0 -0
  25. package/esm/main/function.js +0 -0
  26. package/esm/main/function.js.map +0 -0
  27. package/esm/main/index.d.ts +0 -0
  28. package/esm/main/index.d.ts.map +0 -0
  29. package/esm/main/index.js +0 -0
  30. package/esm/main/index.js.map +0 -0
  31. package/esm/main/json.d.ts +0 -0
  32. package/esm/main/json.d.ts.map +0 -0
  33. package/esm/main/json.js +0 -0
  34. package/esm/main/json.js.map +0 -0
  35. package/esm/main/key.d.ts +0 -0
  36. package/esm/main/key.d.ts.map +0 -0
  37. package/esm/main/key.js +0 -0
  38. package/esm/main/key.js.map +0 -0
  39. package/esm/main/object.d.ts +0 -0
  40. package/esm/main/object.d.ts.map +0 -0
  41. package/esm/main/object.js +0 -0
  42. package/esm/main/object.js.map +0 -0
  43. package/esm/main/type/compare.d.ts +0 -0
  44. package/esm/main/type/compare.d.ts.map +0 -0
  45. package/esm/main/type/compare.js +0 -0
  46. package/esm/main/type/compare.js.map +0 -0
  47. package/esm/main/type/index.d.ts +0 -0
  48. package/esm/main/type/index.d.ts.map +0 -0
  49. package/esm/main/type/index.js +0 -0
  50. package/esm/main/type/index.js.map +0 -0
  51. package/esm/main/type/set.d.ts +0 -0
  52. package/esm/main/type/set.d.ts.map +0 -0
  53. package/esm/main/type/set.js +0 -0
  54. package/esm/main/type/set.js.map +0 -0
  55. package/esm/main/typed-array.d.ts +0 -0
  56. package/esm/main/typed-array.d.ts.map +0 -0
  57. package/esm/main/typed-array.js +0 -0
  58. package/esm/main/typed-array.js.map +0 -0
  59. package/esm/package.json +0 -0
  60. package/esm/test-utils.d.ts +0 -0
  61. package/esm/test-utils.d.ts.map +1 -1
  62. package/esm/test-utils.js +8 -0
  63. package/esm/test-utils.js.map +1 -1
  64. package/package.json +2 -2
  65. package/script/main/array.d.ts +0 -0
  66. package/script/main/array.d.ts.map +0 -0
  67. package/script/main/array.js +0 -0
  68. package/script/main/array.js.map +0 -0
  69. package/script/main/async.d.ts +0 -0
  70. package/script/main/async.d.ts.map +0 -0
  71. package/script/main/async.js +0 -0
  72. package/script/main/async.js.map +0 -0
  73. package/script/main/boolean.d.ts +0 -0
  74. package/script/main/boolean.d.ts.map +0 -0
  75. package/script/main/boolean.js +0 -0
  76. package/script/main/boolean.js.map +0 -0
  77. package/script/main/control.d.ts +0 -0
  78. package/script/main/control.d.ts.map +0 -0
  79. package/script/main/control.js +0 -0
  80. package/script/main/control.js.map +0 -0
  81. package/script/main/doc.d.ts +0 -0
  82. package/script/main/doc.d.ts.map +0 -0
  83. package/script/main/doc.js +0 -0
  84. package/script/main/doc.js.map +0 -0
  85. package/script/main/function.d.ts +0 -0
  86. package/script/main/function.d.ts.map +0 -0
  87. package/script/main/function.js +0 -0
  88. package/script/main/function.js.map +0 -0
  89. package/script/main/index.d.ts +0 -0
  90. package/script/main/index.d.ts.map +0 -0
  91. package/script/main/index.js +0 -0
  92. package/script/main/index.js.map +0 -0
  93. package/script/main/json.d.ts +0 -0
  94. package/script/main/json.d.ts.map +0 -0
  95. package/script/main/json.js +0 -0
  96. package/script/main/json.js.map +0 -0
  97. package/script/main/key.d.ts +0 -0
  98. package/script/main/key.d.ts.map +0 -0
  99. package/script/main/key.js +0 -0
  100. package/script/main/key.js.map +0 -0
  101. package/script/main/object.d.ts +0 -0
  102. package/script/main/object.d.ts.map +0 -0
  103. package/script/main/object.js +0 -0
  104. package/script/main/object.js.map +0 -0
  105. package/script/main/type/compare.d.ts +0 -0
  106. package/script/main/type/compare.d.ts.map +0 -0
  107. package/script/main/type/compare.js +0 -0
  108. package/script/main/type/compare.js.map +0 -0
  109. package/script/main/type/index.d.ts +0 -0
  110. package/script/main/type/index.d.ts.map +0 -0
  111. package/script/main/type/index.js +0 -0
  112. package/script/main/type/index.js.map +0 -0
  113. package/script/main/type/set.d.ts +0 -0
  114. package/script/main/type/set.d.ts.map +0 -0
  115. package/script/main/type/set.js +0 -0
  116. package/script/main/type/set.js.map +0 -0
  117. package/script/main/typed-array.d.ts +0 -0
  118. package/script/main/typed-array.d.ts.map +0 -0
  119. package/script/main/typed-array.js +0 -0
  120. package/script/main/typed-array.js.map +0 -0
  121. package/script/package.json +0 -0
  122. package/script/test-utils.d.ts +0 -0
  123. package/script/test-utils.d.ts.map +1 -1
  124. package/script/test-utils.js +8 -0
  125. package/script/test-utils.js.map +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2025 Leawind <leawind@yeah.net>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Leawind <leawind@yeah.net>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  | English | [简体中文](./README-zh.md) |
2
2
  | ------- | -------------------------- |
3
- | | |
4
3
 
5
4
  # `lay-sing`
6
5
 
7
- TypeScript utilities for compile-time type validation and testing
6
+ TypeScript utilities for compile-time type testing and utility types
8
7
 
9
8
  ## What is it
10
9
 
@@ -12,14 +11,16 @@ TypeScript utilities for compile-time type validation and testing
12
11
 
13
12
  ```ts
14
13
  // They do nothing at runtime
15
- expect<number>().toBe<number>().success
16
- expect<number>().toBe<string>().fail
14
+ expect<never>().toBe<never>().success
15
+ expect<never>().toBeNever // alias for above
16
+ expect<never>().toBe<'should fail'>().fail
17
17
 
18
- // Type error: Property 'success' does not exist on type '{ fail: void; }'.
19
- expect<number>().toBe<string>().success
18
+ // Type Error: Property 'success' does not exist on type '{ fail: void; }'.
19
+ expect<never>().toBe<'should fail'>().success
20
+ // ^^^^^^^
20
21
  ```
21
22
 
22
- 2. **Type Manipulation Tools**
23
+ 1. **Type Manipulation Tools**
23
24
 
24
25
  ```ts
25
26
  // Result is 'Bob'
@@ -32,78 +33,94 @@ type Result = Switch<2, [
32
33
 
33
34
  ## Install
34
35
 
35
- (#TODO)
36
+ > This lib is published to both [NPM](https://www.npmjs.com/package/lay-sing) and [JSR](https://jsr.io/@leawind/lay-sing)
36
37
 
37
- ## Testing Utilities
38
+ ### NPM
38
39
 
39
- The `test-utils` module provides type-level testing utilities for compile-time type validation.
40
+ ```sh
41
+ npm i -D lay-sing
42
+ ```
40
43
 
41
- ### Type Expectations
44
+ ```ts
45
+ import type { Same } from 'lay-sing'
46
+ import { expect } from 'lay-sing/test-utils'
47
+ ```
42
48
 
43
- The `expect` function provides a fluent API for type-level assertions:
49
+ ### Deno (JSR)
50
+
51
+ ```sh
52
+ deno add jsr:@leawind/lay-sing
53
+ ```
44
54
 
45
55
  ```ts
46
- // Test if two types are identical
47
- expect<number>().toBe<number>().success
48
- expect<number>().toBe<string>().fail
56
+ import type { Same } from '@leawind/lay-sing'
57
+ import { expect } from '@leawind/lay-sing/test-utils'
58
+ ```
49
59
 
50
- // Test if one type extends another
51
- expect<2>().toExtend<number>().success
52
- expect<2>().toExtend<string>().fail
60
+ Or Import directly:
53
61
 
54
- // Test if type has a specific property
55
- expect<{ name: string }>().toHaveProperty<'name'>().success
62
+ ```ts
63
+ import type { Same } from 'jsr:@leawind/lay-sing@^0.1'
64
+ import { expect } from 'jsr:@leawind/lay-sing@^0.1/test-utils'
65
+ ```
56
66
 
57
- // Test primitive types
58
- expect<'hello'>().toExtendString.success
59
- expect<true>().toExtendBoolean.success
67
+ ---
68
+
69
+ ## Usage
70
+
71
+ ### Testing Utilities
72
+
73
+ ```ts
74
+ import { compare, expect, NOOP } from 'lay-sing/test-utils'
60
75
  ```
61
76
 
62
- Available assertion methods:
77
+ The `test-utils` module provides utilities for **compile-time** type validation. These utilities have **no runtime effect** — they always return a special [`NOOP`](https://jsr.io/@leawind/lay-sing/doc/test-utils/~/NOOP) value that safely supports almost any property access or method call.
78
+
79
+ A typical type test statement follows this pattern:
63
80
 
64
- - `toBe<U>()` - Tests exact type equality
65
- - `toExtend<U>()` - Tests if type extends another
66
- - `toProperExtend<U>()` - Tests if type properly extends another (extends but is not the same)
67
- - `toHaveProperty<K>()` - Tests if type has a property with key K
68
- - `toExtendNumber` - Tests if type extends the Number primitive (available only when type extends number)
69
- - `toExtendString` - Tests if type extends the String primitive (available only when type extends string)
70
- - `toExtendBoolean` - Tests if type extends the Boolean primitive (available only when type extends boolean)
71
- - Specific primitive type checks: `toBeAny`, `toBeNever`, `toBeUnknown`, `toBeVoid`, `toBeTrue`, `toBeFalse`
81
+ ```ts
82
+ expect<ActualType>().toBe<ExpectedType>().success
83
+ ```
72
84
 
73
- ### Type Comparisons
85
+ - It starts with a function call like `expect<T>()` or `compare<T, U>()`
86
+ - It ends with a property like `.success` or `.fail`
87
+ - A **type error occurs only if the assertion fails**, helping you catch incorrect types at compile time
88
+ - At runtime, the function always returns the actual value `NOOP`, which performs **no operation**. It can be accessed, called, or chained indefinitely without throwing
74
89
 
75
- The `compare` function allows for sophisticated type-to-type relationship testing:
90
+ #### Common Usage
76
91
 
77
92
  ```ts
78
- // Check if two types are the same
79
- compare<number, number>().same // Available
93
+ // Exact equality
94
+ expect<A>().toBe<B>().success // Passes only if A and B are identical
80
95
 
81
- // Check if two types are different
82
- compare<number, string>().different // Available
96
+ // Subtype check
97
+ expect<A>().toExtend<B>().success // Passes if A extends B
83
98
 
84
- // Check if two types overlap
85
- compare<4, number>().overlap.different // Available
99
+ // Property existence
100
+ expect<{ name: string }>().toHaveProperty<'name'>().success
86
101
 
87
- // Check if two types are disjoint
88
- compare<4, 'abc'>().different.disjoint // Available
102
+ // Primitive checks
103
+ expect<true>().toBeTrue.success
104
+ expect<'hello'>().toExtendString.success
89
105
 
90
- // Check if two types are mutually assignable
91
- compare<1 | 2, 1 | 2>().mutuallyAssignable // Available
106
+ // Type comparison
107
+ compare<A, B>().same // Available only if A ≡ B
108
+ compare<A, B>().different // Available only if A ≠ B
92
109
  ```
93
110
 
94
- Available comparison methods:
95
-
96
- - `same` - Available when types are exactly the same
97
- - `different` - Available when types are different
98
- - `overlap` - Available when types have some overlap
99
- - `disjoint` - Available when types have no overlap
100
- - `mutuallyAssignable` - Available when types are mutually assignable
111
+ > [!TIP]
112
+ >
113
+ > There's no need to memorize the full API.
114
+ >
115
+ > Your editor will show inline documentation and auto-completion for all available methods and properties
101
116
 
102
- These utilities are invaluable for creating type-level tests that validate your type definitions at compile time.
117
+ #### NOOP
103
118
 
104
- ### NOOP Placeholder
119
+ A `Proxy`-based no-op object:
105
120
 
106
- A universal no-op placeholder implemented via `Proxy`. `NOOP` can be accessed, called, or chained indefinitely without throwing. Every operation returns itself, making it safe to use as a dummy fallback for APIs, optional hooks, or unimplemented interfaces.
121
+ - Most accesses return itself.
122
+ - `toString()` returns `"[NOOP]"`.
123
+ - Not thenable (`then` is `undefined`).
107
124
 
108
125
  ```ts
109
126
  NOOP.foo.bar().baz.qux // safe, returns NOOP
@@ -111,41 +128,39 @@ String(NOOP) // "[NOOP]"
111
128
  await NOOP // does not await (not thenable)
112
129
  ```
113
130
 
114
- ## Type Tools
131
+ ### Type Tools
115
132
 
116
- Here are some of type tools:
133
+ The main entry point provides a collection of utility types for common type-level programming tasks. All types are flat-exported from the main entry point — you don’t need to import from deep paths.
117
134
 
118
- ### Conditional Types
119
-
120
- ```typescript
121
- type Result = If<true, 'yes', 'no'> // 'yes'
122
- type Conditional = If<boolean, 'yes', 'no'> // 'yes' | 'no'
135
+ ```ts
136
+ import type { Same } from 'lay-sing'
123
137
  ```
124
138
 
125
- ### Boolean Operations
139
+ > All types are documented — your editor will show inline documentation on hover
140
+
141
+ ### Examples
126
142
 
127
143
  ```typescript
128
- type IsTrue = And<true, true> // true
129
- type IsFalse = And<true, false> // false
130
- type Either = Or<true, false> // true
131
- type Negation = Not<true> // false
132
- ```
144
+ // Conditional Types
145
+ type Result = If<true, 'yes', 'no'> // 'yes'
133
146
 
134
- ### Array/Tuple Operations
147
+ // Boolean Logic
148
+ type IsTrue = And<true, true> // true
135
149
 
136
- ```typescript
150
+ // Tuple Manipulation
137
151
  type Combined = ConcatTuple<[1, 2], [3, 4]> // [1, 2, 3, 4]
138
- type UniqueCombined = ConcatUniqueTuple<[1, 2, 3], [2, 3, 4]> // [1, 2, 3, 4]
139
- type HasElement = TupleIncludes<[1, 2, 3], 2> // true
140
- ```
141
-
142
- ### Object Manipulation
143
152
 
144
- ```typescript
145
- type PartialObj = DeepPartial<{ a: string; nested: { b: number } }> // { a?: string; nested?: { b?: number } }
146
- type PickedProps = PropsOfType<{ a: string; b: number; c: string }, string> // { a: string; c: string }
153
+ // Object Utilities
154
+ type PartialObj = DeepPartial<{ a: string; nested: { b: number } }>
155
+ // { a?: string; nested?: { b?: number } }
147
156
  ```
148
157
 
149
- ## Name
158
+ > [!NOTE]
159
+ >
160
+ > [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
161
+
162
+ ---
150
163
 
151
- The name "lay-sing" (pronounced /leɪ sɪŋ/) is phonetically similar to the Chinese word "类型" (pinyin: lèi xíng), which translates to "type" in English.
164
+ > ## _Pronunciation of lay-sing_
165
+ >
166
+ > _"lay-sing" mimics Mandarin "lèi xíng" ("type") — Say "LAY-sing" with a sharp "LAY" (like a command) followed by a rising "sing" (like a question)._
File without changes
File without changes
package/esm/main/array.js CHANGED
File without changes
File without changes
File without changes
File without changes
package/esm/main/async.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/esm/main/doc.d.ts CHANGED
File without changes
File without changes
package/esm/main/doc.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/esm/main/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
package/esm/main/json.js CHANGED
File without changes
File without changes
package/esm/main/key.d.ts CHANGED
File without changes
File without changes
package/esm/main/key.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/esm/package.json CHANGED
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,EAAE,EACF,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,IAAI,EACL,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI,EAAE,GAkBlB,CAAA;AAED;;;;;;GAMG;AACH,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG;IAC7D;;OAEG;IACH,OAAO,EAAE,CAAC,CAAA;CACX,GACC;IACA;;OAEG;IACH,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAEH;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,
43
+ getOwnPropertyDescriptor: () => ({
44
+ configurable: true,
45
+ value: NOOP,
46
+ }),
47
+ getPrototypeOf: () => null,
48
+ has: () => true,
49
+ ownKeys: () => ['prototype'],
42
50
  });
43
51
  export function expect() {
44
52
  return NOOP;
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAQ,IAAI,KAAK,CAChC;IACE,OAAO,IAAI,CAAA;AACb,CAAC,EACD;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,SAAS,CAAA;YAClB,KAAK,SAAS,CAAC;YACf,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC,WAAW;gBACrB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAA;YACvB;gBACE,OAAO,IAAI,CAAA;QACf,CAAC;IACH,CAAC;CACF,CACF,CAAA;AAkQD,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,CAAA;AACb,CAAC;AA+GD,MAAM,UAAU,OAAO;IACrB,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// deno-lint-ignore-file no-explicit-any\nimport type {\n Diff,\n Disjoint,\n Extends,\n If,\n MutuallyAssignable,\n Overlap,\n ProperExtend,\n SafePick,\n Same,\n} from './main/index.js'\n\n/**\n * A universal no-op placeholder implemented via `Proxy`.\n *\n * `NOOP` can be accessed, called, or chained indefinitely without throwing.\n * Every operation returns itself, making it safe to use as a dummy fallback\n * for APIs, optional hooks, or unimplemented interfaces.\n *\n * ### Special behaviors\n *\n * - Callable: invoking `NOOP()` returns `NOOP`\n * - Property access: `NOOP.anything` returns `NOOP`\n * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise\n * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields\n * a stable string representation: `\"[NOOP]\"`\n *\n * This is useful in scenarios where a value is required syntactically but\n * should perform no action and never fail at runtime.\n *\n * ### Examples\n *\n * ```ts\n * NOOP.foo.bar().baz.qux; // safe, returns NOOP\n * String(NOOP); // \"[NOOP]\"\n * await NOOP; // does not await (not thenable)\n * ```\n */\nexport const NOOP: any = new Proxy(\n function () {\n return NOOP\n },\n {\n get(_, prop) {\n switch (prop) {\n case 'then':\n return undefined\n case 'valueOf':\n case 'toString':\n case Symbol.toPrimitive:\n return () => '[NOOP]'\n default:\n return NOOP\n }\n },\n },\n)\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n * If the condition is true, the result has a `success` property; otherwise, it has a `fail` property.\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\ntype Result<B extends true | false, R = void> = B extends true ? {\n /**\n * ## Expect to succeed without type error\n */\n success: R\n }\n : {\n /**\n * ## Expect to fail with type error\n */\n fail: R\n }\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 * ### Examples\n *\n * ```ts\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}>().toHaveProperty<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n\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 * ### Examples\n *\n * ```ts\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): Result<Same<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): Result<Extends<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): Result<ProperExtend<T, U>>\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 * ### Examples\n *\n * ```ts\n * type WithProp = { prop: string; another: number }\n * expect<WithProp>().toHaveProperty<'prop'>().success\n * expect<WithProp>().toHaveProperty<'another'>().success\n * expect<WithProp>().toHaveProperty<'missing'>().fail\n * ```\n */\n toHaveProperty<K extends PropertyKey>(): Result<Extends<K, keyof T>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtendNumber // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<'hello'>().toExtendString // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<true>().toExtendBoolean // Available and would succeed\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 * Tests if the current type is exactly `any`.\n * Available only if the current type is `any`.\n *\n * ### Examples\n *\n * ```ts\n * expect<any>().toBeAny // Available and would succeed\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `never`.\n * Available only if the current type is `never`.\n *\n * ### Examples\n *\n * ```ts\n * expect<never>().toBeNever // Available and would succeed\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `unknown`.\n * Available only if the current type is `unknown`.\n *\n * ### Examples\n *\n * ```ts\n * expect<unknown>().toBeUnknown // Available and would succeed\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `void`.\n * Available only if the current type is `void`.\n *\n * ### Examples\n *\n * ```ts\n * expect<void>().toBeVoid // Available and would succeed\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `true` (boolean literal).\n * Available only if the current type is `true`.\n *\n * ### Examples\n *\n * ```ts\n * expect<true>().toBeTrue // Available and would succeed\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Tests if the current type is exactly `false` (boolean literal).\n * Available only if the current type is `false`.\n *\n * ### Examples\n *\n * ```ts\n * expect<false>().toBeFalse // Available and would succeed\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Same<T, any>, 'toBeAny'>\n | If<Same<T, never>, 'toBeNever'>\n | If<Same<T, unknown>, 'toBeUnknown'>\n | If<Same<T, void>, 'toBeVoid'>\n | If<Same<T, true>, 'toBeTrue'>\n | If<Same<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n\n/**\n * Creates an instance of ExpectType to perform type-level assertions on the given type.\n * This function enables testing various type relationships at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T The type to be tested\n *\n * @returns An ExpectType instance with methods to test type relationships\n *\n * ### Examples\n *\n * ```ts\n * // Test exact type equality\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * ```\n */\nexport function expect<T>(): ExpectType<T>\nexport function expect<T>(_: T): ExpectType<T>\nexport function expect<T>(): ExpectType<T> {\n return NOOP\n}\n\n/**\n * Type-level utility that compares two types and provides methods to test their relationship.\n * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.\n *\n * @template T First type to compare\n * @template U Second type to compare\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * ### Examples\n *\n * ```ts\n * // Check if two types are the same\n * compare<number, number>().same // Available\n * // Check if two types are different\n * compare<number, string>().different // Available\n * // Check if two types overlap\n * compare<4, number>().overlap.different // Available\n * ```\n */\nexport type CompareTypes<T, U, H extends PropertyKey = never> = Omit<\n SafePick<\n {\n /**\n * Available when types T and U are exactly the same.\n *\n * ### Examples\n *\n * ```ts\n * compare<3, 3>().same // Available\n * compare<boolean, boolean>().same // Available\n * ```\n */\n same: CompareTypes<T, U, H | 'same'>\n\n /**\n * Available when types T and U are different.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different // Available\n * compare<number, 4>().different // Available\n * ```\n */\n different: CompareTypes<T, U, H | 'different'>\n\n /**\n * Available when types T and U have some overlap.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, number>().overlap // Available since 4 overlaps with number\n * ```\n */\n overlap: CompareTypes<T, U, H | 'overlap'>\n\n /**\n * Available when types T and U have no overlap (are disjoint).\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint\n * ```\n */\n disjoint: CompareTypes<T, U, H | 'disjoint'>\n\n /**\n * Available when types T and U are mutually assignable (each type can be assigned to the other).\n *\n * ### Examples\n *\n * ```ts\n * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable\n * ```\n */\n mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>\n },\n | If<Same<T, U>, 'same'>\n | If<Diff<T, U>, 'different'>\n | If<Overlap<T, U>, 'overlap'>\n | If<Disjoint<T, U>, 'disjoint'>\n | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>\n >,\n H\n>\n\n/**\n * Creates an instance of CompareTypes to perform type-level comparisons between two types.\n * This function enables testing various relationships between types at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T First type to compare\n * @template U Second type to compare\n *\n * @returns A CompareTypes instance with methods to test relationships between T and U\n *\n * ### Examples\n *\n * ```ts\n * // Compare two identical types\n * compare<number, number>().same // Results in an available property\n * // Compare two different but overlapping types\n * compare<4, number>().overlap.different // Results in available properties\n * ```\n */\nexport function compare<T, U>(): CompareTypes<T, U>\nexport function compare<T, U>(t: T, u: U): CompareTypes<T, U>\nexport function compare<T, U>(): CompareTypes<T, U> {\n return NOOP\n}\n"]}
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAQ,IAAI,KAAK,CAChC;IACE,OAAO,IAAI,CAAA;AACb,CAAC,EACD;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,SAAS,CAAA;YAClB,KAAK,SAAS,CAAC;YACf,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC,WAAW;gBACrB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAA;YACvB;gBACE,OAAO,IAAI,CAAA;QACf,CAAC;IACH,CAAC;IACD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,IAAI;KACZ,CAAC;IACF,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;IAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC;CAC7B,CACF,CAAA;AAkQD,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,CAAA;AACb,CAAC;AA+GD,MAAM,UAAU,OAAO;IACrB,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// deno-lint-ignore-file no-explicit-any\nimport type {\n Diff,\n Disjoint,\n Extends,\n If,\n MutuallyAssignable,\n Overlap,\n ProperExtend,\n SafePick,\n Same,\n} from './main/index.js'\n\n/**\n * A universal no-op placeholder implemented via `Proxy`.\n *\n * `NOOP` can be accessed, called, or chained indefinitely without throwing.\n * Every operation returns itself, making it safe to use as a dummy fallback\n * for APIs, optional hooks, or unimplemented interfaces.\n *\n * ### Special behaviors\n *\n * - Callable: invoking `NOOP()` returns `NOOP`\n * - Property access: `NOOP.anything` returns `NOOP`\n * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise\n * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields\n * a stable string representation: `\"[NOOP]\"`\n *\n * This is useful in scenarios where a value is required syntactically but\n * should perform no action and never fail at runtime.\n *\n * ### Examples\n *\n * ```ts\n * NOOP.foo.bar().baz.qux; // safe, returns NOOP\n * String(NOOP); // \"[NOOP]\"\n * await NOOP; // does not await (not thenable)\n * ```\n */\nexport const NOOP: any = new Proxy(\n function () {\n return NOOP\n },\n {\n get(_, prop) {\n switch (prop) {\n case 'then':\n return undefined\n case 'valueOf':\n case 'toString':\n case Symbol.toPrimitive:\n return () => '[NOOP]'\n default:\n return NOOP\n }\n },\n set: () => true,\n getOwnPropertyDescriptor: () => ({\n configurable: true,\n value: NOOP,\n }),\n getPrototypeOf: () => null,\n has: () => true,\n ownKeys: () => ['prototype'],\n },\n)\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n * If the condition is true, the result has a `success` property; otherwise, it has a `fail` property.\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\ntype Result<B extends true | false, R = void> = B extends true ? {\n /**\n * ## Expect to succeed without type error\n */\n success: R\n }\n : {\n /**\n * ## Expect to fail with type error\n */\n fail: R\n }\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 * ### Examples\n *\n * ```ts\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}>().toHaveProperty<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n\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 * ### Examples\n *\n * ```ts\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): Result<Same<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): Result<Extends<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): Result<ProperExtend<T, U>>\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 * ### Examples\n *\n * ```ts\n * type WithProp = { prop: string; another: number }\n * expect<WithProp>().toHaveProperty<'prop'>().success\n * expect<WithProp>().toHaveProperty<'another'>().success\n * expect<WithProp>().toHaveProperty<'missing'>().fail\n * ```\n */\n toHaveProperty<K extends PropertyKey>(): Result<Extends<K, keyof T>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtendNumber // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<'hello'>().toExtendString // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<true>().toExtendBoolean // Available and would succeed\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 * Tests if the current type is exactly `any`.\n * Available only if the current type is `any`.\n *\n * ### Examples\n *\n * ```ts\n * expect<any>().toBeAny // Available and would succeed\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `never`.\n * Available only if the current type is `never`.\n *\n * ### Examples\n *\n * ```ts\n * expect<never>().toBeNever // Available and would succeed\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `unknown`.\n * Available only if the current type is `unknown`.\n *\n * ### Examples\n *\n * ```ts\n * expect<unknown>().toBeUnknown // Available and would succeed\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `void`.\n * Available only if the current type is `void`.\n *\n * ### Examples\n *\n * ```ts\n * expect<void>().toBeVoid // Available and would succeed\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `true` (boolean literal).\n * Available only if the current type is `true`.\n *\n * ### Examples\n *\n * ```ts\n * expect<true>().toBeTrue // Available and would succeed\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Tests if the current type is exactly `false` (boolean literal).\n * Available only if the current type is `false`.\n *\n * ### Examples\n *\n * ```ts\n * expect<false>().toBeFalse // Available and would succeed\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Same<T, any>, 'toBeAny'>\n | If<Same<T, never>, 'toBeNever'>\n | If<Same<T, unknown>, 'toBeUnknown'>\n | If<Same<T, void>, 'toBeVoid'>\n | If<Same<T, true>, 'toBeTrue'>\n | If<Same<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n\n/**\n * Creates an instance of ExpectType to perform type-level assertions on the given type.\n * This function enables testing various type relationships at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T The type to be tested\n *\n * @returns An ExpectType instance with methods to test type relationships\n *\n * ### Examples\n *\n * ```ts\n * // Test exact type equality\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * ```\n */\nexport function expect<T>(): ExpectType<T>\nexport function expect<T>(_: T): ExpectType<T>\nexport function expect<T>(): ExpectType<T> {\n return NOOP\n}\n\n/**\n * Type-level utility that compares two types and provides methods to test their relationship.\n * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.\n *\n * @template T First type to compare\n * @template U Second type to compare\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * ### Examples\n *\n * ```ts\n * // Check if two types are the same\n * compare<number, number>().same // Available\n * // Check if two types are different\n * compare<number, string>().different // Available\n * // Check if two types overlap\n * compare<4, number>().overlap.different // Available\n * ```\n */\nexport type CompareTypes<T, U, H extends PropertyKey = never> = Omit<\n SafePick<\n {\n /**\n * Available when types T and U are exactly the same.\n *\n * ### Examples\n *\n * ```ts\n * compare<3, 3>().same // Available\n * compare<boolean, boolean>().same // Available\n * ```\n */\n same: CompareTypes<T, U, H | 'same'>\n\n /**\n * Available when types T and U are different.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different // Available\n * compare<number, 4>().different // Available\n * ```\n */\n different: CompareTypes<T, U, H | 'different'>\n\n /**\n * Available when types T and U have some overlap.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, number>().overlap // Available since 4 overlaps with number\n * ```\n */\n overlap: CompareTypes<T, U, H | 'overlap'>\n\n /**\n * Available when types T and U have no overlap (are disjoint).\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint\n * ```\n */\n disjoint: CompareTypes<T, U, H | 'disjoint'>\n\n /**\n * Available when types T and U are mutually assignable (each type can be assigned to the other).\n *\n * ### Examples\n *\n * ```ts\n * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable\n * ```\n */\n mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>\n },\n | If<Same<T, U>, 'same'>\n | If<Diff<T, U>, 'different'>\n | If<Overlap<T, U>, 'overlap'>\n | If<Disjoint<T, U>, 'disjoint'>\n | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>\n >,\n H\n>\n\n/**\n * Creates an instance of CompareTypes to perform type-level comparisons between two types.\n * This function enables testing various relationships between types at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T First type to compare\n * @template U Second type to compare\n *\n * @returns A CompareTypes instance with methods to test relationships between T and U\n *\n * ### Examples\n *\n * ```ts\n * // Compare two identical types\n * compare<number, number>().same // Results in an available property\n * // Compare two different but overlapping types\n * compare<4, number>().overlap.different // Results in available properties\n * ```\n */\nexport function compare<T, U>(): CompareTypes<T, U>\nexport function compare<T, U>(t: T, u: U): CompareTypes<T, U>\nexport function compare<T, U>(): CompareTypes<T, U> {\n return NOOP\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lay-sing",
3
- "version": "0.1.1",
4
- "description": "TypeScript utilities for compile-time type validation and testing",
3
+ "version": "0.1.2",
4
+ "description": "Utilities for compile-time type testing and utility types",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Leawind/lay-sing.git"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,EAAE,EACF,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,IAAI,EACL,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI,EAAE,GAkBlB,CAAA;AAED;;;;;;GAMG;AACH,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,IAAI,GAAG;IAC7D;;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@@ -44,6 +44,14 @@ exports.NOOP = new Proxy(function () {
44
44
  return exports.NOOP;
45
45
  }
46
46
  },
47
+ set: () => true,
48
+ getOwnPropertyDescriptor: () => ({
49
+ configurable: true,
50
+ value: exports.NOOP,
51
+ }),
52
+ getPrototypeOf: () => null,
53
+ has: () => true,
54
+ ownKeys: () => ['prototype'],
47
55
  });
48
56
  function expect() {
49
57
  return exports.NOOP;
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":";;;AA2TA,wBAEC;AA+GD,0BAEC;AAjaD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,IAAI,GAAQ,IAAI,KAAK,CAChC;IACE,OAAO,YAAI,CAAA;AACb,CAAC,EACD;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,SAAS,CAAA;YAClB,KAAK,SAAS,CAAC;YACf,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC,WAAW;gBACrB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAA;YACvB;gBACE,OAAO,YAAI,CAAA;QACf,CAAC;IACH,CAAC;CACF,CACF,CAAA;AAkQD,SAAgB,MAAM;IACpB,OAAO,YAAI,CAAA;AACb,CAAC;AA+GD,SAAgB,OAAO;IACrB,OAAO,YAAI,CAAA;AACb,CAAC","sourcesContent":["// deno-lint-ignore-file no-explicit-any\nimport type {\n Diff,\n Disjoint,\n Extends,\n If,\n MutuallyAssignable,\n Overlap,\n ProperExtend,\n SafePick,\n Same,\n} from './main/index.js'\n\n/**\n * A universal no-op placeholder implemented via `Proxy`.\n *\n * `NOOP` can be accessed, called, or chained indefinitely without throwing.\n * Every operation returns itself, making it safe to use as a dummy fallback\n * for APIs, optional hooks, or unimplemented interfaces.\n *\n * ### Special behaviors\n *\n * - Callable: invoking `NOOP()` returns `NOOP`\n * - Property access: `NOOP.anything` returns `NOOP`\n * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise\n * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields\n * a stable string representation: `\"[NOOP]\"`\n *\n * This is useful in scenarios where a value is required syntactically but\n * should perform no action and never fail at runtime.\n *\n * ### Examples\n *\n * ```ts\n * NOOP.foo.bar().baz.qux; // safe, returns NOOP\n * String(NOOP); // \"[NOOP]\"\n * await NOOP; // does not await (not thenable)\n * ```\n */\nexport const NOOP: any = new Proxy(\n function () {\n return NOOP\n },\n {\n get(_, prop) {\n switch (prop) {\n case 'then':\n return undefined\n case 'valueOf':\n case 'toString':\n case Symbol.toPrimitive:\n return () => '[NOOP]'\n default:\n return NOOP\n }\n },\n },\n)\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n * If the condition is true, the result has a `success` property; otherwise, it has a `fail` property.\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\ntype Result<B extends true | false, R = void> = B extends true ? {\n /**\n * ## Expect to succeed without type error\n */\n success: R\n }\n : {\n /**\n * ## Expect to fail with type error\n */\n fail: R\n }\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 * ### Examples\n *\n * ```ts\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}>().toHaveProperty<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n\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 * ### Examples\n *\n * ```ts\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): Result<Same<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): Result<Extends<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): Result<ProperExtend<T, U>>\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 * ### Examples\n *\n * ```ts\n * type WithProp = { prop: string; another: number }\n * expect<WithProp>().toHaveProperty<'prop'>().success\n * expect<WithProp>().toHaveProperty<'another'>().success\n * expect<WithProp>().toHaveProperty<'missing'>().fail\n * ```\n */\n toHaveProperty<K extends PropertyKey>(): Result<Extends<K, keyof T>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtendNumber // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<'hello'>().toExtendString // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<true>().toExtendBoolean // Available and would succeed\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 * Tests if the current type is exactly `any`.\n * Available only if the current type is `any`.\n *\n * ### Examples\n *\n * ```ts\n * expect<any>().toBeAny // Available and would succeed\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `never`.\n * Available only if the current type is `never`.\n *\n * ### Examples\n *\n * ```ts\n * expect<never>().toBeNever // Available and would succeed\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `unknown`.\n * Available only if the current type is `unknown`.\n *\n * ### Examples\n *\n * ```ts\n * expect<unknown>().toBeUnknown // Available and would succeed\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `void`.\n * Available only if the current type is `void`.\n *\n * ### Examples\n *\n * ```ts\n * expect<void>().toBeVoid // Available and would succeed\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `true` (boolean literal).\n * Available only if the current type is `true`.\n *\n * ### Examples\n *\n * ```ts\n * expect<true>().toBeTrue // Available and would succeed\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Tests if the current type is exactly `false` (boolean literal).\n * Available only if the current type is `false`.\n *\n * ### Examples\n *\n * ```ts\n * expect<false>().toBeFalse // Available and would succeed\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Same<T, any>, 'toBeAny'>\n | If<Same<T, never>, 'toBeNever'>\n | If<Same<T, unknown>, 'toBeUnknown'>\n | If<Same<T, void>, 'toBeVoid'>\n | If<Same<T, true>, 'toBeTrue'>\n | If<Same<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n\n/**\n * Creates an instance of ExpectType to perform type-level assertions on the given type.\n * This function enables testing various type relationships at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T The type to be tested\n *\n * @returns An ExpectType instance with methods to test type relationships\n *\n * ### Examples\n *\n * ```ts\n * // Test exact type equality\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * ```\n */\nexport function expect<T>(): ExpectType<T>\nexport function expect<T>(_: T): ExpectType<T>\nexport function expect<T>(): ExpectType<T> {\n return NOOP\n}\n\n/**\n * Type-level utility that compares two types and provides methods to test their relationship.\n * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.\n *\n * @template T First type to compare\n * @template U Second type to compare\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * ### Examples\n *\n * ```ts\n * // Check if two types are the same\n * compare<number, number>().same // Available\n * // Check if two types are different\n * compare<number, string>().different // Available\n * // Check if two types overlap\n * compare<4, number>().overlap.different // Available\n * ```\n */\nexport type CompareTypes<T, U, H extends PropertyKey = never> = Omit<\n SafePick<\n {\n /**\n * Available when types T and U are exactly the same.\n *\n * ### Examples\n *\n * ```ts\n * compare<3, 3>().same // Available\n * compare<boolean, boolean>().same // Available\n * ```\n */\n same: CompareTypes<T, U, H | 'same'>\n\n /**\n * Available when types T and U are different.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different // Available\n * compare<number, 4>().different // Available\n * ```\n */\n different: CompareTypes<T, U, H | 'different'>\n\n /**\n * Available when types T and U have some overlap.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, number>().overlap // Available since 4 overlaps with number\n * ```\n */\n overlap: CompareTypes<T, U, H | 'overlap'>\n\n /**\n * Available when types T and U have no overlap (are disjoint).\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint\n * ```\n */\n disjoint: CompareTypes<T, U, H | 'disjoint'>\n\n /**\n * Available when types T and U are mutually assignable (each type can be assigned to the other).\n *\n * ### Examples\n *\n * ```ts\n * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable\n * ```\n */\n mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>\n },\n | If<Same<T, U>, 'same'>\n | If<Diff<T, U>, 'different'>\n | If<Overlap<T, U>, 'overlap'>\n | If<Disjoint<T, U>, 'disjoint'>\n | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>\n >,\n H\n>\n\n/**\n * Creates an instance of CompareTypes to perform type-level comparisons between two types.\n * This function enables testing various relationships between types at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T First type to compare\n * @template U Second type to compare\n *\n * @returns A CompareTypes instance with methods to test relationships between T and U\n *\n * ### Examples\n *\n * ```ts\n * // Compare two identical types\n * compare<number, number>().same // Results in an available property\n * // Compare two different but overlapping types\n * compare<4, number>().overlap.different // Results in available properties\n * ```\n */\nexport function compare<T, U>(): CompareTypes<T, U>\nexport function compare<T, U>(t: T, u: U): CompareTypes<T, U>\nexport function compare<T, U>(): CompareTypes<T, U> {\n return NOOP\n}\n"]}
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":";;;AAmUA,wBAEC;AA+GD,0BAEC;AAzaD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,IAAI,GAAQ,IAAI,KAAK,CAChC;IACE,OAAO,YAAI,CAAA;AACb,CAAC,EACD;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,SAAS,CAAA;YAClB,KAAK,SAAS,CAAC;YACf,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC,WAAW;gBACrB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAA;YACvB;gBACE,OAAO,YAAI,CAAA;QACf,CAAC;IACH,CAAC;IACD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,YAAI;KACZ,CAAC;IACF,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;IAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC;CAC7B,CACF,CAAA;AAkQD,SAAgB,MAAM;IACpB,OAAO,YAAI,CAAA;AACb,CAAC;AA+GD,SAAgB,OAAO;IACrB,OAAO,YAAI,CAAA;AACb,CAAC","sourcesContent":["// deno-lint-ignore-file no-explicit-any\nimport type {\n Diff,\n Disjoint,\n Extends,\n If,\n MutuallyAssignable,\n Overlap,\n ProperExtend,\n SafePick,\n Same,\n} from './main/index.js'\n\n/**\n * A universal no-op placeholder implemented via `Proxy`.\n *\n * `NOOP` can be accessed, called, or chained indefinitely without throwing.\n * Every operation returns itself, making it safe to use as a dummy fallback\n * for APIs, optional hooks, or unimplemented interfaces.\n *\n * ### Special behaviors\n *\n * - Callable: invoking `NOOP()` returns `NOOP`\n * - Property access: `NOOP.anything` returns `NOOP`\n * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise\n * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields\n * a stable string representation: `\"[NOOP]\"`\n *\n * This is useful in scenarios where a value is required syntactically but\n * should perform no action and never fail at runtime.\n *\n * ### Examples\n *\n * ```ts\n * NOOP.foo.bar().baz.qux; // safe, returns NOOP\n * String(NOOP); // \"[NOOP]\"\n * await NOOP; // does not await (not thenable)\n * ```\n */\nexport const NOOP: any = new Proxy(\n function () {\n return NOOP\n },\n {\n get(_, prop) {\n switch (prop) {\n case 'then':\n return undefined\n case 'valueOf':\n case 'toString':\n case Symbol.toPrimitive:\n return () => '[NOOP]'\n default:\n return NOOP\n }\n },\n set: () => true,\n getOwnPropertyDescriptor: () => ({\n configurable: true,\n value: NOOP,\n }),\n getPrototypeOf: () => null,\n has: () => true,\n ownKeys: () => ['prototype'],\n },\n)\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n * If the condition is true, the result has a `success` property; otherwise, it has a `fail` property.\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\ntype Result<B extends true | false, R = void> = B extends true ? {\n /**\n * ## Expect to succeed without type error\n */\n success: R\n }\n : {\n /**\n * ## Expect to fail with type error\n */\n fail: R\n }\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 * ### Examples\n *\n * ```ts\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}>().toHaveProperty<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n\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 * ### Examples\n *\n * ```ts\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): Result<Same<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): Result<Extends<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): Result<ProperExtend<T, U>>\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 * ### Examples\n *\n * ```ts\n * type WithProp = { prop: string; another: number }\n * expect<WithProp>().toHaveProperty<'prop'>().success\n * expect<WithProp>().toHaveProperty<'another'>().success\n * expect<WithProp>().toHaveProperty<'missing'>().fail\n * ```\n */\n toHaveProperty<K extends PropertyKey>(): Result<Extends<K, keyof T>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtendNumber // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<'hello'>().toExtendString // Available and would succeed\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 * ### Examples\n *\n * ```ts\n * expect<true>().toExtendBoolean // Available and would succeed\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 * Tests if the current type is exactly `any`.\n * Available only if the current type is `any`.\n *\n * ### Examples\n *\n * ```ts\n * expect<any>().toBeAny // Available and would succeed\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `never`.\n * Available only if the current type is `never`.\n *\n * ### Examples\n *\n * ```ts\n * expect<never>().toBeNever // Available and would succeed\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `unknown`.\n * Available only if the current type is `unknown`.\n *\n * ### Examples\n *\n * ```ts\n * expect<unknown>().toBeUnknown // Available and would succeed\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `void`.\n * Available only if the current type is `void`.\n *\n * ### Examples\n *\n * ```ts\n * expect<void>().toBeVoid // Available and would succeed\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `true` (boolean literal).\n * Available only if the current type is `true`.\n *\n * ### Examples\n *\n * ```ts\n * expect<true>().toBeTrue // Available and would succeed\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Tests if the current type is exactly `false` (boolean literal).\n * Available only if the current type is `false`.\n *\n * ### Examples\n *\n * ```ts\n * expect<false>().toBeFalse // Available and would succeed\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Same<T, any>, 'toBeAny'>\n | If<Same<T, never>, 'toBeNever'>\n | If<Same<T, unknown>, 'toBeUnknown'>\n | If<Same<T, void>, 'toBeVoid'>\n | If<Same<T, true>, 'toBeTrue'>\n | If<Same<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n\n/**\n * Creates an instance of ExpectType to perform type-level assertions on the given type.\n * This function enables testing various type relationships at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T The type to be tested\n *\n * @returns An ExpectType instance with methods to test type relationships\n *\n * ### Examples\n *\n * ```ts\n * // Test exact type equality\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * ```\n */\nexport function expect<T>(): ExpectType<T>\nexport function expect<T>(_: T): ExpectType<T>\nexport function expect<T>(): ExpectType<T> {\n return NOOP\n}\n\n/**\n * Type-level utility that compares two types and provides methods to test their relationship.\n * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.\n *\n * @template T First type to compare\n * @template U Second type to compare\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * ### Examples\n *\n * ```ts\n * // Check if two types are the same\n * compare<number, number>().same // Available\n * // Check if two types are different\n * compare<number, string>().different // Available\n * // Check if two types overlap\n * compare<4, number>().overlap.different // Available\n * ```\n */\nexport type CompareTypes<T, U, H extends PropertyKey = never> = Omit<\n SafePick<\n {\n /**\n * Available when types T and U are exactly the same.\n *\n * ### Examples\n *\n * ```ts\n * compare<3, 3>().same // Available\n * compare<boolean, boolean>().same // Available\n * ```\n */\n same: CompareTypes<T, U, H | 'same'>\n\n /**\n * Available when types T and U are different.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different // Available\n * compare<number, 4>().different // Available\n * ```\n */\n different: CompareTypes<T, U, H | 'different'>\n\n /**\n * Available when types T and U have some overlap.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, number>().overlap // Available since 4 overlaps with number\n * ```\n */\n overlap: CompareTypes<T, U, H | 'overlap'>\n\n /**\n * Available when types T and U have no overlap (are disjoint).\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint\n * ```\n */\n disjoint: CompareTypes<T, U, H | 'disjoint'>\n\n /**\n * Available when types T and U are mutually assignable (each type can be assigned to the other).\n *\n * ### Examples\n *\n * ```ts\n * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable\n * ```\n */\n mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>\n },\n | If<Same<T, U>, 'same'>\n | If<Diff<T, U>, 'different'>\n | If<Overlap<T, U>, 'overlap'>\n | If<Disjoint<T, U>, 'disjoint'>\n | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>\n >,\n H\n>\n\n/**\n * Creates an instance of CompareTypes to perform type-level comparisons between two types.\n * This function enables testing various relationships between types at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T First type to compare\n * @template U Second type to compare\n *\n * @returns A CompareTypes instance with methods to test relationships between T and U\n *\n * ### Examples\n *\n * ```ts\n * // Compare two identical types\n * compare<number, number>().same // Results in an available property\n * // Compare two different but overlapping types\n * compare<4, number>().overlap.different // Results in available properties\n * ```\n */\nexport function compare<T, U>(): CompareTypes<T, U>\nexport function compare<T, U>(t: T, u: U): CompareTypes<T, U>\nexport function compare<T, U>(): CompareTypes<T, U> {\n return NOOP\n}\n"]}