@typescript-deploys/pr-build 5.0.0-pr-51241-2 → 5.0.0-pr-50820-27

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.
@@ -0,0 +1,412 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ this file except in compliance with the License. You may obtain a copy of the
5
+ License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+
16
+
17
+
18
+ /// <reference no-default-lib="true"/>
19
+
20
+
21
+ /**
22
+ * The decorator context types provided to class member decorators.
23
+ */
24
+ type ClassMemberDecoratorContext =
25
+ | ClassMethodDecoratorContext
26
+ | ClassGetterDecoratorContext
27
+ | ClassSetterDecoratorContext
28
+ | ClassFieldDecoratorContext
29
+ | ClassAccessorDecoratorContext
30
+ ;
31
+
32
+ /**
33
+ * The decorator context types provided to any decorator.
34
+ */
35
+ type DecoratorContext =
36
+ | ClassDecoratorContext
37
+ | ClassMemberDecoratorContext
38
+ ;
39
+
40
+ /**
41
+ * Context provided to a class decorator.
42
+ */
43
+ interface ClassDecoratorContext<
44
+ Class extends abstract new (...args: any) => any = abstract new (...args: any) => any
45
+ > {
46
+ /** The kind of element that was decorated. */
47
+ readonly kind: "class";
48
+
49
+ /** The name of the decorated class. */
50
+ readonly name: string | undefined;
51
+
52
+ /**
53
+ * Adds a callback to be invoked after the class definition has been finalized.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * function customElement(name: string): ClassDecoratorFunction {
58
+ * return (target, { addInitializer }) => {
59
+ * addInitializer(function () {
60
+ * customElements.define(name, this);
61
+ * });
62
+ * }
63
+ * }
64
+ *
65
+ * @customElement("my-element")
66
+ * class MyElement {}
67
+ * ```
68
+ */
69
+ addInitializer(initializer: (this: Class) => void): void;
70
+ }
71
+
72
+ /**
73
+ * Describes the call signature of a generic function that can be used to decorate a class.
74
+ * @param target The decorated class constructor.
75
+ * @param context Additional context about the decorated class.
76
+ * @returns A replacement class constructor, or `undefined`.
77
+ */
78
+ type ClassDecoratorFunction<Overrides extends { name?: string | undefined } = {}> = <
79
+ Class extends abstract new (...args: any) => any,
80
+ >(
81
+ target: Class,
82
+ context: ClassDecoratorContext<Class> & Overrides
83
+ ) => Class | void;
84
+
85
+ /**
86
+ * Context provided to a class method decorator.
87
+ */
88
+ interface ClassMethodDecoratorContext<
89
+ This = unknown,
90
+ Value extends (this: This, ...args: any) => any = (this: This, ...args: any) => any,
91
+ > {
92
+ /** The kind of class member that was decorated. */
93
+ readonly kind: "method";
94
+
95
+ /** The name of the decorated class member. */
96
+ readonly name: string | symbol;
97
+
98
+ /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */
99
+ readonly static: boolean;
100
+
101
+ /** A value indicating whether the class member has a private name. */
102
+ readonly private: boolean;
103
+
104
+ /** An object that can be used to access the current value of the class member at runtime. */
105
+ readonly access: {
106
+ /**
107
+ * Gets the current value of the method from the provided receiver.
108
+ *
109
+ * @example
110
+ * let fn = context.access.get.call(instance);
111
+ */
112
+ get(this: This): Value;
113
+ };
114
+
115
+ /**
116
+ * Adds a callback to be invoked either before static initializers are run (when
117
+ * decorating a `static` member), or before instance initializers are run (when
118
+ * decorating a non-`static` member).
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const bound: ClassMethodDecoratorFunction = (value, { name, private: isPrivate, addInitializer }) {
123
+ * if (isPrivate) throw new TypeError("Not supported on private methods.");
124
+ * addInitializer(function () {
125
+ * this[name] = this[name].bind(this);
126
+ * });
127
+ * }
128
+ *
129
+ * class C {
130
+ * message = "Hello";
131
+ *
132
+ * @bound
133
+ * m() {
134
+ * console.log(this.message);
135
+ * }
136
+ * }
137
+ * ```
138
+ */
139
+ addInitializer(initializer: (this: This) => void): void;
140
+ }
141
+
142
+ /**
143
+ * Describes a generic function that can be used to decorate a class method.
144
+ * @param target The function for the decorated class method.
145
+ * @param context Additional context about the decorated class method.
146
+ * @returns A replacement function, or `undefined`.
147
+ */
148
+ type ClassMethodDecoratorFunction<Overrides extends { name?: string | symbol, private?: boolean, static?: boolean } = {}> = <
149
+ This,
150
+ Value extends (this: This, ...args: any) => any
151
+ >(target: Value, context: ClassMethodDecoratorContext<This, Value> & Overrides) => Value | void;
152
+
153
+ /**
154
+ * Context provided to a class `get` method decorator.
155
+ */
156
+ interface ClassGetterDecoratorContext<
157
+ This = unknown,
158
+ Value = unknown,
159
+ > {
160
+ /** The kind of class member that was decorated. */
161
+ readonly kind: "getter";
162
+
163
+ /** The name of the decorated class member. */
164
+ readonly name: string | symbol;
165
+
166
+ /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */
167
+ readonly static: boolean;
168
+
169
+ /** A value indicating whether the class member has a private name. */
170
+ readonly private: boolean;
171
+
172
+ /** An object that can be used to access the current value of the class member at runtime. */
173
+ readonly access: {
174
+ /**
175
+ * Invokes the getter on the provided receiver.
176
+ *
177
+ * @example
178
+ * let value = context.access.get.call(instance);
179
+ */
180
+ get(this: This): Value;
181
+ };
182
+
183
+ /**
184
+ * Adds a callback to be invoked either before static initializers are run (when
185
+ * decorating a `static` member), or before instance initializers are run (when
186
+ * decorating a non-`static` member).
187
+ */
188
+ addInitializer(initializer: (this: This) => void): void;
189
+ }
190
+
191
+ /**
192
+ * Describes a generic function that can be used to decorate a class `get` method.
193
+ * @param target The getter function for the decorated class `get` method.
194
+ * @param context Additional context about the decorated class `get` method.
195
+ * @returns A replacement getter function, or `undefined`.
196
+ */
197
+ type ClassGetterDecoratorFunction<Overrides extends { name?: string | symbol, private?: boolean, static?: boolean } = {}> = <
198
+ This,
199
+ Value,
200
+ >(
201
+ target: (this: This) => Value,
202
+ context: ClassGetterDecoratorContext<This, Value> & Overrides
203
+ ) => ((this: This) => Value) | void;
204
+
205
+ /**
206
+ * Context provided to a class `set` method decorator.
207
+ */
208
+ interface ClassSetterDecoratorContext<
209
+ This = unknown,
210
+ Value = unknown,
211
+ > {
212
+ /** The kind of class member that was decorated. */
213
+ readonly kind: "setter";
214
+
215
+ /** The name of the decorated class member. */
216
+ readonly name: string | symbol;
217
+
218
+ /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */
219
+ readonly static: boolean;
220
+
221
+ /** A value indicating whether the class member has a private name. */
222
+ readonly private: boolean;
223
+
224
+ /** An object that can be used to access the current value of the class member at runtime. */
225
+ readonly access: {
226
+ /**
227
+ * Invokes the setter on the provided receiver.
228
+ *
229
+ * @example
230
+ * context.access.set.call(instance, value);
231
+ */
232
+ set(this: This, value: Value): void;
233
+ };
234
+
235
+ /**
236
+ * Adds a callback to be invoked either before static initializers are run (when
237
+ * decorating a `static` member), or before instance initializers are run (when
238
+ * decorating a non-`static` member).
239
+ */
240
+ addInitializer(initializer: (this: This) => void): void;
241
+ }
242
+
243
+ /**
244
+ * Describes a generic function that can be used to decorate a class `set` method.
245
+ * @param target The setter function for the decorated class `set` method.
246
+ * @param context Additional context about the decorated class `set` method.
247
+ * @returns A replacement setter function, or `undefined`.
248
+ */
249
+ type ClassSetterDecoratorFunction<Overrides extends { name?: string | symbol, private?: boolean, static?: boolean } = {}> = <
250
+ This,
251
+ Value,
252
+ >(
253
+ target: (this: This, value: Value) => void,
254
+ context: ClassSetterDecoratorContext<This, Value> & Overrides
255
+ ) => ((this: This, value: Value) => void) | void;
256
+
257
+ /**
258
+ * Context provided to a class `accessor` field decorator.
259
+ */
260
+ interface ClassAccessorDecoratorContext<
261
+ This = unknown,
262
+ Value = unknown,
263
+ > {
264
+ /** The kind of class member that was decorated. */
265
+ readonly kind: "accessor";
266
+
267
+ /** The name of the decorated class member. */
268
+ readonly name: string | symbol;
269
+
270
+ /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */
271
+ readonly static: boolean;
272
+
273
+ /** A value indicating whether the class member has a private name. */
274
+ readonly private: boolean;
275
+
276
+ /** An object that can be used to access the current value of the class member at runtime. */
277
+ readonly access: {
278
+ /**
279
+ * Invokes the getter on the provided receiver.
280
+ *
281
+ * @example
282
+ * let value = context.access.get.call(instance);
283
+ */
284
+ get(this: This): Value;
285
+
286
+ /**
287
+ * Invokes the setter on the provided receiver.
288
+ *
289
+ * @example
290
+ * context.access.set.call(instance, value);
291
+ */
292
+ set(this: This, value: Value): void;
293
+ };
294
+
295
+ /**
296
+ * Adds a callback to be invoked either before static initializers are run (when
297
+ * decorating a `static` member), or before instance initializers are run (when
298
+ * decorating a non-`static` member).
299
+ */
300
+ addInitializer(initializer: (this: This) => void): void;
301
+ }
302
+
303
+ /**
304
+ * Describes the target provided to class `accessor` field decorators.
305
+ */
306
+ interface ClassAccessorDecoratorTarget<This, Value> {
307
+ /**
308
+ * Invokes the getter that was defined prior to decorator application.
309
+ *
310
+ * @example
311
+ * let value = target.get.call(instance);
312
+ */
313
+ get(this: This): Value;
314
+
315
+ /**
316
+ * Invokes the setter that was defined prior to decorator application.
317
+ *
318
+ * @example
319
+ * target.set.call(instance, value);
320
+ */
321
+ set(this: This, value: Value): void;
322
+ }
323
+
324
+ /**
325
+ * Describes the allowed return value from a class `accessor` field decorator.
326
+ */
327
+ interface ClassAccessorDecoratorResult<This, Value> {
328
+ /**
329
+ * An optional replacement getter function. If not provided, the existing getter function is used instead.
330
+ */
331
+ get?(this: This): Value;
332
+
333
+ /**
334
+ * An optional replacement setter function. If not provided, the existing setter function is used instead.
335
+ */
336
+ set?(this: This, value: Value): void;
337
+
338
+ /**
339
+ * An optional initializer mutator that is invoked when the underlying field initializer is evaluated.
340
+ * @param value The incoming initializer value.
341
+ * @returns The replacement initializer value.
342
+ */
343
+ init?(this: This, value: Value): Value;
344
+ }
345
+
346
+ /**
347
+ * Describes a generic function that can be used to decorate a class `accessor` field.
348
+ * @param target The {@link ClassAccessorDecoratorTarget} the decorated class `accessor` field.
349
+ * @param context Additional context about the decorated class `accessor` field.
350
+ * @returns A {@link ClassAccessorDecoratorResult} that is used to replace the getter or setter or to inject an initializer mutator, or `undefined` to use the existing getter and setter.
351
+ */
352
+ type ClassAccessorDecoratorFunction<Overrides extends { name?: string | symbol, private?: boolean, static?: boolean } = {}> = <
353
+ This,
354
+ Value,
355
+ >(
356
+ target: ClassAccessorDecoratorTarget<This, Value>,
357
+ context: ClassAccessorDecoratorContext<This, Value> & Overrides
358
+ ) => ClassAccessorDecoratorResult<This, Value> | void;
359
+
360
+ /**
361
+ * Context provided to a class field decorator.
362
+ */
363
+ interface ClassFieldDecoratorContext<
364
+ This = unknown,
365
+ Value = unknown,
366
+ > {
367
+ /** The kind of class member that was decorated. */
368
+ readonly kind: "field";
369
+
370
+ /** The name of the decorated class member. */
371
+ readonly name: string | symbol;
372
+
373
+ /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */
374
+ readonly static: boolean;
375
+
376
+ /** A value indicating whether the class member has a private name. */
377
+ readonly private: boolean;
378
+
379
+ /** An object that can be used to access the current value of the class member at runtime. */
380
+ readonly access: {
381
+ /**
382
+ * Gets the value of the field on the provided receiver.
383
+ */
384
+ get(this: This): Value;
385
+
386
+ /**
387
+ * Sets the value of the field on the provided receiver.
388
+ */
389
+ set(this: This, value: Value): void;
390
+ };
391
+
392
+ /**
393
+ * Adds a callback to be invoked either before static initializers are run (when
394
+ * decorating a `static` member), or before instance initializers are run (when
395
+ * decorating a non-`static` member).
396
+ */
397
+ addInitializer(initializer: (this: This) => void): void;
398
+ }
399
+
400
+ /**
401
+ * Describes a generic function that can be used to decorate a class field.
402
+ * @param target Class field decorators always receive `undefined`.
403
+ * @param context Additional context about the decorated class field.
404
+ * @returns An initializer mutator function, or `undefined`.
405
+ */
406
+ type ClassFieldDecoratorFunction<Overrides extends { name?: string | symbol, private?: boolean, static?: boolean } = {}> = <
407
+ This,
408
+ Value,
409
+ >(
410
+ target: undefined,
411
+ context: ClassFieldDecoratorContext<This, Value> & Overrides
412
+ ) => ((this: This, initialValue: Value) => Value) | void;
@@ -0,0 +1,24 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ this file except in compliance with the License. You may obtain a copy of the
5
+ License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+
16
+
17
+
18
+ /// <reference no-default-lib="true"/>
19
+
20
+
21
+ declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
22
+ declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
23
+ declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
24
+ declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
@@ -0,0 +1,34 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ this file except in compliance with the License. You may obtain a copy of the
5
+ License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+
16
+
17
+
18
+ /// <reference no-default-lib="true"/>
19
+
20
+
21
+ interface ParameterDecoratorContext<Func extends Function> {
22
+ readonly kind: "parameter";
23
+ readonly index: number;
24
+ readonly name: string | undefined;
25
+ readonly rest: boolean;
26
+ addInitializer(initializer: (this: Func) => void): void;
27
+ }
28
+
29
+ type ParameterDecoratorFunction = <
30
+ Func extends Function,
31
+ This,
32
+ In,
33
+ Out = In
34
+ >(target: undefined, context: ParameterDecoratorContext<Func>) => ((this: This, initialValue: In) => Out) | void;
package/lib/lib.es5.d.ts CHANGED
@@ -18,6 +18,9 @@ and limitations under the License.
18
18
  /// <reference no-default-lib="true"/>
19
19
 
20
20
 
21
+ /// <reference lib="decorators" />
22
+ /// <reference lib="decorators.legacy" />
23
+
21
24
  /////////////////////////////
22
25
  /// ECMAScript APIs
23
26
  /////////////////////////////
@@ -1503,11 +1506,6 @@ interface TypedPropertyDescriptor<T> {
1503
1506
  set?: (value: T) => void;
1504
1507
  }
1505
1508
 
1506
- declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
1507
- declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
1508
- declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
1509
- declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
1510
-
1511
1509
  declare type PromiseConstructorLike = new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => PromiseLike<T>;
1512
1510
 
1513
1511
  interface PromiseLike<T> {