@xaendar/types 0.6.14 → 0.6.15

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.
@@ -34,6 +34,18 @@ export declare type AccessorDecorator<Class extends object, Value = unknown> = (
34
34
  */
35
35
  export declare type AsyncFunction<Arguments extends any[] = any[], ReturnType = void> = Arguments extends Array<any> ? (...args: Arguments) => Promise<ReturnType> : () => Promise<ReturnType>;
36
36
 
37
+ /**
38
+ * Flattens the display of an intersection or mapped type so that IDEs show
39
+ * the resolved property list instead of the raw intersection expression.
40
+ *
41
+ * Useful for improving hover information on complex composed types.
42
+ *
43
+ * @template T - The object type to beautify.
44
+ *
45
+ * @example
46
+ * type Merged = Beautify<{ a: string } & { b: number }>;
47
+ * // Hovering shows: { a: string; b: number }
48
+ */
37
49
  export declare type Beautify<T extends Object> = {
38
50
  [K in keyof T]: T[K];
39
51
  } & {};
@@ -55,6 +67,15 @@ export declare type ClassAccessorDecoratorValue<Field = unknown> = {
55
67
  set(this: unknown, value: Field): void;
56
68
  };
57
69
 
70
+ /**
71
+ * Represents a TC39 stage-3 class decorator function.
72
+ *
73
+ * Receives the class constructor and its decorator context and may return a
74
+ * replacement constructor or `void` to leave the original unchanged.
75
+ *
76
+ * @template T - The instance type of the decorated class.
77
+ * @template Statics - Optional static members of the class.
78
+ */
58
79
  declare type ClassDecorator_2<T extends Object, Statics extends {
59
80
  [key: string]: any;
60
81
  } = {
@@ -67,12 +88,49 @@ export { ClassDecorator_2 as ClassDecorator }
67
88
  */
68
89
  export declare type Constructor<T extends object = object, Statics extends Record<string, unknown> | undefined = undefined> = (new (...args: any[]) => T) & (Statics extends undefined ? object : Statics);
69
90
 
91
+ /**
92
+ * Recursively checks whether a string literal type contains a specific
93
+ * single-character substring.
94
+ *
95
+ * Resolves to `true` if `Contains` is found anywhere in `String`,
96
+ * or `false` if it is absent.
97
+ *
98
+ * @template String - The string literal type to inspect.
99
+ * @template Contains - The single character to search for.
100
+ *
101
+ * @example
102
+ * type HasMinus = ContainsChar<'-1', '-'>; // true
103
+ * type HasDot = ContainsChar<'42', '.'>; // false
104
+ */
70
105
  export declare type ContainsChar<String extends string, Contains extends string> = String extends `${infer First}${infer Rest}` ? First extends Contains ? true : ContainsChar<Rest, Contains> : false;
71
106
 
107
+ /**
108
+ * A strongly-typed key/value map where every value is optional.
109
+ *
110
+ * Useful as a looser alternative to `Record<K, V>` when not all keys
111
+ * are guaranteed to be present.
112
+ *
113
+ * @template Key - The allowed key type. Must be a string or number.
114
+ * @template Value - The type of each value. Defaults to `string`.
115
+ *
116
+ * @example
117
+ * const headers: Dictionary<string, string> = { 'Content-Type': 'application/json' };
118
+ */
72
119
  export declare type Dictionary<Key extends string | number, Value = string> = {
73
120
  [K in Key]?: Value;
74
121
  };
75
122
 
123
+ /**
124
+ * Represents a TC39 stage-3 class field decorator function.
125
+ *
126
+ * Receives the initial `undefined` value and the field decorator context.
127
+ * Returns an initializer that maps the declared field value to its stored
128
+ * (possibly transformed) representation.
129
+ *
130
+ * @template Class - The class that owns the decorated field.
131
+ * @template Field - The declared type of the field.
132
+ * @template ReturnType - The type the initializer transforms the value into. Defaults to `Field`.
133
+ */
76
134
  export declare type FieldDecorator<Class extends Object, Field, ReturnType = Field> = (field: undefined, context: ClassFieldDecoratorContext<Class, Field>) => ((value: Field) => ReturnType);
77
135
 
78
136
  /**
@@ -81,9 +139,30 @@ export declare type FieldDecorator<Class extends Object, Field, ReturnType = Fie
81
139
  declare type Function_2<Arguments extends any[] = any[], ReturnType = void> = Arguments extends Array<any> ? (...args: Arguments) => ReturnType : () => ReturnType;
82
140
  export { Function_2 as Function }
83
141
 
142
+ /**
143
+ * Represents a TC39 stage-3 class method decorator function.
144
+ *
145
+ * Receives the original method and its decorator context, and may return a
146
+ * replacement method or `void` to leave the original unchanged.
147
+ *
148
+ * @template T - The class that owns the decorated method.
149
+ * @template Method - The type of the method being decorated.
150
+ */
84
151
  declare type MethodDecorator_2<T extends Object, Method extends Function_2> = (value: Method, context: ClassMethodDecoratorContext<T, Method>) => Method | void;
85
152
  export { MethodDecorator_2 as MethodDecorator }
86
153
 
154
+ /**
155
+ * Removes the `readonly` modifier from every property of an object type,
156
+ * producing a fully mutable version.
157
+ *
158
+ * The inverse of `Readonly<T>`.
159
+ *
160
+ * @template T - The object type whose properties should become mutable.
161
+ *
162
+ * @example
163
+ * type MutablePoint = Mutable<{ readonly x: number; readonly y: number }>;
164
+ * // { x: number; y: number }
165
+ */
87
166
  export declare type Mutable<T extends Object> = {
88
167
  -readonly [P in keyof T]: T[P];
89
168
  };
@@ -117,12 +196,55 @@ export declare type NoArgsFunction<ReturnType = void> = () => ReturnType;
117
196
  */
118
197
  export declare type NoArgsVoidFunction = () => void;
119
198
 
199
+ /**
200
+ * Resolves to `Value` when it is a positive integer, or `never` otherwise.
201
+ *
202
+ * Rejects negative numbers (contain `'-'`) and non-integer numbers (contain `'.'`).
203
+ * Useful as a compile-time constraint for length or count parameters.
204
+ *
205
+ * @template Value - The numeric literal to validate.
206
+ *
207
+ * @example
208
+ * type Valid = PositiveInteger<5>; // 5
209
+ * type Invalid = PositiveInteger<-1>; // never
210
+ * type Float = PositiveInteger<1.5>; // never
211
+ */
120
212
  export declare type PositiveInteger<Value extends number> = ContainsChar<`${Value}`, '-'> extends true ? never : ContainsChar<`${Value}`, '.'> extends true ? never : Value;
121
213
 
214
+ /**
215
+ * Creates a type from `T` where at least one of the specified `Keys` must
216
+ * be provided, while the remaining keys stay optional.
217
+ *
218
+ * Useful for option bags where a minimum of one field is required to avoid
219
+ * ambiguous or meaningless configurations.
220
+ *
221
+ * @template T - The base object type.
222
+ * @template Keys - The subset of keys of which at least one must be present.
223
+ * Defaults to all keys of `T`.
224
+ *
225
+ * @example
226
+ * type SearchParams = RequireOne<{ query?: string; id?: number }>;
227
+ * // Valid: { query: 'foo' } | { id: 42 } | { query: 'foo', id: 42 }
228
+ * // Invalid: {} (TypeScript error)
229
+ */
122
230
  export declare type RequireOne<T extends Object, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
123
231
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
124
232
  }[Keys];
125
233
 
234
+ /**
235
+ * Constructs a fixed-length tuple of type `TupleType` with exactly `Length`
236
+ * elements.
237
+ *
238
+ * Resolves to `never` when `Length` is not a positive integer.
239
+ *
240
+ * @template Length - The number of elements. Must be a positive integer.
241
+ * @template TupleType - The element type. Defaults to `number`.
242
+ * @template Acc - Internal accumulator (do not provide manually).
243
+ *
244
+ * @example
245
+ * type Three = TupleOfLength<3, string>; // [string, string, string]
246
+ * type Bad = TupleOfLength<0, string>; // never
247
+ */
126
248
  export declare type TupleOfLength<Length extends number, TupleType = number, Acc extends TupleType[] = []> = PositiveInteger<Length> extends never ? never : Acc['length'] extends Length ? Acc : TupleOfLength<Length, TupleType, [...Acc, TupleType]>;
127
249
 
128
250
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/types",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
  "description": "A library containing common types shared across packages and consumers",
5
5
  "sideEffects": false,
6
6
  "type": "module",