@xaendar/types 0.12.0 → 0.13.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/dist/xaendar-types.d.ts +61 -24
- package/package.json +1 -1
package/dist/xaendar-types.d.ts
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* An abstract constructor function type that can accept any number of arguments
|
|
3
3
|
* and return an instance of the specified type.
|
|
4
4
|
*/
|
|
5
|
-
export declare type AbstractConstructor<T extends object = object, Statics extends Record<string, unknown> | undefined = undefined> = (abstract new (...args: any[]) => T) & (Statics extends undefined ? object : Statics)
|
|
5
|
+
export declare type AbstractConstructor<T extends object = object, Statics extends Record<string, unknown> | undefined = undefined> = (abstract new (...args: any[]) => T) & (Statics extends undefined ? object : Statics) & {
|
|
6
|
+
prototype: T;
|
|
7
|
+
};
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
* Represents a class accessor decorator function.
|
|
9
|
-
*
|
|
10
|
-
* Note: the `context` parameter uses `Field` (not `ReturnTypeField`) because
|
|
11
|
-
* `ClassAccessorDecoratorContext` is tied to the original field type.
|
|
10
|
+
* Represents a class accessor decorator function. It may return a replacement getter, setter or initializer,
|
|
11
|
+
* or `void` to leave the accessor unchanged.
|
|
12
12
|
*
|
|
13
13
|
* @template Class - The class that owns the decorated accessor.
|
|
14
|
-
* @template Value - The
|
|
15
|
-
* @template
|
|
14
|
+
* @template Value - The type of the accessor's value, the same for the original accessor and its replacement.
|
|
15
|
+
* @template Metadata - The shape of the metadata of the class (see {@link DecoratorMetadataContext}).
|
|
16
16
|
*/
|
|
17
|
-
export declare type AccessorDecorator<Class extends object, Value = unknown> = (value: ClassAccessorDecoratorValue<Value>, context: ClassAccessorDecoratorContext<Class, Value>) => {
|
|
17
|
+
export declare type AccessorDecorator<Class extends object, Value = unknown, Metadata extends object = DecoratorMetadataObject> = (value: ClassAccessorDecoratorValue<Value>, context: DecoratorMetadataContext<ClassAccessorDecoratorContext<Class, Value>, Metadata>) => {
|
|
18
18
|
/**
|
|
19
19
|
* Replacement getter returning a value of `Value`.
|
|
20
20
|
*/
|
|
@@ -70,23 +70,26 @@ export declare type ClassAccessorDecoratorValue<Field = unknown> = {
|
|
|
70
70
|
/**
|
|
71
71
|
* Represents a TC39 stage-3 class decorator function.
|
|
72
72
|
*
|
|
73
|
-
* Receives the class constructor and its decorator context and
|
|
74
|
-
*
|
|
73
|
+
* Receives the class constructor and its decorator context, and returns `void`:
|
|
74
|
+
* the original class is left in place, it cannot be replaced.
|
|
75
75
|
*
|
|
76
76
|
* @template T - The instance type of the decorated class.
|
|
77
77
|
* @template Statics - Optional static members of the class.
|
|
78
|
+
* @template Metadata - The shape of the metadata of the class (see {@link DecoratorMetadataContext}).
|
|
78
79
|
*/
|
|
79
80
|
declare type ClassDecorator_2<T extends Object, Statics extends {
|
|
80
81
|
[key: string]: any;
|
|
81
82
|
} = {
|
|
82
83
|
[key: string]: any;
|
|
83
|
-
}> = (klass: Constructor<T, Statics>, context: ClassDecoratorContext) => void;
|
|
84
|
+
}, Metadata extends object = DecoratorMetadataObject> = (klass: Constructor<T, Statics>, context: DecoratorMetadataContext<ClassDecoratorContext<Constructor<T, Statics>>, Metadata>) => void;
|
|
84
85
|
export { ClassDecorator_2 as ClassDecorator }
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* A constructor function type that can accept any number of arguments and return an instance of any type.
|
|
88
89
|
*/
|
|
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)
|
|
90
|
+
export declare type Constructor<T extends object = object, Statics extends Record<string, unknown> | undefined = undefined> = (new (...args: any[]) => T) & (Statics extends undefined ? object : Statics) & {
|
|
91
|
+
prototype: T;
|
|
92
|
+
};
|
|
90
93
|
|
|
91
94
|
/**
|
|
92
95
|
* Recursively checks whether a string literal type contains a specific
|
|
@@ -104,13 +107,32 @@ export declare type Constructor<T extends object = object, Statics extends Recor
|
|
|
104
107
|
*/
|
|
105
108
|
export declare type ContainsChar<String extends string, Contains extends string> = String extends `${infer First}${infer Rest}` ? First extends Contains ? true : ContainsChar<Rest, Contains> : false;
|
|
106
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Represents the context of a TC39 stage-3 decorator whose `metadata` has the shape the decorators of the class store in
|
|
112
|
+
* it, instead of the untyped `DecoratorMetadataObject`.
|
|
113
|
+
*
|
|
114
|
+
* The metadata is `Partial`: while the class is being decorated it holds only what the decorators applied so far
|
|
115
|
+
* stored, and the metadata of a subclass starts from the one of its parent class.
|
|
116
|
+
*
|
|
117
|
+
* @template Context - The context of the decorator, such as `ClassFieldDecoratorContext<Class, Value>`.
|
|
118
|
+
* @template Metadata - The shape of the metadata. Defaults to `DecoratorMetadataObject`.
|
|
119
|
+
*/
|
|
120
|
+
export declare type DecoratorMetadataContext<Context extends {
|
|
121
|
+
metadata: DecoratorMetadataObject;
|
|
122
|
+
}, Metadata extends object = DecoratorMetadataObject> = Omit<Context, 'metadata'> & {
|
|
123
|
+
/**
|
|
124
|
+
* The metadata of the class being decorated.
|
|
125
|
+
*/
|
|
126
|
+
metadata: Partial<Metadata>;
|
|
127
|
+
};
|
|
128
|
+
|
|
107
129
|
/**
|
|
108
130
|
* A strongly-typed key/value map where every value is optional.
|
|
109
131
|
*
|
|
110
132
|
* Useful as a looser alternative to `Record<K, V>` when not all keys
|
|
111
133
|
* are guaranteed to be present.
|
|
112
134
|
*
|
|
113
|
-
* @template Key - The allowed key type. Must be a string or
|
|
135
|
+
* @template Key - The allowed key type. Must be a string, a number or a symbol.
|
|
114
136
|
* @template Value - The type of each value. Defaults to `string`.
|
|
115
137
|
*
|
|
116
138
|
* @example
|
|
@@ -124,21 +146,34 @@ export declare type Dictionary<Key extends string | number | symbol, Value = str
|
|
|
124
146
|
* Represents a TC39 stage-3 class field decorator function.
|
|
125
147
|
*
|
|
126
148
|
* Receives the initial `undefined` value and the field decorator context.
|
|
127
|
-
*
|
|
128
|
-
* (possibly transformed) representation.
|
|
149
|
+
* May return an initializer that maps the declared field value to its stored
|
|
150
|
+
* (possibly transformed) representation, or `void` to leave the field unchanged.
|
|
129
151
|
*
|
|
130
152
|
* @template Class - The class that owns the decorated field.
|
|
131
153
|
* @template Field - The declared type of the field.
|
|
132
154
|
* @template ReturnType - The type the initializer transforms the value into. Defaults to `Field`.
|
|
155
|
+
* @template Metadata - The shape of the metadata of the class (see {@link DecoratorMetadataContext}).
|
|
133
156
|
*/
|
|
134
|
-
export declare type FieldDecorator<Class extends Object, Field, ReturnType = Field> = (field: undefined, context: ClassFieldDecoratorContext<Class, Field>) => ((value: Field) => ReturnType);
|
|
157
|
+
export declare type FieldDecorator<Class extends Object, Field, ReturnType = Field, Metadata extends object = DecoratorMetadataObject> = (field: undefined, context: DecoratorMetadataContext<ClassFieldDecoratorContext<Class, Field>, Metadata>) => ((value: Field) => ReturnType) | void;
|
|
135
158
|
|
|
136
159
|
/**
|
|
137
160
|
* A function type that can accept any number of arguments and return any type.
|
|
138
161
|
*/
|
|
139
|
-
declare type Function_2<Arguments extends any[] = any[], ReturnType = void> =
|
|
162
|
+
declare type Function_2<Arguments extends any[] = any[], ReturnType = void> = (...args: Arguments) => ReturnType;
|
|
140
163
|
export { Function_2 as Function }
|
|
141
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Represents a TC39 stage-3 class getter decorator function.
|
|
167
|
+
*
|
|
168
|
+
* Receives the original getter and its decorator context, and may return a
|
|
169
|
+
* replacement getter or `void` to leave the original unchanged.
|
|
170
|
+
*
|
|
171
|
+
* @template Class - The class that owns the decorated getter.
|
|
172
|
+
* @template Value - The type the getter returns.
|
|
173
|
+
* @template Metadata - The shape of the metadata of the class (see {@link DecoratorMetadataContext}).
|
|
174
|
+
*/
|
|
175
|
+
export declare type GetterDecorator<Class extends Object, Value, Metadata extends object = DecoratorMetadataObject> = (value: (this: Class) => Value, context: DecoratorMetadataContext<ClassGetterDecoratorContext<Class, Value>, Metadata>) => ((this: Class) => Value) | void;
|
|
176
|
+
|
|
142
177
|
/**
|
|
143
178
|
* Represents a TC39 stage-3 class method decorator function.
|
|
144
179
|
*
|
|
@@ -147,8 +182,9 @@ export { Function_2 as Function }
|
|
|
147
182
|
*
|
|
148
183
|
* @template T - The class that owns the decorated method.
|
|
149
184
|
* @template Method - The type of the method being decorated.
|
|
185
|
+
* @template Metadata - The shape of the metadata of the class (see {@link DecoratorMetadataContext}).
|
|
150
186
|
*/
|
|
151
|
-
declare type MethodDecorator_2<T extends Object, Method extends Function_2> = (value: Method, context: ClassMethodDecoratorContext<T, Method>) => Method | void;
|
|
187
|
+
declare type MethodDecorator_2<T extends Object, Method extends Function_2, Metadata extends object = DecoratorMetadataObject> = (value: Method, context: DecoratorMetadataContext<ClassMethodDecoratorContext<T, Method>, Metadata>) => Method | void;
|
|
152
188
|
export { MethodDecorator_2 as MethodDecorator }
|
|
153
189
|
|
|
154
190
|
/**
|
|
@@ -177,7 +213,7 @@ export declare type Mutable<T extends Object> = {
|
|
|
177
213
|
export declare type NoArgsAsyncFunction<ReturnType = void> = () => Promise<ReturnType>;
|
|
178
214
|
|
|
179
215
|
/**
|
|
180
|
-
* An async function type that
|
|
216
|
+
* An async function type that takes no arguments and resolves to void.
|
|
181
217
|
*/
|
|
182
218
|
export declare type NoArgsAsyncVoidFunction = () => Promise<void>;
|
|
183
219
|
|
|
@@ -192,7 +228,7 @@ export declare type NoArgsAsyncVoidFunction = () => Promise<void>;
|
|
|
192
228
|
export declare type NoArgsFunction<ReturnType = void> = () => ReturnType;
|
|
193
229
|
|
|
194
230
|
/**
|
|
195
|
-
* A function type that
|
|
231
|
+
* A function type that takes no arguments and returns void.
|
|
196
232
|
*/
|
|
197
233
|
export declare type NoArgsVoidFunction = () => void;
|
|
198
234
|
|
|
@@ -209,7 +245,7 @@ export declare type NoArgsVoidFunction = () => void;
|
|
|
209
245
|
* type Invalid = PositiveInteger<-1>; // never
|
|
210
246
|
* type Float = PositiveInteger<1.5>; // never
|
|
211
247
|
*/
|
|
212
|
-
export declare type PositiveInteger<Value extends number> = ContainsChar<`${Value}`, '-'> extends true ? never : ContainsChar<`${Value}`, '.'> extends true ? never : Value;
|
|
248
|
+
export declare type PositiveInteger<Value extends number> = ContainsChar<`${Value}`, '-'> extends true ? never : ContainsChar<`${Value}`, '.'> extends true ? never : Value extends 0 ? never : Value;
|
|
213
249
|
|
|
214
250
|
/**
|
|
215
251
|
* Creates a type from `T` where at least one of the specified `Keys` must
|
|
@@ -235,15 +271,16 @@ export declare type RequireOne<T extends Object, Keys extends keyof T = keyof T>
|
|
|
235
271
|
* Constructs a fixed-length tuple of type `TupleType` with exactly `Length`
|
|
236
272
|
* elements.
|
|
237
273
|
*
|
|
238
|
-
* Resolves to `never` when `Length` is not a
|
|
274
|
+
* Resolves to `never` when `Length` is negative or not an integer, and to `[]` when it is `0` or not a literal
|
|
275
|
+
* (`number`). Lengths above 999 exceed the recursion limit of TypeScript.
|
|
239
276
|
*
|
|
240
|
-
* @template Length - The number of elements. Must be a
|
|
277
|
+
* @template Length - The number of elements. Must be a non-negative integer literal.
|
|
241
278
|
* @template TupleType - The element type. Defaults to `number`.
|
|
242
279
|
* @template Acc - Internal accumulator (do not provide manually).
|
|
243
280
|
*
|
|
244
281
|
* @example
|
|
245
282
|
* type Three = TupleOfLength<3, string>; // [string, string, string]
|
|
246
|
-
* type
|
|
283
|
+
* type Empty = TupleOfLength<0, string>; // []
|
|
247
284
|
*/
|
|
248
285
|
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]>;
|
|
249
286
|
|