lay-sing 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -66
- package/esm/main/async.d.ts +9 -1
- package/esm/main/async.d.ts.map +1 -1
- package/esm/main/async.js.map +1 -1
- package/esm/main/boolean.d.ts +43 -20
- package/esm/main/boolean.d.ts.map +1 -1
- package/esm/main/boolean.js.map +1 -1
- package/esm/main/control.d.ts +70 -46
- package/esm/main/control.d.ts.map +1 -1
- package/esm/main/control.js.map +1 -1
- package/esm/main/doc.d.ts +33 -7
- package/esm/main/doc.d.ts.map +1 -1
- package/esm/main/doc.js.map +1 -1
- package/esm/main/function.d.ts +11 -5
- package/esm/main/function.d.ts.map +1 -1
- package/esm/main/function.js +0 -1
- package/esm/main/function.js.map +1 -1
- package/esm/main/index.d.ts +6 -1
- package/esm/main/index.d.ts.map +1 -1
- package/esm/main/index.js +8 -1
- package/esm/main/index.js.map +1 -1
- package/esm/main/key.d.ts +51 -13
- package/esm/main/key.d.ts.map +1 -1
- package/esm/main/key.js.map +1 -1
- package/esm/main/object.d.ts +74 -35
- package/esm/main/object.d.ts.map +1 -1
- package/esm/main/object.js.map +1 -1
- package/esm/main/tuple.d.ts +64 -0
- package/esm/main/tuple.d.ts.map +1 -0
- package/esm/main/tuple.js +2 -0
- package/esm/main/tuple.js.map +1 -0
- package/esm/main/type/compare.d.ts +118 -28
- package/esm/main/type/compare.d.ts.map +1 -1
- package/esm/main/type/compare.js.map +1 -1
- package/esm/main/type/index.d.ts.map +1 -1
- package/esm/main/type/index.js +2 -0
- package/esm/main/type/index.js.map +1 -1
- package/esm/main/type/set.d.ts +17 -12
- package/esm/main/type/set.d.ts.map +1 -1
- package/esm/main/type/set.js.map +1 -1
- package/esm/test-utils/compare.d.ts +81 -0
- package/esm/test-utils/compare.d.ts.map +1 -0
- package/esm/test-utils/compare.js +2 -0
- package/esm/test-utils/compare.js.map +1 -0
- package/esm/test-utils/expect.d.ts +278 -0
- package/esm/test-utils/expect.d.ts.map +1 -0
- package/esm/test-utils/expect.js +2 -0
- package/esm/test-utils/expect.js.map +1 -0
- package/esm/test-utils/index.d.ts +77 -0
- package/esm/test-utils/index.d.ts.map +1 -0
- package/esm/{test-utils.js → test-utils/index.js} +9 -5
- package/esm/test-utils/index.js.map +1 -0
- package/package.json +3 -3
- package/script/main/async.d.ts +9 -1
- package/script/main/async.d.ts.map +1 -1
- package/script/main/async.js.map +1 -1
- package/script/main/boolean.d.ts +43 -20
- package/script/main/boolean.d.ts.map +1 -1
- package/script/main/boolean.js.map +1 -1
- package/script/main/control.d.ts +70 -46
- package/script/main/control.d.ts.map +1 -1
- package/script/main/control.js.map +1 -1
- package/script/main/doc.d.ts +33 -7
- package/script/main/doc.d.ts.map +1 -1
- package/script/main/doc.js.map +1 -1
- package/script/main/function.d.ts +11 -5
- package/script/main/function.d.ts.map +1 -1
- package/script/main/function.js +0 -1
- package/script/main/function.js.map +1 -1
- package/script/main/index.d.ts +6 -1
- package/script/main/index.d.ts.map +1 -1
- package/script/main/index.js +8 -1
- package/script/main/index.js.map +1 -1
- package/script/main/key.d.ts +51 -13
- package/script/main/key.d.ts.map +1 -1
- package/script/main/key.js.map +1 -1
- package/script/main/object.d.ts +74 -35
- package/script/main/object.d.ts.map +1 -1
- package/script/main/object.js.map +1 -1
- package/script/main/tuple.d.ts +64 -0
- package/script/main/tuple.d.ts.map +1 -0
- package/script/main/{array.js → tuple.js} +1 -1
- package/script/main/tuple.js.map +1 -0
- package/script/main/type/compare.d.ts +118 -28
- package/script/main/type/compare.d.ts.map +1 -1
- package/script/main/type/compare.js.map +1 -1
- package/script/main/type/index.d.ts.map +1 -1
- package/script/main/type/index.js +2 -0
- package/script/main/type/index.js.map +1 -1
- package/script/main/type/set.d.ts +17 -12
- package/script/main/type/set.d.ts.map +1 -1
- package/script/main/type/set.js.map +1 -1
- package/script/test-utils/compare.d.ts +81 -0
- package/script/test-utils/compare.d.ts.map +1 -0
- package/script/test-utils/compare.js +3 -0
- package/script/test-utils/compare.js.map +1 -0
- package/script/test-utils/expect.d.ts +278 -0
- package/script/test-utils/expect.d.ts.map +1 -0
- package/script/test-utils/expect.js +3 -0
- package/script/test-utils/expect.js.map +1 -0
- package/script/test-utils/index.d.ts +77 -0
- package/script/test-utils/index.d.ts.map +1 -0
- package/script/{test-utils.js → test-utils/index.js} +10 -6
- package/script/test-utils/index.js.map +1 -0
- package/esm/main/array.d.ts +0 -48
- package/esm/main/array.d.ts.map +0 -1
- package/esm/main/array.js +0 -2
- package/esm/main/array.js.map +0 -1
- package/esm/test-utils.d.ts +0 -348
- package/esm/test-utils.d.ts.map +0 -1
- package/esm/test-utils.js.map +0 -1
- package/script/main/array.d.ts +0 -48
- package/script/main/array.d.ts.map +0 -1
- package/script/main/array.js.map +0 -1
- package/script/test-utils.d.ts +0 -348
- package/script/test-utils.d.ts.map +0 -1
- package/script/test-utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
[](https://github.com/Leawind/lay-sing?tab=MIT-1-ov-file)
|
|
2
|
+
[](https://www.npmjs.com/package/lay-sing)
|
|
3
|
+
[](https://jsr.io/@leawind/lay-sing)
|
|
4
|
+
[](https://github.com/Leawind/lay-sing/actions/workflows/verify.yaml)
|
|
3
5
|
|
|
4
|
-
#
|
|
6
|
+
# Lay-Sing
|
|
5
7
|
|
|
6
8
|
TypeScript utilities for compile-time type testing and utility types
|
|
7
9
|
|
|
8
|
-
## What is it
|
|
9
|
-
|
|
10
|
-
1. **Testing Utilities**
|
|
11
|
-
|
|
12
10
|
```ts
|
|
13
11
|
// They do nothing at runtime
|
|
14
12
|
expect<never>().toBe<never>().success
|
|
15
|
-
expect<never>().toBeNever // alias for above
|
|
13
|
+
expect<never>().toBeNever // alias for the above
|
|
16
14
|
expect<never>().toBe<'should fail'>().fail
|
|
17
15
|
|
|
18
16
|
// Type Error: Property 'success' does not exist on type '{ fail: void; }'.
|
|
@@ -20,50 +18,59 @@ expect<never>().toBe<'should fail'>().success
|
|
|
20
18
|
// ^^^^^^^
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
> [!TIP]
|
|
22
|
+
>
|
|
23
|
+
> I know this library is quite simple and serves a specific purpose, so one of its API design principles is to minimize the cognitive load for users. You just need to remember to **start with an `expect<>()` call** and **end with some property access**. Leave the rest to editor suggestions and inline documentation.
|
|
24
|
+
|
|
25
|
+
## Install & Import
|
|
26
|
+
|
|
27
|
+
<details>
|
|
28
|
+
<summary>NPM</summary>
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm i -D lay-sing
|
|
32
|
+
```
|
|
24
33
|
|
|
25
34
|
```ts
|
|
26
|
-
|
|
27
|
-
type Result = Switch<2, [
|
|
28
|
-
Case<1, 'Alice'>,
|
|
29
|
-
Case<2, 'Bob'>,
|
|
30
|
-
Case<3, 'Charlie'>,
|
|
31
|
-
], DefaultCase<'Unknown'>>
|
|
35
|
+
import { expect } from 'lay-sing/test-utils'
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
</details>
|
|
35
39
|
|
|
36
|
-
>
|
|
40
|
+
<details>
|
|
41
|
+
<summary>Deno</summary>
|
|
37
42
|
|
|
38
|
-
### NPM
|
|
43
|
+
### From NPM
|
|
39
44
|
|
|
40
45
|
```sh
|
|
41
|
-
|
|
46
|
+
deno add npm:lay-sing
|
|
42
47
|
```
|
|
43
48
|
|
|
44
49
|
```ts
|
|
45
|
-
import type { Same } from 'lay-sing'
|
|
46
50
|
import { expect } from 'lay-sing/test-utils'
|
|
47
51
|
```
|
|
48
52
|
|
|
49
|
-
###
|
|
53
|
+
### From JSR
|
|
54
|
+
|
|
55
|
+
This library is also published to [JSR (`@leawind/lay-sing`)](https://jsr.io/@leawind/lay-sing)
|
|
50
56
|
|
|
51
57
|
```sh
|
|
52
|
-
deno add
|
|
58
|
+
deno add @leawind/lay-sing
|
|
53
59
|
```
|
|
54
60
|
|
|
55
61
|
```ts
|
|
56
|
-
import type { Same } from '@leawind/lay-sing'
|
|
57
62
|
import { expect } from '@leawind/lay-sing/test-utils'
|
|
58
63
|
```
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
### From Latest commit
|
|
61
66
|
|
|
62
67
|
```ts
|
|
63
|
-
import
|
|
64
|
-
import {
|
|
68
|
+
import { expect } from 'https://raw.githubusercontent.com/Leawind/lay-sing/refs/heads/main/src/test-utils/index.ts'
|
|
69
|
+
import { Exact } from 'https://raw.githubusercontent.com/Leawind/lay-sing/refs/heads/main/src/main/index.ts'
|
|
65
70
|
```
|
|
66
71
|
|
|
72
|
+
</details>
|
|
73
|
+
|
|
67
74
|
---
|
|
68
75
|
|
|
69
76
|
## Usage
|
|
@@ -71,10 +78,10 @@ import { expect } from 'jsr:@leawind/lay-sing@^0.1/test-utils'
|
|
|
71
78
|
### Testing Utilities
|
|
72
79
|
|
|
73
80
|
```ts
|
|
74
|
-
import {
|
|
81
|
+
import { expect } from 'lay-sing/test-utils'
|
|
75
82
|
```
|
|
76
83
|
|
|
77
|
-
The `test-utils` module provides utilities for **compile-time** type validation. These utilities have **no runtime
|
|
84
|
+
The `test-utils` module provides utilities for **compile-time** type validation. These utilities have **no runtime impact** — 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
85
|
|
|
79
86
|
A typical type test statement follows this pattern:
|
|
80
87
|
|
|
@@ -84,63 +91,76 @@ expect<ActualType>().toBe<ExpectedType>().success
|
|
|
84
91
|
|
|
85
92
|
- It starts with a function call like `expect<T>()` or `compare<T, U>()`
|
|
86
93
|
- It ends with a property like `.success` or `.fail`
|
|
87
|
-
-
|
|
88
|
-
|
|
94
|
+
- Type error occurs only if the assertion fails
|
|
95
|
+
|
|
96
|
+
> [!CAUTION]
|
|
97
|
+
>
|
|
98
|
+
> Only statements ending with property access are type assertions. Without property access, type error may never occur:
|
|
99
|
+
>
|
|
100
|
+
> ```diff
|
|
101
|
+
> - expect<true>().toBe<false>() // Type error never occur
|
|
102
|
+
> + expect<true>().toBe<false>().success // Type Error: Property 'success' does not exist on type '{ fail: void; }'.
|
|
103
|
+
> ```
|
|
104
|
+
|
|
105
|
+
At runtime, the function always returns the `NOOP` object, which performs **no operation**. It can be accessed, called, or chained indefinitely without throwing errors.
|
|
89
106
|
|
|
90
107
|
#### Common Usage
|
|
91
108
|
|
|
92
109
|
```ts
|
|
93
|
-
//
|
|
94
|
-
expect<
|
|
95
|
-
|
|
96
|
-
// Subtype check
|
|
97
|
-
expect<A>().toExtend<B>().success // Passes if A extends B
|
|
110
|
+
// Passes only if A and B are identical
|
|
111
|
+
expect<keyof { a: 2 }>().toBe<'a'>().success
|
|
98
112
|
|
|
99
|
-
//
|
|
100
|
-
expect<
|
|
113
|
+
// Passes if A extends B
|
|
114
|
+
expect<12138>().toExtend<number>().success
|
|
101
115
|
|
|
102
|
-
//
|
|
103
|
-
expect<
|
|
104
|
-
expect<'hello'>().toExtendString.success
|
|
116
|
+
// Passes if mutually assignable
|
|
117
|
+
expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
|
|
105
118
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
compare<A, B>().different // Available only if A ≠ B
|
|
119
|
+
// Test property existence
|
|
120
|
+
expect<{ name: string }>().toHaveKey<'name'>().success
|
|
109
121
|
```
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
>
|
|
115
|
-
>
|
|
123
|
+
Aliases:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
expect<never>().toBe<never>().success
|
|
127
|
+
expect<never>().toBeNever
|
|
128
|
+
|
|
129
|
+
expect<'hello'>().toExtend<string>().success
|
|
130
|
+
expect<'hello'>().toExtendString
|
|
131
|
+
```
|
|
116
132
|
|
|
117
133
|
#### NOOP
|
|
118
134
|
|
|
119
|
-
A `Proxy`-based no-op object:
|
|
135
|
+
A `Proxy`-based no-op object with the following behavior:
|
|
120
136
|
|
|
121
|
-
- Most accesses return itself.
|
|
122
|
-
-
|
|
137
|
+
- Most property/method accesses return the NOOP object itself.
|
|
138
|
+
- `.toString()`, `.valueOf()` returns string `"[NOOP]"`.
|
|
123
139
|
- Not thenable (`then` is `undefined`).
|
|
124
140
|
|
|
141
|
+
It's used as returned value of `expect()` and `compare()`.
|
|
142
|
+
|
|
125
143
|
```ts
|
|
126
|
-
|
|
144
|
+
expect().foo.bar().baz.qux // Safe, returns NOOP
|
|
127
145
|
String(NOOP) // "[NOOP]"
|
|
128
|
-
await NOOP //
|
|
146
|
+
await NOOP // Does not await (not thenable)
|
|
129
147
|
```
|
|
130
148
|
|
|
131
149
|
### Type Tools
|
|
132
150
|
|
|
133
|
-
The main entry point provides
|
|
151
|
+
The main entry point provides some utility types for common type-level programming tasks. All types are flat-exported from the main entry point — no need to import from nested paths.
|
|
134
152
|
|
|
135
153
|
```ts
|
|
136
|
-
import type {
|
|
154
|
+
import type { Exact } from 'lay-sing'
|
|
137
155
|
```
|
|
138
156
|
|
|
139
|
-
> All types are documented — your editor will show inline documentation on hover
|
|
140
|
-
|
|
141
157
|
### Examples
|
|
142
158
|
|
|
143
159
|
```typescript
|
|
160
|
+
// Test if exactly the same
|
|
161
|
+
type False = Exact<{ a: 1 }, { a?: 1 }> // false
|
|
162
|
+
type Yes = Exact<boolean, true | false, 'yes', 'no'> // 'yes'
|
|
163
|
+
|
|
144
164
|
// Conditional Types
|
|
145
165
|
type Result = If<true, 'yes', 'no'> // 'yes'
|
|
146
166
|
|
|
@@ -155,12 +175,4 @@ type PartialObj = DeepPartial<{ a: string; nested: { b: number } }>
|
|
|
155
175
|
// { a?: string; nested?: { b?: number } }
|
|
156
176
|
```
|
|
157
177
|
|
|
158
|
-
|
|
159
|
-
>
|
|
160
|
-
> [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
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)._
|
|
178
|
+
[Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
|
package/esm/main/async.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Represents a value that can be either T or a Promise of T
|
|
2
|
+
* Represents a value that can be either `T` or a Promise of `T`
|
|
3
|
+
*
|
|
4
|
+
* @template T - The underlying type that may or may not be wrapped in a Promise
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* type StringOrPromise = Awaitable<string>
|
|
9
|
+
* // Equivalent to: string | Promise<string>
|
|
10
|
+
* ```
|
|
3
11
|
*/
|
|
4
12
|
export type Awaitable<T> = Promise<T> | T;
|
|
5
13
|
//# sourceMappingURL=async.d.ts.map
|
package/esm/main/async.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
|
package/esm/main/async.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a value that can be either T or a Promise of T\n */\nexport type Awaitable<T> = Promise<T> | T\n"]}
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a value that can be either `T` or a Promise of `T`\n *\n * @template T - The underlying type that may or may not be wrapped in a Promise\n *\n * @example\n * ```ts\n * type StringOrPromise = Awaitable<string>\n * // Equivalent to: string | Promise<string>\n * ```\n */\nexport type Awaitable<T> = Promise<T> | T\n"]}
|
package/esm/main/boolean.d.ts
CHANGED
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Negates a boolean type
|
|
3
3
|
*
|
|
4
|
-
* -
|
|
5
|
-
* - `boolean`: if `T` is `boolean` or `any`
|
|
6
|
-
* - `false`: if `T` is `true`
|
|
7
|
-
* - `true`: if `T` is `false`
|
|
4
|
+
* @template T - The boolean type to negate
|
|
8
5
|
*
|
|
9
|
-
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* | `false` | `true` |
|
|
16
|
-
* | `boolean` | `boolean` |
|
|
17
|
-
* | `any` | `boolean` |
|
|
10
|
+
* expect<Not<true>>().toBeFalse
|
|
11
|
+
* expect<Not<false>>().toBeTrue
|
|
12
|
+
* expect<Not<boolean>>().toBe<boolean>().success
|
|
13
|
+
* ```
|
|
18
14
|
*/
|
|
19
15
|
export type Not<T extends boolean> = T extends true ? false : T extends false ? true : boolean;
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* -
|
|
24
|
-
* -
|
|
17
|
+
* Logical AND operation on two boolean types
|
|
18
|
+
*
|
|
19
|
+
* @template A - The first boolean type to compare
|
|
20
|
+
* @template B - The second boolean type to compare
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
25
|
+
*
|
|
26
|
+
* expect<And<true, true>>().toBeTrue
|
|
27
|
+
* expect<And<true, false>>().toBeFalse
|
|
28
|
+
* expect<And<false, true>>().toBeFalse
|
|
29
|
+
* expect<And<false, false>>().toBeFalse
|
|
30
|
+
* expect<And<boolean, boolean>>().toBe<boolean>().success
|
|
31
|
+
* ```
|
|
25
32
|
*/
|
|
26
33
|
export type And<A extends boolean, B extends boolean> = A extends never ? never : [B] extends [never] ? never : (A extends true ? (B extends true ? true : false) : false);
|
|
27
34
|
/**
|
|
35
|
+
* Logical OR operation on two boolean types
|
|
36
|
+
*
|
|
37
|
+
* @template A - The first boolean type to compare
|
|
38
|
+
* @template B - The second boolean type to compare
|
|
39
|
+
*
|
|
28
40
|
* ### Result
|
|
29
41
|
*
|
|
30
|
-
* - `never`: if
|
|
31
|
-
* - `boolean`: if
|
|
32
|
-
* - `false`: if both A
|
|
42
|
+
* - `never`: if either `A` or `B` is `never`
|
|
43
|
+
* - `boolean`: if either `A` or `B` is `boolean` or `any`
|
|
44
|
+
* - `false`: if both `A` and `B` are `false`
|
|
33
45
|
* - `true`: otherwise
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
50
|
+
*
|
|
51
|
+
* expect<Or<true, true>>().toBeTrue
|
|
52
|
+
* expect<Or<true, false>>().toBeTrue
|
|
53
|
+
* expect<Or<false, true>>().toBeTrue
|
|
54
|
+
* expect<Or<false, false>>().toBeFalse
|
|
55
|
+
* expect<Or<boolean, false>>().toBe<boolean>().success
|
|
56
|
+
* ```
|
|
34
57
|
*/
|
|
35
58
|
export type Or<A extends boolean, B extends boolean> = [A] extends [never] ? never : [B] extends [never] ? never : [boolean] extends [A] ? boolean : [boolean] extends [B] ? boolean : true extends A ? true : true extends B ? true : false;
|
|
36
59
|
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,GACvD,CAAC,SAAS,KAAK,GAAG,IAAI,GACtB,OAAO,CAAA;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,KAAK,GAAG,KAAK,GACvB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,EAAE,CACZ,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,KAAK,CAAA"}
|
package/esm/main/boolean.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"","sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Negates a boolean type\n *\n * @template T - The boolean type to negate\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<Not<true>>().toBeFalse\n * expect<Not<false>>().toBeTrue\n * expect<Not<boolean>>().toBe<boolean>().success\n * ```\n */\nexport type Not<T extends boolean> = T extends true ? false\n : T extends false ? true\n : boolean\n\n/**\n * Logical AND operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<And<true, true>>().toBeTrue\n * expect<And<true, false>>().toBeFalse\n * expect<And<false, true>>().toBeFalse\n * expect<And<false, false>>().toBeFalse\n * expect<And<boolean, boolean>>().toBe<boolean>().success\n * ```\n */\nexport type And<\n A extends boolean,\n B extends boolean,\n> = A extends never ? never\n : [B] extends [never] ? never\n : (A extends true ? (B extends true ? true : false) : false)\n\n/**\n * Logical OR operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * ### Result\n *\n * - `never`: if either `A` or `B` is `never`\n * - `boolean`: if either `A` or `B` is `boolean` or `any`\n * - `false`: if both `A` and `B` are `false`\n * - `true`: otherwise\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<Or<true, true>>().toBeTrue\n * expect<Or<true, false>>().toBeTrue\n * expect<Or<false, true>>().toBeTrue\n * expect<Or<false, false>>().toBeFalse\n * expect<Or<boolean, false>>().toBe<boolean>().success\n * ```\n */\nexport type Or<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? true\n : true extends B ? true\n : false\n"]}
|
package/esm/main/control.d.ts
CHANGED
|
@@ -1,88 +1,112 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Exact } from './type/compare.js';
|
|
2
2
|
/**
|
|
3
|
-
* Conditional type - returns `
|
|
3
|
+
* Conditional type - returns `Yes` if condition `Condition` is true, otherwise returns `No`
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* - `T`: if `C` is `true`
|
|
9
|
-
* - `F`: if `C` is `false`
|
|
10
|
-
*
|
|
11
|
-
* ### Examples
|
|
5
|
+
* @template Condition - The boolean condition to check
|
|
6
|
+
* @template Yes - The type to return if condition is true
|
|
7
|
+
* @template No - The type to return if condition is false (defaults to `never`)
|
|
12
8
|
*
|
|
9
|
+
* @example
|
|
13
10
|
* ```ts
|
|
14
11
|
* type Result = If<true, 'yes', 'no'> // 'yes'
|
|
15
12
|
* type Result2 = If<false, 'yes', 'no'> // 'no'
|
|
16
|
-
* type
|
|
13
|
+
* type BoolResult = If<boolean, 'yes', 'no'> // boolean
|
|
17
14
|
* ```
|
|
18
15
|
*/
|
|
19
|
-
export type If<
|
|
16
|
+
export type If<Condition extends boolean, Yes, No = never> = Condition extends true ? Yes : No;
|
|
20
17
|
/**
|
|
21
|
-
* Conditional type - returns `
|
|
18
|
+
* Conditional type - returns `Yes` if condition `Condition` is false, otherwise returns `No`
|
|
22
19
|
*
|
|
23
|
-
*
|
|
20
|
+
* @template Condition - The boolean condition to check
|
|
21
|
+
* @template Yes - The type to return if condition is false
|
|
22
|
+
* @template No - The type to return if condition is true (defaults to `never`)
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
* - `T`: if `C` is `false`
|
|
27
|
-
* - `F`: if `C` is `true`
|
|
24
|
+
* ### Result
|
|
28
25
|
*
|
|
29
|
-
*
|
|
26
|
+
* - `never`: if `Condition` is `never`
|
|
27
|
+
* - `Yes`: if `Condition` is `false`
|
|
28
|
+
* - `No`: if `Condition` is `true`
|
|
30
29
|
*
|
|
30
|
+
* @example
|
|
31
31
|
* ```ts
|
|
32
32
|
* type Result = IfFalse<false, 'yes', 'no'> // 'yes'
|
|
33
33
|
* type Result2 = IfFalse<true, 'yes', 'no'> // 'no'
|
|
34
|
-
* type
|
|
34
|
+
* type BoolResult = IfFalse<boolean, 'yes', 'no'> // boolean
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export type IfFalse<
|
|
37
|
+
export type IfFalse<Condition extends boolean, Yes, No = never> = Condition extends false ? Yes : No;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* -
|
|
39
|
+
* Case tuple type used with `SwitchExact` and `SwitchExtends`
|
|
40
|
+
*
|
|
41
|
+
* @template T - The condition type to match against
|
|
42
|
+
* @template Result - The result type to return if match is found
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* type MyCase = Case<1, 'one'>
|
|
47
|
+
* // Equivalent to: [1, 'one']
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see SwitchExact
|
|
42
51
|
*/
|
|
43
|
-
export type Case<T = unknown,
|
|
52
|
+
export type Case<T = unknown, Result = unknown> = [T, Result];
|
|
44
53
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* - {@link Switch}
|
|
48
|
-
* - {@link SwitchExtends}
|
|
54
|
+
* Default case type used with `SwitchExact` and `SwitchExtends`
|
|
49
55
|
*
|
|
50
|
-
*
|
|
56
|
+
* @template T - The default result type
|
|
51
57
|
*
|
|
58
|
+
* @example
|
|
52
59
|
* ```ts
|
|
53
|
-
* type NameMap<id> =
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* Case<3, 'Charlie'>,
|
|
60
|
+
* type NameMap<id> = SwitchExact<id, [
|
|
61
|
+
* [1, 'Alice'],
|
|
62
|
+
* [2, 'Bob'],
|
|
57
63
|
* ], DefaultCase<'Steve'>>
|
|
58
64
|
* ```
|
|
65
|
+
*
|
|
66
|
+
* @see SwitchExact
|
|
59
67
|
*/
|
|
60
68
|
export type DefaultCase<T> = T;
|
|
61
69
|
/**
|
|
62
|
-
*
|
|
70
|
+
* Switch type that uses exact matching logic
|
|
71
|
+
*
|
|
72
|
+
* **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.
|
|
63
73
|
*
|
|
74
|
+
* @template T - The type to match against cases
|
|
75
|
+
* @template Cases - Array of case tuples, each tuple has the form [Condition, Result]
|
|
76
|
+
* @template Default - Default result if no exact match is found (defaults to `never`)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
64
79
|
* ```ts
|
|
65
|
-
* type Result =
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
80
|
+
* type Result = SwitchExact<2, [
|
|
81
|
+
* [1, 'Alice'],
|
|
82
|
+
* [2, 'Bob'],
|
|
83
|
+
* [3, 'Charlie'],
|
|
69
84
|
* ], DefaultCase<'Steve'>>
|
|
70
85
|
*
|
|
71
86
|
* // Result: 'Bob'
|
|
72
87
|
* ```
|
|
73
88
|
*/
|
|
74
|
-
export type
|
|
89
|
+
export type SwitchExact<T, Cases extends readonly [unknown, unknown][], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result : (SwitchExact<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>)) : (never)) : Default;
|
|
75
90
|
/**
|
|
76
|
-
* Switch type that uses 'extends' logic instead of '
|
|
91
|
+
* Switch type that uses 'extends' logic instead of 'Exact' logic
|
|
92
|
+
*
|
|
93
|
+
* **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.
|
|
77
94
|
*
|
|
78
|
-
*
|
|
95
|
+
* @template T - The type to match against cases
|
|
96
|
+
* @template Cases - Array of case tuples, each tuple has the form [Condition, Result]
|
|
97
|
+
* @template Default - Default result if no match is found (defaults to `never`)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
79
100
|
* ```ts
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
101
|
+
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
102
|
+
*
|
|
103
|
+
* expect<
|
|
104
|
+
* SwitchExtends<string, [
|
|
105
|
+
* [number, boolean],
|
|
106
|
+
* [string, boolean],
|
|
107
|
+
* ], Error>
|
|
108
|
+
* >().toBe<boolean>().success
|
|
85
109
|
* ```
|
|
86
110
|
*/
|
|
87
|
-
export type SwitchExtends<T, Cases extends readonly
|
|
111
|
+
export type SwitchExtends<T, Cases extends readonly [unknown, unknown][], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer C, infer R] ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>) : never) : Default;
|
|
88
112
|
//# sourceMappingURL=control.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,EAAE,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,SAAS,SAAS,IAAI,GAAG,GAAG,GAAG,EAAE,CAAA;AAE9F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,OAAO,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,SAAS,SAAS,KAAK,GAAG,GAAG,GAAG,EAAE,CAAA;AAEpG;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,WAAW,CACrB,CAAC,EACD,KAAK,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAC3C,OAAO,GAAG,KAAK,IACb,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAC7C,KAAK,SAAS,CAAC,MAAM,SAAS,EAAE,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,IAAI,GAAG,MAAM,GACpF,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GACvF,CAAC,KAAK,CAAC,CACZ,GACC,OAAO,CAAA;AAEX;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,aAAa,CACvB,CAAC,EACD,KAAK,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAC3C,OAAO,GAAG,KAAK,IACb,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAC7C,KAAK,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC5B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,GAC5G,KAAK,CACV,GACC,OAAO,CAAA"}
|
package/esm/main/control.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from './type/compare.js'\n\n/**\n * Conditional type - returns `Yes` if condition `Condition` is true, otherwise returns `No`\n *\n * @template Condition - The boolean condition to check\n * @template Yes - The type to return if condition is true\n * @template No - The type to return if condition is false (defaults to `never`)\n *\n * @example\n * ```ts\n * type Result = If<true, 'yes', 'no'> // 'yes'\n * type Result2 = If<false, 'yes', 'no'> // 'no'\n * type BoolResult = If<boolean, 'yes', 'no'> // boolean\n * ```\n */\nexport type If<Condition extends boolean, Yes, No = never> = Condition extends true ? Yes : No\n\n/**\n * Conditional type - returns `Yes` if condition `Condition` is false, otherwise returns `No`\n *\n * @template Condition - The boolean condition to check\n * @template Yes - The type to return if condition is false\n * @template No - The type to return if condition is true (defaults to `never`)\n *\n * ### Result\n *\n * - `never`: if `Condition` is `never`\n * - `Yes`: if `Condition` is `false`\n * - `No`: if `Condition` is `true`\n *\n * @example\n * ```ts\n * type Result = IfFalse<false, 'yes', 'no'> // 'yes'\n * type Result2 = IfFalse<true, 'yes', 'no'> // 'no'\n * type BoolResult = IfFalse<boolean, 'yes', 'no'> // boolean\n * ```\n */\nexport type IfFalse<Condition extends boolean, Yes, No = never> = Condition extends false ? Yes : No\n\n/**\n * Case tuple type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The condition type to match against\n * @template Result - The result type to return if match is found\n *\n * @example\n * ```ts\n * type MyCase = Case<1, 'one'>\n * // Equivalent to: [1, 'one']\n * ```\n *\n * @see SwitchExact\n */\nexport type Case<T = unknown, Result = unknown> = [T, Result]\n\n/**\n * Default case type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The default result type\n *\n * @example\n * ```ts\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type DefaultCase<T> = T\n\n/**\n * Switch type that uses exact matching logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no exact match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * type Result = SwitchExact<2, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * [3, 'Charlie'],\n * ], DefaultCase<'Steve'>>\n *\n * // Result: 'Bob'\n * ```\n */\nexport type SwitchExact<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result\n : (SwitchExact<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>))\n : (never)\n )\n : Default\n\n/**\n * Switch type that uses 'extends' logic instead of 'Exact' logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<\n * SwitchExtends<string, [\n * [number, boolean],\n * [string, boolean],\n * ], Error>\n * >().toBe<boolean>().success\n * ```\n */\nexport type SwitchExtends<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer C, infer R]\n ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>)\n : never\n )\n : Default\n"]}
|
package/esm/main/doc.d.ts
CHANGED
|
@@ -1,30 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Append documentation or auxiliary metadata to type `
|
|
2
|
+
* Append documentation or auxiliary metadata to type `T`
|
|
3
3
|
* without changing its shape.
|
|
4
4
|
*
|
|
5
|
-
* This type intersects `Doc` onto `
|
|
6
|
-
* originally defined in `
|
|
5
|
+
* This type intersects `Doc` onto `T`, but only keeps the keys
|
|
6
|
+
* originally defined in `T`. As a result:
|
|
7
7
|
*
|
|
8
8
|
* - `Doc` cannot introduce new properties
|
|
9
|
-
* - Existing properties in `
|
|
9
|
+
* - Existing properties in `T` are preserved
|
|
10
10
|
* - `Doc` may further constrain or annotate existing properties
|
|
11
11
|
*
|
|
12
12
|
* This is typically used to attach JSDoc comments, branding,
|
|
13
13
|
* or editor-only metadata to an existing type while keeping
|
|
14
14
|
* its public structure intact.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The target type to append documentation to
|
|
17
|
+
* @template Doc - The documentation or metadata type to append
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
22
|
+
*
|
|
23
|
+
* type User = { name: string; age: number }
|
|
24
|
+
* type UserWithDoc = AppendDoc<User, { name: string }>
|
|
25
|
+
*
|
|
26
|
+
* expect<UserWithDoc>().toBe<User>().success
|
|
27
|
+
* ```
|
|
15
28
|
*/
|
|
16
29
|
export type AppendDoc<T, Doc> = Pick<T & Doc, keyof T>;
|
|
17
30
|
/**
|
|
18
|
-
* Prepend documentation or auxiliary metadata to type `
|
|
31
|
+
* Prepend documentation or auxiliary metadata to type `T`
|
|
19
32
|
* without changing its shape.
|
|
20
33
|
*
|
|
21
34
|
* This is similar to {@link AppendDoc}, but the intersection order
|
|
22
|
-
* is reversed (`Doc &
|
|
35
|
+
* is reversed (`Doc & T`), which can affect how property types,
|
|
23
36
|
* documentation, and hover information are presented by tooling.
|
|
24
37
|
*
|
|
25
38
|
* In practice, this allows `Doc` to act as a non-invasive,
|
|
26
|
-
* descriptive layer while ensuring `
|
|
39
|
+
* descriptive layer while ensuring `T` remains the authoritative
|
|
27
40
|
* source of truth for property types.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The target type to prepend documentation to
|
|
43
|
+
* @template Doc - The documentation or metadata type to prepend
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { expect } from '@leawind/lay-sing/test-utils'
|
|
48
|
+
*
|
|
49
|
+
* type User = { name: string; age: number }
|
|
50
|
+
* type UserWithDoc = PrependDoc<User, { age: number }>
|
|
51
|
+
*
|
|
52
|
+
* expect<UserWithDoc>().toBe<User>().success
|
|
53
|
+
* ```
|
|
28
54
|
*/
|
|
29
55
|
export type PrependDoc<T, Doc> = Pick<Doc & T, keyof T>;
|
|
30
56
|
//# sourceMappingURL=doc.d.ts.map
|
package/esm/main/doc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/main/doc.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/main/doc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA"}
|