lay-sing 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -35
- package/esm/main/expect/index.d.ts +31 -0
- package/esm/main/expect/index.d.ts.map +1 -0
- package/esm/main/expect/index.js +2 -0
- package/esm/main/expect/index.js.map +1 -0
- package/esm/main/expect/to/be.d.ts +23 -0
- package/esm/main/expect/to/be.d.ts.map +1 -0
- package/esm/main/expect/to/be.js +2 -0
- package/esm/main/expect/to/be.js.map +1 -0
- package/esm/main/expect/to/equal.d.ts +26 -0
- package/esm/main/expect/to/equal.d.ts.map +1 -0
- package/esm/main/expect/to/equal.js +2 -0
- package/esm/main/expect/to/equal.js.map +1 -0
- package/esm/main/expect/to/extend.d.ts +31 -0
- package/esm/main/expect/to/extend.d.ts.map +1 -0
- package/esm/main/expect/to/extend.js +2 -0
- package/esm/main/expect/to/extend.js.map +1 -0
- package/esm/main/expect/to/have-key.d.ts +38 -0
- package/esm/main/expect/to/have-key.d.ts.map +1 -0
- package/esm/main/expect/to/have-key.js +2 -0
- package/esm/main/expect/to/have-key.js.map +1 -0
- package/esm/main/expect/to/index.d.ts +13 -0
- package/esm/main/expect/to/index.d.ts.map +1 -0
- package/esm/main/expect/to/index.js +2 -0
- package/esm/main/expect/to/index.js.map +1 -0
- package/esm/main/expect/to/proper-extends.d.ts +21 -0
- package/esm/main/expect/to/proper-extends.d.ts.map +1 -0
- package/esm/main/expect/to/proper-extends.js +2 -0
- package/esm/main/expect/to/proper-extends.js.map +1 -0
- package/esm/main/index.d.ts +26 -11
- package/esm/main/index.d.ts.map +1 -1
- package/esm/main/index.js +22 -13
- package/esm/main/index.js.map +1 -1
- package/esm/main/noop.d.ts +27 -0
- package/esm/main/noop.d.ts.map +1 -0
- package/esm/{test-utils/index.js → main/noop.js} +1 -12
- package/esm/main/noop.js.map +1 -0
- package/esm/utils/compare/assignable.d.ts +30 -0
- package/esm/utils/compare/assignable.d.ts.map +1 -0
- package/esm/utils/compare/assignable.js +2 -0
- package/esm/utils/compare/assignable.js.map +1 -0
- package/esm/utils/compare/exact.d.ts +50 -0
- package/esm/utils/compare/exact.d.ts.map +1 -0
- package/esm/utils/compare/exact.js +2 -0
- package/esm/utils/compare/exact.js.map +1 -0
- package/esm/utils/compare/extends.d.ts +46 -0
- package/esm/utils/compare/extends.d.ts.map +1 -0
- package/esm/utils/compare/extends.js +2 -0
- package/esm/utils/compare/extends.js.map +1 -0
- package/esm/utils/compare/index.d.ts +5 -0
- package/esm/utils/compare/index.d.ts.map +1 -0
- package/esm/utils/compare/index.js +7 -0
- package/esm/utils/compare/index.js.map +1 -0
- package/esm/utils/compare/overlap.d.ts +47 -0
- package/esm/utils/compare/overlap.d.ts.map +1 -0
- package/esm/utils/compare/overlap.js +2 -0
- package/esm/utils/compare/overlap.js.map +1 -0
- package/esm/utils/index.d.ts +11 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +13 -0
- package/esm/utils/index.js.map +1 -0
- package/esm/utils/logic/assert.d.ts +18 -0
- package/esm/utils/logic/assert.d.ts.map +1 -0
- package/esm/utils/logic/assert.js +2 -0
- package/esm/utils/logic/assert.js.map +1 -0
- package/esm/utils/logic/if.d.ts +37 -0
- package/esm/utils/logic/if.d.ts.map +1 -0
- package/esm/utils/logic/if.js +2 -0
- package/esm/utils/logic/if.js.map +1 -0
- package/esm/utils/logic/index.d.ts +4 -0
- package/esm/utils/logic/index.d.ts.map +1 -0
- package/esm/utils/logic/index.js +6 -0
- package/esm/utils/logic/index.js.map +1 -0
- package/{script/main/control.d.ts → esm/utils/logic/switch.d.ts} +15 -40
- package/esm/utils/logic/switch.d.ts.map +1 -0
- package/esm/utils/logic/switch.js +2 -0
- package/esm/utils/logic/switch.js.map +1 -0
- package/esm/utils/misc.d.ts +34 -0
- package/esm/utils/misc.d.ts.map +1 -0
- package/esm/utils/misc.js +2 -0
- package/esm/utils/misc.js.map +1 -0
- package/esm/utils/object/index.d.ts +4 -0
- package/esm/utils/object/index.d.ts.map +1 -0
- package/esm/utils/object/index.js +6 -0
- package/esm/utils/object/index.js.map +1 -0
- package/{script/main/key.d.ts → esm/utils/object/keys.d.ts} +34 -34
- package/esm/utils/object/keys.d.ts.map +1 -0
- package/esm/utils/object/keys.js +2 -0
- package/esm/utils/object/keys.js.map +1 -0
- package/esm/utils/object/pick.d.ts +16 -0
- package/esm/utils/object/pick.d.ts.map +1 -0
- package/esm/utils/object/pick.js +2 -0
- package/esm/utils/object/pick.js.map +1 -0
- package/esm/utils/object/props.d.ts +17 -0
- package/esm/utils/object/props.d.ts.map +1 -0
- package/esm/utils/object/props.js +2 -0
- package/esm/utils/object/props.js.map +1 -0
- package/esm/utils/tuple/append.d.ts +17 -0
- package/esm/utils/tuple/append.d.ts.map +1 -0
- package/esm/utils/tuple/append.js +2 -0
- package/esm/utils/tuple/append.js.map +1 -0
- package/esm/utils/tuple/concat.d.ts +31 -0
- package/esm/utils/tuple/concat.d.ts.map +1 -0
- package/esm/utils/tuple/concat.js +2 -0
- package/esm/utils/tuple/concat.js.map +1 -0
- package/esm/utils/tuple/includes.d.ts +20 -0
- package/esm/utils/tuple/includes.d.ts.map +1 -0
- package/esm/utils/tuple/includes.js +2 -0
- package/esm/utils/tuple/includes.js.map +1 -0
- package/esm/utils/tuple/index.d.ts +4 -0
- package/esm/utils/tuple/index.d.ts.map +1 -0
- package/esm/utils/tuple/index.js +6 -0
- package/esm/utils/tuple/index.js.map +1 -0
- package/package.json +5 -5
- package/script/main/expect/index.d.ts +31 -0
- package/script/main/expect/index.d.ts.map +1 -0
- package/script/main/{async.js → expect/index.js} +1 -1
- package/script/main/expect/index.js.map +1 -0
- package/script/main/expect/to/be.d.ts +23 -0
- package/script/main/expect/to/be.d.ts.map +1 -0
- package/script/main/{type/set.js → expect/to/be.js} +1 -1
- package/script/main/expect/to/be.js.map +1 -0
- package/script/main/expect/to/equal.d.ts +26 -0
- package/script/main/expect/to/equal.d.ts.map +1 -0
- package/script/main/expect/to/equal.js +3 -0
- package/script/main/expect/to/equal.js.map +1 -0
- package/script/main/expect/to/extend.d.ts +31 -0
- package/script/main/expect/to/extend.d.ts.map +1 -0
- package/script/main/expect/to/extend.js +3 -0
- package/script/main/expect/to/extend.js.map +1 -0
- package/script/main/expect/to/have-key.d.ts +38 -0
- package/script/main/expect/to/have-key.d.ts.map +1 -0
- package/script/main/expect/to/have-key.js +3 -0
- package/script/main/expect/to/have-key.js.map +1 -0
- package/script/main/expect/to/index.d.ts +13 -0
- package/script/main/expect/to/index.d.ts.map +1 -0
- package/script/main/expect/to/index.js +3 -0
- package/script/main/expect/to/index.js.map +1 -0
- package/script/main/expect/to/proper-extends.d.ts +21 -0
- package/script/main/expect/to/proper-extends.d.ts.map +1 -0
- package/script/main/expect/to/proper-extends.js +3 -0
- package/script/main/expect/to/proper-extends.js.map +1 -0
- package/script/main/index.d.ts +26 -11
- package/script/main/index.d.ts.map +1 -1
- package/script/main/index.js +24 -27
- package/script/main/index.js.map +1 -1
- package/script/main/noop.d.ts +27 -0
- package/script/main/noop.d.ts.map +1 -0
- package/script/{test-utils/index.js → main/noop.js} +1 -14
- package/script/main/noop.js.map +1 -0
- package/script/utils/compare/assignable.d.ts +30 -0
- package/script/utils/compare/assignable.d.ts.map +1 -0
- package/script/utils/compare/assignable.js +3 -0
- package/script/utils/compare/assignable.js.map +1 -0
- package/script/utils/compare/exact.d.ts +50 -0
- package/script/utils/compare/exact.d.ts.map +1 -0
- package/script/utils/compare/exact.js +3 -0
- package/script/utils/compare/exact.js.map +1 -0
- package/script/utils/compare/extends.d.ts +46 -0
- package/script/utils/compare/extends.d.ts.map +1 -0
- package/script/{main/boolean.js → utils/compare/extends.js} +1 -1
- package/script/utils/compare/extends.js.map +1 -0
- package/script/utils/compare/index.d.ts +5 -0
- package/script/utils/compare/index.d.ts.map +1 -0
- package/script/utils/compare/index.js +23 -0
- package/script/utils/compare/index.js.map +1 -0
- package/script/utils/compare/overlap.d.ts +47 -0
- package/script/utils/compare/overlap.d.ts.map +1 -0
- package/script/{main/control.js → utils/compare/overlap.js} +1 -1
- package/script/utils/compare/overlap.js.map +1 -0
- package/script/utils/index.d.ts +11 -0
- package/script/utils/index.d.ts.map +1 -0
- package/script/utils/index.js +29 -0
- package/script/utils/index.js.map +1 -0
- package/script/utils/logic/assert.d.ts +18 -0
- package/script/utils/logic/assert.d.ts.map +1 -0
- package/script/utils/logic/assert.js +3 -0
- package/script/utils/logic/assert.js.map +1 -0
- package/script/utils/logic/if.d.ts +37 -0
- package/script/utils/logic/if.d.ts.map +1 -0
- package/script/{main/key.js → utils/logic/if.js} +1 -1
- package/script/utils/logic/if.js.map +1 -0
- package/script/utils/logic/index.d.ts +4 -0
- package/script/utils/logic/index.d.ts.map +1 -0
- package/script/utils/logic/index.js +22 -0
- package/script/utils/logic/index.js.map +1 -0
- package/{esm/main/control.d.ts → script/utils/logic/switch.d.ts} +15 -40
- package/script/utils/logic/switch.d.ts.map +1 -0
- package/script/utils/logic/switch.js +3 -0
- package/script/utils/logic/switch.js.map +1 -0
- package/script/utils/misc.d.ts +34 -0
- package/script/utils/misc.d.ts.map +1 -0
- package/script/{main/json.js → utils/misc.js} +1 -1
- package/script/utils/misc.js.map +1 -0
- package/script/utils/object/index.d.ts +4 -0
- package/script/utils/object/index.d.ts.map +1 -0
- package/script/{main/type → utils/object}/index.js +3 -2
- package/script/utils/object/index.js.map +1 -0
- package/{esm/main/key.d.ts → script/utils/object/keys.d.ts} +34 -34
- package/script/utils/object/keys.d.ts.map +1 -0
- package/script/{main/doc.js → utils/object/keys.js} +1 -1
- package/script/utils/object/keys.js.map +1 -0
- package/script/utils/object/pick.d.ts +16 -0
- package/script/utils/object/pick.d.ts.map +1 -0
- package/script/utils/object/pick.js +3 -0
- package/script/utils/object/pick.js.map +1 -0
- package/script/utils/object/props.d.ts +17 -0
- package/script/utils/object/props.d.ts.map +1 -0
- package/script/utils/object/props.js +3 -0
- package/script/utils/object/props.js.map +1 -0
- package/script/utils/tuple/append.d.ts +17 -0
- package/script/utils/tuple/append.d.ts.map +1 -0
- package/script/utils/tuple/append.js +3 -0
- package/script/utils/tuple/append.js.map +1 -0
- package/script/utils/tuple/concat.d.ts +31 -0
- package/script/utils/tuple/concat.d.ts.map +1 -0
- package/script/utils/tuple/concat.js +3 -0
- package/script/utils/tuple/concat.js.map +1 -0
- package/script/utils/tuple/includes.d.ts +20 -0
- package/script/utils/tuple/includes.d.ts.map +1 -0
- package/script/utils/tuple/includes.js +3 -0
- package/script/utils/tuple/includes.js.map +1 -0
- package/script/utils/tuple/index.d.ts +4 -0
- package/script/utils/tuple/index.d.ts.map +1 -0
- package/script/utils/tuple/index.js +22 -0
- package/script/utils/tuple/index.js.map +1 -0
- package/esm/main/async.d.ts +0 -13
- package/esm/main/async.d.ts.map +0 -1
- package/esm/main/async.js +0 -2
- package/esm/main/async.js.map +0 -1
- package/esm/main/boolean.d.ts +0 -59
- package/esm/main/boolean.d.ts.map +0 -1
- package/esm/main/boolean.js +0 -2
- package/esm/main/boolean.js.map +0 -1
- package/esm/main/control.d.ts.map +0 -1
- package/esm/main/control.js +0 -2
- package/esm/main/control.js.map +0 -1
- package/esm/main/doc.d.ts +0 -56
- package/esm/main/doc.d.ts.map +0 -1
- package/esm/main/doc.js +0 -2
- package/esm/main/doc.js.map +0 -1
- package/esm/main/function.d.ts +0 -27
- package/esm/main/function.d.ts.map +0 -1
- package/esm/main/function.js +0 -2
- package/esm/main/function.js.map +0 -1
- package/esm/main/json.d.ts +0 -44
- package/esm/main/json.d.ts.map +0 -1
- package/esm/main/json.js +0 -2
- package/esm/main/json.js.map +0 -1
- package/esm/main/key.d.ts.map +0 -1
- package/esm/main/key.js +0 -2
- package/esm/main/key.js.map +0 -1
- package/esm/main/object.d.ts +0 -120
- package/esm/main/object.d.ts.map +0 -1
- package/esm/main/object.js +0 -2
- package/esm/main/object.js.map +0 -1
- package/esm/main/tuple.d.ts +0 -64
- package/esm/main/tuple.d.ts.map +0 -1
- package/esm/main/tuple.js +0 -2
- package/esm/main/tuple.js.map +0 -1
- package/esm/main/type/compare.d.ts +0 -169
- package/esm/main/type/compare.d.ts.map +0 -1
- package/esm/main/type/compare.js +0 -2
- package/esm/main/type/compare.js.map +0 -1
- package/esm/main/type/index.d.ts +0 -3
- package/esm/main/type/index.d.ts.map +0 -1
- package/esm/main/type/index.js +0 -5
- package/esm/main/type/index.js.map +0 -1
- package/esm/main/type/set.d.ts +0 -34
- package/esm/main/type/set.d.ts.map +0 -1
- package/esm/main/type/set.js +0 -2
- package/esm/main/type/set.js.map +0 -1
- package/esm/main/typed-array.d.ts +0 -5
- package/esm/main/typed-array.d.ts.map +0 -1
- package/esm/main/typed-array.js +0 -2
- package/esm/main/typed-array.js.map +0 -1
- package/esm/test-utils/compare.d.ts +0 -81
- package/esm/test-utils/compare.d.ts.map +0 -1
- package/esm/test-utils/compare.js +0 -2
- package/esm/test-utils/compare.js.map +0 -1
- package/esm/test-utils/expect.d.ts +0 -278
- package/esm/test-utils/expect.d.ts.map +0 -1
- package/esm/test-utils/expect.js +0 -2
- package/esm/test-utils/expect.js.map +0 -1
- package/esm/test-utils/index.d.ts +0 -77
- package/esm/test-utils/index.d.ts.map +0 -1
- package/esm/test-utils/index.js.map +0 -1
- package/script/main/async.d.ts +0 -13
- package/script/main/async.d.ts.map +0 -1
- package/script/main/async.js.map +0 -1
- package/script/main/boolean.d.ts +0 -59
- package/script/main/boolean.d.ts.map +0 -1
- package/script/main/boolean.js.map +0 -1
- package/script/main/control.d.ts.map +0 -1
- package/script/main/control.js.map +0 -1
- package/script/main/doc.d.ts +0 -56
- package/script/main/doc.d.ts.map +0 -1
- package/script/main/doc.js.map +0 -1
- package/script/main/function.d.ts +0 -27
- package/script/main/function.d.ts.map +0 -1
- package/script/main/function.js +0 -3
- package/script/main/function.js.map +0 -1
- package/script/main/json.d.ts +0 -44
- package/script/main/json.d.ts.map +0 -1
- package/script/main/json.js.map +0 -1
- package/script/main/key.d.ts.map +0 -1
- package/script/main/key.js.map +0 -1
- package/script/main/object.d.ts +0 -120
- package/script/main/object.d.ts.map +0 -1
- package/script/main/object.js +0 -3
- package/script/main/object.js.map +0 -1
- package/script/main/tuple.d.ts +0 -64
- package/script/main/tuple.d.ts.map +0 -1
- package/script/main/tuple.js +0 -3
- package/script/main/tuple.js.map +0 -1
- package/script/main/type/compare.d.ts +0 -169
- package/script/main/type/compare.d.ts.map +0 -1
- package/script/main/type/compare.js +0 -3
- package/script/main/type/compare.js.map +0 -1
- package/script/main/type/index.d.ts +0 -3
- package/script/main/type/index.d.ts.map +0 -1
- package/script/main/type/index.js.map +0 -1
- package/script/main/type/set.d.ts +0 -34
- package/script/main/type/set.d.ts.map +0 -1
- package/script/main/type/set.js.map +0 -1
- package/script/main/typed-array.d.ts +0 -5
- package/script/main/typed-array.d.ts.map +0 -1
- package/script/main/typed-array.js +0 -3
- package/script/main/typed-array.js.map +0 -1
- package/script/test-utils/compare.d.ts +0 -81
- package/script/test-utils/compare.d.ts.map +0 -1
- package/script/test-utils/compare.js +0 -3
- package/script/test-utils/compare.js.map +0 -1
- package/script/test-utils/expect.d.ts +0 -278
- package/script/test-utils/expect.d.ts.map +0 -1
- package/script/test-utils/expect.js +0 -3
- package/script/test-utils/expect.js.map +0 -1
- package/script/test-utils/index.d.ts +0 -77
- package/script/test-utils/index.d.ts.map +0 -1
- package/script/test-utils/index.js.map +0 -1
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../main/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/test-utils'
|
|
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
|
-
/**
|
|
44
|
-
* Tests if the current type is mutually assignable with the provided type U.
|
|
45
|
-
*
|
|
46
|
-
* It's like:
|
|
47
|
-
*
|
|
48
|
-
* ```ts ignore
|
|
49
|
-
* [T] extends [U] ? [U] extends [T] ? Yes : No : No
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @template U The type to compare with
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
57
|
-
*
|
|
58
|
-
* expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
|
|
59
|
-
* expect<1>().toEqual<1 | 2>().fail
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
|
|
63
|
-
/**
|
|
64
|
-
* Tests if the current type T extends the provided type U.
|
|
65
|
-
*
|
|
66
|
-
* @template U The type to check extension against
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```ts
|
|
70
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
71
|
-
*
|
|
72
|
-
* expect<3.14>().toExtend<number>().success
|
|
73
|
-
* expect<2>().toExtend<string>().fail
|
|
74
|
-
* expect<'hello'>().toExtend<string>().success
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
|
|
78
|
-
/**
|
|
79
|
-
* Tests if the current type T properly extends the provided type U (extends but is not the same).
|
|
80
|
-
*
|
|
81
|
-
* @template U The type to check proper extension against
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
86
|
-
*
|
|
87
|
-
* expect<2>().toProperExtend<number>().success
|
|
88
|
-
* expect<'a' | 'b'>().toProperExtend<string>().success
|
|
89
|
-
* expect<number>().toProperExtend<number>().fail
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
|
|
93
|
-
/**
|
|
94
|
-
* Tests if the current type `T` has a property with key `K`.
|
|
95
|
-
*
|
|
96
|
-
* @template K The property key to check for
|
|
97
|
-
*
|
|
98
|
-
* ### Behavior
|
|
99
|
-
*
|
|
100
|
-
* - For single keys: succeeds if the key exists in `T`
|
|
101
|
-
* - For union types: succeeds only if **all** keys in the union exist in `T`
|
|
102
|
-
*
|
|
103
|
-
* ### Examples
|
|
104
|
-
*
|
|
105
|
-
* ```ts
|
|
106
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
107
|
-
*
|
|
108
|
-
* type WithProp = { prop: string; another: number; may?: 5 }
|
|
109
|
-
*
|
|
110
|
-
* // Single key checks
|
|
111
|
-
* expect<WithProp>().toHaveKey<'prop'>().success
|
|
112
|
-
* expect<WithProp>().toHaveKey<'missing'>().fail
|
|
113
|
-
*
|
|
114
|
-
* // Union type checks
|
|
115
|
-
* expect<WithProp>().toHaveKey<'prop' | 'another'>().success
|
|
116
|
-
* expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
toHaveKey<K extends PropertyKey>(): IfTupleIncludes<[
|
|
120
|
-
never,
|
|
121
|
-
any
|
|
122
|
-
], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Type-level testing utility that allows checking various relationships between types.
|
|
126
|
-
* Provides methods to test type equality, extension, properties, and more.
|
|
127
|
-
*
|
|
128
|
-
* @template T The type being tested
|
|
129
|
-
* @template H Hidden property keys that are already used (internal tracking)
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```ts
|
|
133
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
134
|
-
*
|
|
135
|
-
* // Test if two types are identical
|
|
136
|
-
* expect<number>().toBe<number>().success
|
|
137
|
-
* expect<number>().toBe<string>().fail
|
|
138
|
-
* // Test if one type extends another
|
|
139
|
-
* expect<2>().toExtend<number>().success
|
|
140
|
-
* expect<2>().toExtend<string>().fail
|
|
141
|
-
* // Test if type has a specific property
|
|
142
|
-
* expect<{name: string}>().toHaveKey<'name'>().success
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMethods<T, H> & {
|
|
146
|
-
T: T;
|
|
147
|
-
inspect: {
|
|
148
|
-
[K in keyof T]: T[K];
|
|
149
|
-
};
|
|
150
|
-
} & SafePick<{
|
|
151
|
-
/**
|
|
152
|
-
* Tests if the current type extends the Number primitive type.
|
|
153
|
-
* Available only if the current type extends number.
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```ts
|
|
157
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
158
|
-
*
|
|
159
|
-
* expect<3.14>().toExtendNumber
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>;
|
|
163
|
-
/**
|
|
164
|
-
* Tests if the current type extends the String primitive type.
|
|
165
|
-
* Available only if the current type extends string.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```ts
|
|
169
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
170
|
-
*
|
|
171
|
-
* expect<'hello'>().toExtendString
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>;
|
|
175
|
-
/**
|
|
176
|
-
* Tests if the current type extends the Boolean primitive type.
|
|
177
|
-
* Available only if the current type extends boolean.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
182
|
-
*
|
|
183
|
-
* expect<true>().toExtendBoolean
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>;
|
|
187
|
-
}, If<Extends<T, number>, 'toExtendNumber'> | If<Extends<T, string>, 'toExtendString'> | If<Extends<T, boolean>, 'toExtendBoolean'>> & SafePick<{
|
|
188
|
-
/**
|
|
189
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = any`
|
|
190
|
-
*
|
|
191
|
-
* ```ts
|
|
192
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
193
|
-
*
|
|
194
|
-
* expect<any>().toBeAny
|
|
195
|
-
* expect<any>().toBe<any>().success
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
|
-
toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>;
|
|
199
|
-
/**
|
|
200
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = never`
|
|
201
|
-
*
|
|
202
|
-
* ```ts
|
|
203
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
204
|
-
*
|
|
205
|
-
* expect<never>().toBeNever
|
|
206
|
-
* expect<never>().toBe<never>().success
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>;
|
|
210
|
-
/**
|
|
211
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`
|
|
212
|
-
*
|
|
213
|
-
* ```ts
|
|
214
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
215
|
-
*
|
|
216
|
-
* expect<unknown>().toBeUnknown
|
|
217
|
-
* expect<unknown>().toBe<unknown>().success
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>;
|
|
221
|
-
/**
|
|
222
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = void`
|
|
223
|
-
*
|
|
224
|
-
* ```ts
|
|
225
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
226
|
-
*
|
|
227
|
-
* expect<void>().toBeVoid
|
|
228
|
-
* expect<void>().toBe<void>().success
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>;
|
|
232
|
-
/**
|
|
233
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = null`
|
|
234
|
-
*
|
|
235
|
-
* ```ts
|
|
236
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
237
|
-
*
|
|
238
|
-
* expect<null>().toBeNull
|
|
239
|
-
* expect<null>().toBe<null>().success
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>;
|
|
243
|
-
/**
|
|
244
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`
|
|
245
|
-
*
|
|
246
|
-
* ```ts
|
|
247
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
248
|
-
*
|
|
249
|
-
* expect<undefined>().toBeUndefined
|
|
250
|
-
* expect<undefined>().toBe<undefined>().success
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
253
|
-
toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>;
|
|
254
|
-
/**
|
|
255
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = true`
|
|
256
|
-
*
|
|
257
|
-
* ```ts
|
|
258
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
259
|
-
*
|
|
260
|
-
* expect<true>().toBeTrue
|
|
261
|
-
* expect<true>().toBe<true>().success
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>;
|
|
265
|
-
/**
|
|
266
|
-
* Alias for {@link ExpectTypeMethods.toBe} where `U = false`
|
|
267
|
-
*
|
|
268
|
-
* ```ts
|
|
269
|
-
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
270
|
-
*
|
|
271
|
-
* expect<false>().toBeFalse
|
|
272
|
-
* expect<false>().toBe<false>().success
|
|
273
|
-
* ```
|
|
274
|
-
*/
|
|
275
|
-
toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>;
|
|
276
|
-
}, 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>;
|
|
277
|
-
export {};
|
|
278
|
-
//# sourceMappingURL=expect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/test-utils/expect.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/test-utils/expect.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../main/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/test-utils'\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\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/test-utils'\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\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/test-utils'\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\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/test-utils'\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\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/test-utils'\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}\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/test-utils'\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 & {\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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/test-utils'\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,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import type { CompareTypes } from './compare.js';
|
|
7
|
-
import type { ExpectType } from './expect.js';
|
|
8
|
-
export type { CompareTypes } from './compare.js';
|
|
9
|
-
export type { ExpectType } from './expect.js';
|
|
10
|
-
/**
|
|
11
|
-
* A universal no-op placeholder implemented via `Proxy`.
|
|
12
|
-
*
|
|
13
|
-
* `NOOP` can be accessed, called, or chained indefinitely without throwing.
|
|
14
|
-
* Every operation returns itself, making it safe to use as a dummy fallback
|
|
15
|
-
* for APIs, optional hooks, or unimplemented interfaces.
|
|
16
|
-
*
|
|
17
|
-
* ### Special behaviors
|
|
18
|
-
*
|
|
19
|
-
* - Callable: invoking `NOOP()` returns `NOOP`
|
|
20
|
-
* - Property access: `NOOP.anything` returns `NOOP`
|
|
21
|
-
* - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise
|
|
22
|
-
* - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields
|
|
23
|
-
* a stable string representation: `"[NOOP]"`
|
|
24
|
-
*
|
|
25
|
-
* This is useful in scenarios where a value is required syntactically but
|
|
26
|
-
* should perform no action and never fail at runtime.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* NOOP.foo.bar().baz.qux; // safe, returns NOOP
|
|
31
|
-
* String(NOOP); // "[NOOP]"
|
|
32
|
-
* await NOOP; // does not await (not thenable)
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare const NOOP: any;
|
|
36
|
-
/**
|
|
37
|
-
* Creates an instance of CompareTypes to perform type-level comparisons between two types.
|
|
38
|
-
* This function enables testing various relationships between types at compile time.
|
|
39
|
-
* NOTE: This function does nothing at runtime and is purely for type-level testing.
|
|
40
|
-
*
|
|
41
|
-
* @template T First type to compare
|
|
42
|
-
* @template U Second type to compare
|
|
43
|
-
*
|
|
44
|
-
* @returns A CompareTypes instance with methods to test relationships between T and U
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```ts
|
|
48
|
-
* // Compare two identical types
|
|
49
|
-
* compare<number, number>().same // Results in an available property
|
|
50
|
-
* // Compare two different but overlapping types
|
|
51
|
-
* compare<4, number>().overlap.different // Results in available properties
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare function compare<T, U>(): CompareTypes<T, U>;
|
|
55
|
-
export declare function compare<T, U>(t: T, u: U): CompareTypes<T, U>;
|
|
56
|
-
/**
|
|
57
|
-
* Creates an instance of ExpectType to perform type-level assertions on the given type.
|
|
58
|
-
* This function enables testing various type relationships at compile time.
|
|
59
|
-
* NOTE: This function does nothing at runtime and is purely for type-level testing.
|
|
60
|
-
*
|
|
61
|
-
* @template T The type to be tested
|
|
62
|
-
*
|
|
63
|
-
* @returns An ExpectType instance with methods to test type relationships
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* // Test exact type equality
|
|
68
|
-
* expect<number>().toBe<number>().success
|
|
69
|
-
* expect<number>().toBe<string>().fail
|
|
70
|
-
* // Test if one type extends another
|
|
71
|
-
* expect<3.14>().toExtend<number>().success
|
|
72
|
-
* expect<2>().toExtend<string>().fail
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
export declare function expect<T>(): ExpectType<T>;
|
|
76
|
-
export declare function expect<T>(_: T): ExpectType<T>;
|
|
77
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,IAAI,EAAE,GA0BlB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACnD,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAK7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAA;AAC1C,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAiFH,0BAEC;AAuBD,wBAEC;AApGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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;AAsBD,SAAgB,OAAO;IACrB,OAAO,YAAI,CAAA;AACb,CAAC;AAuBD,SAAgB,MAAM;IACpB,OAAO,YAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)\n *\n * @module\n */\n\nimport type { CompareTypes } from './compare.js'\nimport type { ExpectType } from './expect.js'\n\nexport type { CompareTypes } from './compare.js'\nexport type { ExpectType } from './expect.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 * @example\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 * 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 * @example\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\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 * @example\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"]}
|