@planet-matrix/mobius-model 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +30 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +22 -4
- package/package.json +3 -3
- package/scripts/build.ts +4 -4
- package/src/basic/README.md +144 -0
- package/src/basic/array.ts +872 -0
- package/src/basic/bigint.ts +114 -0
- package/src/basic/boolean.ts +180 -0
- package/src/basic/enhance.ts +10 -0
- package/src/basic/error.ts +51 -0
- package/src/basic/function.ts +453 -0
- package/src/basic/helper.ts +276 -0
- package/src/basic/index.ts +17 -0
- package/src/basic/is.ts +320 -0
- package/src/basic/number.ts +178 -0
- package/src/basic/object.ts +140 -0
- package/src/basic/promise.ts +464 -0
- package/src/basic/regexp.ts +7 -0
- package/src/basic/stream.ts +140 -0
- package/src/basic/string.ts +308 -0
- package/src/basic/symbol.ts +164 -0
- package/src/basic/temporal.ts +224 -0
- package/src/encoding/README.md +105 -0
- package/src/encoding/base64.ts +98 -0
- package/src/encoding/index.ts +1 -0
- package/src/index.ts +4 -0
- package/src/random/README.md +109 -0
- package/src/random/index.ts +1 -0
- package/src/random/uuid.ts +103 -0
- package/src/type/README.md +330 -0
- package/src/type/array.ts +5 -0
- package/src/type/boolean.ts +471 -0
- package/src/type/class.ts +419 -0
- package/src/type/function.ts +1519 -0
- package/src/type/helper.ts +135 -0
- package/src/type/index.ts +14 -0
- package/src/type/intersection.ts +93 -0
- package/src/type/is.ts +247 -0
- package/src/type/iteration.ts +233 -0
- package/src/type/number.ts +732 -0
- package/src/type/object.ts +788 -0
- package/src/type/path.ts +73 -0
- package/src/type/string.ts +1004 -0
- package/src/type/tuple.ts +2424 -0
- package/src/type/union.ts +108 -0
- package/tests/unit/basic/array.spec.ts +290 -0
- package/tests/unit/basic/bigint.spec.ts +50 -0
- package/tests/unit/basic/boolean.spec.ts +74 -0
- package/tests/unit/basic/error.spec.ts +32 -0
- package/tests/unit/basic/function.spec.ts +175 -0
- package/tests/unit/basic/helper.spec.ts +118 -0
- package/tests/unit/basic/number.spec.ts +74 -0
- package/tests/unit/basic/object.spec.ts +46 -0
- package/tests/unit/basic/promise.spec.ts +232 -0
- package/tests/unit/basic/regexp.spec.ts +11 -0
- package/tests/unit/basic/stream.spec.ts +120 -0
- package/tests/unit/basic/string.spec.ts +74 -0
- package/tests/unit/basic/symbol.spec.ts +72 -0
- package/tests/unit/basic/temporal.spec.ts +78 -0
- package/tests/unit/encoding/base64.spec.ts +40 -0
- package/tests/unit/random/uuid.spec.ts +37 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/reactor/index.d.ts +0 -3
- package/dist/reactor/index.d.ts.map +0 -1
- package/dist/reactor/reactor-core/flags.d.ts +0 -99
- package/dist/reactor/reactor-core/flags.d.ts.map +0 -1
- package/dist/reactor/reactor-core/index.d.ts +0 -4
- package/dist/reactor/reactor-core/index.d.ts.map +0 -1
- package/dist/reactor/reactor-core/primitive.d.ts +0 -276
- package/dist/reactor/reactor-core/primitive.d.ts.map +0 -1
- package/dist/reactor/reactor-core/reactive-system.d.ts +0 -241
- package/dist/reactor/reactor-core/reactive-system.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/branch.d.ts +0 -19
- package/dist/reactor/reactor-operators/branch.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/convert.d.ts +0 -30
- package/dist/reactor/reactor-operators/convert.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/create.d.ts +0 -26
- package/dist/reactor/reactor-operators/create.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/filter.d.ts +0 -269
- package/dist/reactor/reactor-operators/filter.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/index.d.ts +0 -8
- package/dist/reactor/reactor-operators/index.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/join.d.ts +0 -48
- package/dist/reactor/reactor-operators/join.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/map.d.ts +0 -165
- package/dist/reactor/reactor-operators/map.d.ts.map +0 -1
- package/dist/reactor/reactor-operators/utility.d.ts +0 -48
- package/dist/reactor/reactor-operators/utility.d.ts.map +0 -1
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# Type
|
|
2
|
+
|
|
3
|
+
Advanced TypeScript type utilities for string manipulation and type-level gymnastics.
|
|
4
|
+
|
|
5
|
+
## For Users
|
|
6
|
+
|
|
7
|
+
This module provides TypeScript type utilities that cover common type-level programming tasks. It is organized by domain and by capability so you can quickly locate the right tool for a specific problem.
|
|
8
|
+
|
|
9
|
+
### 1. Domain Areas
|
|
10
|
+
|
|
11
|
+
1. Helper: Shared internal building blocks used across domains.
|
|
12
|
+
2. Is: Generic predicates and basic type guards at the type level.
|
|
13
|
+
3. Union: Utilities for building, filtering, and comparing union types.
|
|
14
|
+
4. Intersection: Utilities for composing and analyzing intersection types.
|
|
15
|
+
5. String: Validation, comparison, queries, slicing, and transformation for string literal types.
|
|
16
|
+
6. Path: Parsing and access helpers for dot-path strings and object path navigation.
|
|
17
|
+
7. Boolean: Logical composition and boolean collection helpers.
|
|
18
|
+
8. Number: Numeric checks, comparisons, arithmetic, and range construction for number literal types.
|
|
19
|
+
9. Object: Key/value queries, structural reshaping, and property-level composition.
|
|
20
|
+
10. Function: Parameter and return extraction, comparisons, and function-shape transformations.
|
|
21
|
+
11. Tuple: Tuple length, element access, mapping, and composition utilities.
|
|
22
|
+
12. Class: Constructor and instance shape helpers for class-based typing.
|
|
23
|
+
13. Iteration: Iterative helpers for building or traversing type-level sequences.
|
|
24
|
+
|
|
25
|
+
### 2. Capability Categories
|
|
26
|
+
|
|
27
|
+
These categories mirror the contributor groupings to keep terminology consistent across docs and source files.
|
|
28
|
+
|
|
29
|
+
1. Helpers: Internal building blocks used by other types.
|
|
30
|
+
2. Primitives: Core domain-specific primitives and base helpers.
|
|
31
|
+
3. Validation: Presence checks, format checks, and equality checks.
|
|
32
|
+
4. Comparison: Ordering, equality, and compatibility checks.
|
|
33
|
+
5. Query: Length, count, index, and metadata queries.
|
|
34
|
+
6. Generation: Creating new literal values, ranges, or repeated structures.
|
|
35
|
+
7. Extraction: Pulling out segments, first/last elements, or subsets.
|
|
36
|
+
8. Manipulation: Replacing, concatenating, mapping, and transforming shapes.
|
|
37
|
+
9. Conversion: Converting between string/number/boolean or related domains.
|
|
38
|
+
|
|
39
|
+
For a full list of types, see the domain files (String, Number, Function, Object, Path, etc.).
|
|
40
|
+
|
|
41
|
+
## For Contributors
|
|
42
|
+
|
|
43
|
+
This guide documents the conventions and best practices for implementing type utilities in this module. All implementations should follow these patterns for consistency and maintainability.
|
|
44
|
+
|
|
45
|
+
### 1. File Organization and Grouping
|
|
46
|
+
|
|
47
|
+
#### 1.1 Group Structure
|
|
48
|
+
|
|
49
|
+
Each type utility file should be organized into logical groups using section headers:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Group Name
|
|
54
|
+
// ============================================================================
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Group Header Rules:**
|
|
58
|
+
- Use exactly 76 equal signs (to reach column 80).
|
|
59
|
+
- Group name should be descriptive and use Title Case.
|
|
60
|
+
- Add one blank line before the header block and one blank line after.
|
|
61
|
+
|
|
62
|
+
#### 1.2 Grouping Logic and Order
|
|
63
|
+
|
|
64
|
+
Groups should follow a logical progression from **simple to complex** and **general to specific**:
|
|
65
|
+
|
|
66
|
+
1. Helpers: Common helper types within the module, such as `KeyOfBase`, `Cast`, `If`, `Try`, `IsEqual` in `Helper`, and internal helpers like `InternalBuildArray` in `Number`.
|
|
67
|
+
2. Primitives: Types closely related to the module's core types, such as `NumberSign` and `NumberDigitCount` in `Number`, `StringAutoCompletable`, `UppercaseLetter`, `LowercaseLetter`, `DigitCharacter` in `String`, `FunctionNoop`, `FunctionIdentity`, `FunctionConstant` in `Function`, and `TupleEmpty`, `TupleSingleton` in `Tuple`.
|
|
68
|
+
3. Validation: Types for validation or checking, such as `StringIsNumber`, `StringIsAlpha`, `StringIsEmpty`, `StringIsUpperCase` in `String`, `NumberIsZero`, `NumberIsPositive`, `NumberIsNegative`, `NumberIsEven` in `Number`, `FunctionIsAsync` in `Function`, `ClassIsConstructor` in `Class`.
|
|
69
|
+
4. Comparison: Types for comparing values, such as `StringIsEqual`, `StringStartsWith`, `StringEndsWith` in `String`, `NumberIsEqual`, `NumberGreaterThan`, `NumberLessThan` in `Number`, `FunctionParametersEqual` in `Function`, `TupleIsEqual`, `TupleStartsWith`, `TupleEndsWith` in `Tuple`.
|
|
70
|
+
5. Query: Types for querying information without transformation, such as `StringLength`, `StringCount`, `StringIndexOf` in `String`, `FunctionLength`, `FunctionArity` in `Function`, `TupleLength`, `TupleIndexOf` in `Tuple`, and `ClassConstructorArity` in `Class`.
|
|
71
|
+
6. Generation: Types for creating new values from scratch, such as `StringRepeat` in `String`, `TupleRepeat`, `TupleRange`, `TupleCombinations` in `Tuple`.
|
|
72
|
+
7. Extraction: Types for extracting partial content, such as `StringFirst`, `StringLast`, `StringAt` in `String`, `TupleHead`, `TupleTail`, `TupleAt` in `Tuple`.
|
|
73
|
+
8. Manipulation: Types for modifying values, such as `StringTakeFirst`, `StringReplaceAll`, `StringTrim`, `StringSplit`, `StringJoin` in `String`, `NumberAdd`, `NumberSubtract`, `NumberMultiply` in `Number`, `FunctionBind`, `FunctionInsertParameter`, `FunctionRemoveParameter` in `Function`, `ObjectMerge`, `ObjectAssign`, `ObjectOverwrite` in `Object`, and `TupleMap`, `TupleFilter`, `TupleAppend` in `Tuple`.
|
|
74
|
+
9. Conversion: Types for converting between different domains, such as `NumberToString`, `NumberToBoolean` in `Number`, `BooleanToNumber`, `BooleanToString` in `Boolean`, `TupleToUnion`, `TupleToObject`, `TupleToArray`, `TupleToString` in `Tuple`, `UnionToIntersection`, `UnionToTuple` in `Union`, `ObjectToFunction` in `Object`, and `ClassConstructorToFunction` or `FunctionToClassConstructor` in `Class`/`Function`.
|
|
75
|
+
|
|
76
|
+
### 2. Documentation and Comments
|
|
77
|
+
|
|
78
|
+
#### 2.1 JSDoc Comment Format
|
|
79
|
+
|
|
80
|
+
Every exported type must have a JSDoc comment following this structure:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
/**
|
|
84
|
+
* Brief one-line description of what the type does.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```
|
|
88
|
+
* // Expect: <expected result>
|
|
89
|
+
* type Example1 = TypeName<...>
|
|
90
|
+
* // Expect: <expected result>
|
|
91
|
+
* type Example2 = TypeName<...>
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export type TypeName<...> = ...
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Documentation Rules:**
|
|
98
|
+
- First line: Clear, concise description starting with a verb (Check, Get, Convert, etc.)
|
|
99
|
+
- Add a blank line after the description
|
|
100
|
+
- Use `@example` tag followed by triple backticks
|
|
101
|
+
- Include multiple example cases showing different scenarios
|
|
102
|
+
- Use comment format: `// Expect: <result>`
|
|
103
|
+
- Use descriptive example names: `Example1`, `Example2`, `Example3`, etc.
|
|
104
|
+
- Include edge cases (empty values, single elements, etc.)
|
|
105
|
+
|
|
106
|
+
#### 2.2 Example Writing Guidelines
|
|
107
|
+
|
|
108
|
+
**Good Examples:**
|
|
109
|
+
```typescript
|
|
110
|
+
/**
|
|
111
|
+
* Check if a string starts with a prefix.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```
|
|
115
|
+
* // Expect: true
|
|
116
|
+
* type Example1 = StringStartsWith<'hello world', 'hello'>
|
|
117
|
+
* // Expect: false
|
|
118
|
+
* type Example2 = StringStartsWith<'hello world', 'world'>
|
|
119
|
+
* // Expect: true
|
|
120
|
+
* type Example3 = StringStartsWith<'', ''>
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Coverage Priority:**
|
|
126
|
+
1. Typical use case (most common scenario)
|
|
127
|
+
2. Edge cases (empty, single element, boundary conditions)
|
|
128
|
+
3. Negative cases (when the operation fails or returns false)
|
|
129
|
+
4. Complex cases (if applicable)
|
|
130
|
+
|
|
131
|
+
### 3. Type Implementation Patterns
|
|
132
|
+
|
|
133
|
+
#### 3.1 Internal Helper Types
|
|
134
|
+
|
|
135
|
+
When a type requires a complex implementation with accumulator parameters or intermediate state, use an `Internal`-prefixed helper type:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Internal helper type - not exported
|
|
139
|
+
type InternalStringLength<S extends string, Acc extends readonly unknown[]> =
|
|
140
|
+
S extends `${string}${infer Rest}`
|
|
141
|
+
? InternalStringLength<Rest, [...Acc, unknown]>
|
|
142
|
+
: Acc['length']
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get the length of a string literal type.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```
|
|
149
|
+
* // Expect: 5
|
|
150
|
+
* type Example1 = StringLength<'hello'>
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export type StringLength<S extends string> = InternalStringLength<S, []>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Internal Type Rules:**
|
|
157
|
+
- Prefix with `Internal`
|
|
158
|
+
- Do NOT export
|
|
159
|
+
- Define immediately before the public type that uses it
|
|
160
|
+
- NO blank line between the internal helper and the public type
|
|
161
|
+
- Include all implementation details (accumulators, counters, flags)
|
|
162
|
+
- The public API should hide complexity and provide clean, minimal parameters
|
|
163
|
+
|
|
164
|
+
#### 3.2 Recursive Patterns
|
|
165
|
+
|
|
166
|
+
Most type gymnastics use recursion. Common patterns:
|
|
167
|
+
|
|
168
|
+
**Pattern 1: Tail Recursion with Accumulator**
|
|
169
|
+
```typescript
|
|
170
|
+
type InternalReverse<S extends string, Acc extends string = ''> =
|
|
171
|
+
S extends `${infer First}${infer Rest}`
|
|
172
|
+
? InternalReverse<Rest, `${First}${Acc}`>
|
|
173
|
+
: Acc
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Pattern 2: Array/Tuple Length as Counter**
|
|
177
|
+
```typescript
|
|
178
|
+
type InternalRepeat<
|
|
179
|
+
S extends string,
|
|
180
|
+
N extends number,
|
|
181
|
+
Acc extends string,
|
|
182
|
+
Count extends readonly unknown[]
|
|
183
|
+
> = Count['length'] extends N
|
|
184
|
+
? Acc
|
|
185
|
+
: InternalRepeat<S, N, `${Acc}${S}`, [...Count, unknown]>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Pattern 3: Distributed Conditional Types**
|
|
189
|
+
```typescript
|
|
190
|
+
type StringSplit<S extends string, Separator extends string> =
|
|
191
|
+
S extends `${infer First}${Separator}${infer Rest}`
|
|
192
|
+
? [First, ...StringSplit<Rest, Separator>]
|
|
193
|
+
: (S extends '' ? [] : [S])
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Pattern 4: Type Narrowing with Extends**
|
|
197
|
+
```typescript
|
|
198
|
+
export type BooleanAnd<T extends boolean, U extends boolean> =
|
|
199
|
+
T extends true
|
|
200
|
+
? (U extends true ? true : false)
|
|
201
|
+
: false
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Ternary Formatting Rules:**
|
|
205
|
+
|
|
206
|
+
When working with nested conditional types (ternary operations):
|
|
207
|
+
|
|
208
|
+
1. **Single-level ternary**: Can be written inline if simple and readable
|
|
209
|
+
```typescript
|
|
210
|
+
type Simple<T> = T extends string ? true : false
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
2. **Two or more levels of nesting**: **MUST** wrap the second level and beyond in parentheses
|
|
214
|
+
```typescript
|
|
215
|
+
// ✅ Correct - nested ternary wrapped in parentheses
|
|
216
|
+
type Nested<T> =
|
|
217
|
+
T extends string
|
|
218
|
+
? (T extends '' ? 'empty' : 'non-empty')
|
|
219
|
+
: false
|
|
220
|
+
|
|
221
|
+
// ❌ Wrong - missing parentheses on nested ternary
|
|
222
|
+
type Wrong<T> =
|
|
223
|
+
T extends string
|
|
224
|
+
? T extends '' ? 'empty' : 'non-empty'
|
|
225
|
+
: false
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
3. **Line breaks**: If the nested ternary can fit on one line and remain readable, keep it on one line. Only break into multiple lines when it improves clarity for complex expressions.
|
|
229
|
+
|
|
230
|
+
4. **Readability**: If a ternary becomes too complex (3+ levels), consider extracting to helper types
|
|
231
|
+
|
|
232
|
+
This ensures code clarity and makes the nesting structure immediately visible.
|
|
233
|
+
|
|
234
|
+
#### 3.3 Parameter Constraints
|
|
235
|
+
|
|
236
|
+
Always use proper constraints for type parameters:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
// String operations
|
|
240
|
+
export type StringReverse<S extends string> = ...
|
|
241
|
+
|
|
242
|
+
// Boolean operations
|
|
243
|
+
export type BooleanAnd<T extends boolean, U extends boolean> = ...
|
|
244
|
+
|
|
245
|
+
// Array/Tuple operations
|
|
246
|
+
export type BooleanAll<T extends readonly boolean[]> = ...
|
|
247
|
+
|
|
248
|
+
// Number constraints
|
|
249
|
+
export type StringRepeat<S extends string, N extends number> = ...
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Key Points:**
|
|
253
|
+
- Use `extends string`, `extends boolean`, `extends number` for primitive types
|
|
254
|
+
- Use `extends readonly T[]` for immutable arrays/tuples
|
|
255
|
+
- Use `extends unknown` for generic or any type parameters
|
|
256
|
+
- Add default values when appropriate (e.g., `First extends boolean = true`)
|
|
257
|
+
|
|
258
|
+
### 4. Naming Conventions
|
|
259
|
+
|
|
260
|
+
#### 4.1 Type Name Format
|
|
261
|
+
|
|
262
|
+
All types should follow a consistent naming pattern:
|
|
263
|
+
|
|
264
|
+
**Format:** `<Domain><Operation><Qualifier>`
|
|
265
|
+
|
|
266
|
+
- **Domain:** `String`, `Boolean`, `Number`, `Array`, `Object`, `Path`, etc.
|
|
267
|
+
- **Operation:** Verb describing the action (Check, Get, Convert, Split, etc.)
|
|
268
|
+
- **Qualifier:** Optional descriptor (First, Last, All, etc.)
|
|
269
|
+
|
|
270
|
+
**Examples:**
|
|
271
|
+
- `StringSplitToWords` - domain: String, operation: Split, qualifier: ToWords
|
|
272
|
+
- `BooleanCountTrue` - domain: Boolean, operation: Count, qualifier: True
|
|
273
|
+
- `StringIsEmpty` - domain: String, operation: Is, qualifier: Empty
|
|
274
|
+
|
|
275
|
+
#### 4.2 Common Verb Prefixes
|
|
276
|
+
|
|
277
|
+
- `Is*` - Returns boolean for validation or checking
|
|
278
|
+
- Examples: `IsEmpty`, `IsNumber`, `IsAlpha`, `IsEqual`
|
|
279
|
+
- `Has*` - Returns boolean for existence checking
|
|
280
|
+
- Examples: `HasPrefix`, `HasSuffix`
|
|
281
|
+
- `Get*` / `Extract*` - Returns a value
|
|
282
|
+
- Examples: `GetFirst`, `ExtractGroups`
|
|
283
|
+
- `String*` / `Boolean*` / etc. - Domain-scoped operations
|
|
284
|
+
- Examples: `StringReverse`, `BooleanAnd`, `PathJoin`
|
|
285
|
+
- `To*` - Conversion operations
|
|
286
|
+
- Examples: `ToString`, `ToNumber`, `ToBoolean`
|
|
287
|
+
|
|
288
|
+
#### 4.3 Alias Types
|
|
289
|
+
|
|
290
|
+
Provide intuitive aliases when appropriate:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
export type BooleanAll<T extends readonly boolean[]> = ...
|
|
294
|
+
export type BooleanEvery<T extends readonly boolean[]> = BooleanAll<T>
|
|
295
|
+
|
|
296
|
+
export type BooleanAny<T extends readonly boolean[]> = ...
|
|
297
|
+
export type BooleanSome<T extends readonly boolean[]> = BooleanAny<T>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### 5. Export Strategy
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
// Always export public types
|
|
304
|
+
export type PublicType<T> = ...
|
|
305
|
+
|
|
306
|
+
// Never export internal helpers
|
|
307
|
+
type InternalHelper<T, Acc> = ...
|
|
308
|
+
|
|
309
|
+
// Export commonly used aliases
|
|
310
|
+
export type Alias<T> = PublicType<T>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 6. Common Pitfalls to Avoid
|
|
314
|
+
|
|
315
|
+
1. ❌ **Don't expose implementation details** in public APIs
|
|
316
|
+
2. ❌ **Don't use ambiguous names** (prefer `StringLength` over `Length`)
|
|
317
|
+
3. ❌ **Don't skip documentation** - every export needs JSDoc comments
|
|
318
|
+
4. ❌ **Don't forget edge cases** in examples
|
|
319
|
+
5. ❌ **Don't create circular dependencies** between types
|
|
320
|
+
6. ❌ **Don't over-optimize** at the cost of readability
|
|
321
|
+
7. ❌ **Don't use overly generic names** that might cause conflicts
|
|
322
|
+
|
|
323
|
+
## Thanks
|
|
324
|
+
|
|
325
|
+
This module is inspired by and borrows ideas from the following projects:
|
|
326
|
+
|
|
327
|
+
- [ts-toolbelt](https://github.com/millsp/ts-toolbelt): 👷 TypeScript's largest type utility library.
|
|
328
|
+
- [type-fest](https://github.com/sindresorhus/type-fest): A collection of essential TypeScript types.
|
|
329
|
+
- [ts-essentials](https://github.com/ts-essentials/ts-essentials): All essential TypeScript types in one place 🤙
|
|
330
|
+
- [type-challenges](https://github.com/type-challenges/type-challenges): Collection of TypeScript type challenges with online judge.
|