@@ -14,12 +14,10 @@ and limitations under the License.
14
14
***************************************************************************** */
15
15
16
16
17
-
18
17
/// <reference no-default-lib="true"/>
19
18
20
-
21
19
/**
22
- * The decorator context types provided to class member decorators.
20
+ * The decorator context types provided to class element decorators.
23
21
*/
24
22
type ClassMemberDecoratorContext =
25
23
| ClassMethodDecoratorContext
@@ -80,34 +78,37 @@ interface ClassMethodDecoratorContext<
80
78
This = unknown ,
81
79
Value extends ( this : This , ...args : any ) => any = ( this : This , ...args : any ) => any ,
82
80
> {
83
- /** The kind of class member that was decorated. */
81
+ /** The kind of class element that was decorated. */
84
82
readonly kind : "method" ;
85
83
86
- /** The name of the decorated class member . */
84
+ /** The name of the decorated class element . */
87
85
readonly name : string | symbol ;
88
86
89
- /** A value indicating whether the class member is a static (`true`) or instance (`false`) member . */
87
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element . */
90
88
readonly static : boolean ;
91
89
92
- /** A value indicating whether the class member has a private name. */
90
+ /** A value indicating whether the class element has a private name. */
93
91
readonly private : boolean ;
94
92
95
- // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494
96
- // /** An object that can be used to access the current value of the class member at runtime. */
97
- // readonly access: {
98
- // /**
99
- // * Gets the current value of the method from the provided receiver.
100
- // *
101
- // * @example
102
- // * let fn = context.access.get.call(instance);
103
- // */
104
- // get(this: This): Value;
105
- // };
93
+ /** An object that can be used to access the current value of the class element at runtime. */
94
+ readonly access : {
95
+ /**
96
+ * Determines whether an object has a property with the same name as the decorated element.
97
+ */
98
+ has ( object : This ) : boolean ;
99
+ /**
100
+ * Gets the current value of the method from the provided object.
101
+ *
102
+ * @example
103
+ * let fn = context.access.get(instance);
104
+ */
105
+ get ( object : This ) : Value ;
106
+ } ;
106
107
107
108
/**
108
109
* Adds a callback to be invoked either before static initializers are run (when
109
- * decorating a `static` member ), or before instance initializers are run (when
110
- * decorating a non-`static` member ).
110
+ * decorating a `static` element ), or before instance initializers are run (when
111
+ * decorating a non-`static` element ).
111
112
*
112
113
* @example
113
114
* ```ts
@@ -141,34 +142,37 @@ interface ClassGetterDecoratorContext<
141
142
This = unknown ,
142
143
Value = unknown ,
143
144
> {
144
- /** The kind of class member that was decorated. */
145
+ /** The kind of class element that was decorated. */
145
146
readonly kind : "getter" ;
146
147
147
- /** The name of the decorated class member . */
148
+ /** The name of the decorated class element . */
148
149
readonly name : string | symbol ;
149
150
150
- /** A value indicating whether the class member is a static (`true`) or instance (`false`) member . */
151
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element . */
151
152
readonly static : boolean ;
152
153
153
- /** A value indicating whether the class member has a private name. */
154
+ /** A value indicating whether the class element has a private name. */
154
155
readonly private : boolean ;
155
156
156
- // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494
157
- // /** An object that can be used to access the current value of the class member at runtime. */
158
- // readonly access: {
159
- // /**
160
- // * Invokes the getter on the provided receiver.
161
- // *
162
- // * @example
163
- // * let value = context.access.get.call(instance);
164
- // */
165
- // get(this: This): Value;
166
- // };
157
+ /** An object that can be used to access the current value of the class element at runtime. */
158
+ readonly access : {
159
+ /**
160
+ * Determines whether an object has a property with the same name as the decorated element.
161
+ */
162
+ has ( object : This ) : boolean ;
163
+ /**
164
+ * Invokes the getter on the provided object.
165
+ *
166
+ * @example
167
+ * let value = context.access.get(instance);
168
+ */
169
+ get ( object : This ) : Value ;
170
+ } ;
167
171
168
172
/**
169
173
* Adds a callback to be invoked either before static initializers are run (when
170
- * decorating a `static` member ), or before instance initializers are run (when
171
- * decorating a non-`static` member ).
174
+ * decorating a `static` element ), or before instance initializers are run (when
175
+ * decorating a non-`static` element ).
172
176
*/
173
177
addInitializer ( initializer : ( this : This ) => void ) : void ;
174
178
}
@@ -183,34 +187,37 @@ interface ClassSetterDecoratorContext<
183
187
This = unknown ,
184
188
Value = unknown ,
185
189
> {
186
- /** The kind of class member that was decorated. */
190
+ /** The kind of class element that was decorated. */
187
191
readonly kind : "setter" ;
188
192
189
- /** The name of the decorated class member . */
193
+ /** The name of the decorated class element . */
190
194
readonly name : string | symbol ;
191
195
192
- /** A value indicating whether the class member is a static (`true`) or instance (`false`) member . */
196
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element . */
193
197
readonly static : boolean ;
194
198
195
- /** A value indicating whether the class member has a private name. */
199
+ /** A value indicating whether the class element has a private name. */
196
200
readonly private : boolean ;
197
201
198
- // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494
199
- /** An object that can be used to access the current value of the class member at runtime. */
200
- // readonly access: {
201
- // /**
202
- // * Invokes the setter on the provided receiver.
203
- // *
204
- // * @example
205
- // * context.access.set.call(instance, value);
206
- // */
207
- // set(this: This, value: Value): void;
208
- // };
202
+ /** An object that can be used to access the current value of the class element at runtime. */
203
+ readonly access : {
204
+ /**
205
+ * Determines whether an object has a property with the same name as the decorated element.
206
+ */
207
+ has ( object : This ) : boolean ;
208
+ /**
209
+ * Invokes the setter on the provided object.
210
+ *
211
+ * @example
212
+ * context.access.set(instance, value);
213
+ */
214
+ set ( object : This , value : Value ) : void ;
215
+ } ;
209
216
210
217
/**
211
218
* Adds a callback to be invoked either before static initializers are run (when
212
- * decorating a `static` member ), or before instance initializers are run (when
213
- * decorating a non-`static` member ).
219
+ * decorating a `static` element ), or before instance initializers are run (when
220
+ * decorating a non-`static` element ).
214
221
*/
215
222
addInitializer ( initializer : ( this : This ) => void ) : void ;
216
223
}
@@ -225,42 +232,46 @@ interface ClassAccessorDecoratorContext<
225
232
This = unknown ,
226
233
Value = unknown ,
227
234
> {
228
- /** The kind of class member that was decorated. */
235
+ /** The kind of class element that was decorated. */
229
236
readonly kind : "accessor" ;
230
237
231
- /** The name of the decorated class member . */
238
+ /** The name of the decorated class element . */
232
239
readonly name : string | symbol ;
233
240
234
- /** A value indicating whether the class member is a static (`true`) or instance (`false`) member . */
241
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element . */
235
242
readonly static : boolean ;
236
243
237
- /** A value indicating whether the class member has a private name. */
244
+ /** A value indicating whether the class element has a private name. */
238
245
readonly private : boolean ;
239
246
240
- // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494
241
- // /** An object that can be used to access the current value of the class member at runtime. */
242
- // readonly access: {
243
- // /**
244
- // * Invokes the getter on the provided receiver.
245
- // *
246
- // * @example
247
- // * let value = context.access.get.call(instance);
248
- // */
249
- // get(this: This): Value;
250
-
251
- // /**
252
- // * Invokes the setter on the provided receiver.
253
- // *
254
- // * @example
255
- // * context.access.set.call(instance, value);
256
- // */
257
- // set(this: This, value: Value): void;
258
- // };
247
+ /** An object that can be used to access the current value of the class element at runtime. */
248
+ readonly access : {
249
+ /**
250
+ * Determines whether an object has a property with the same name as the decorated element.
251
+ */
252
+ has ( object : This ) : boolean ;
253
+
254
+ /**
255
+ * Invokes the getter on the provided object.
256
+ *
257
+ * @example
258
+ * let value = context.access.get(instance);
259
+ */
260
+ get ( object : This ) : Value ;
261
+
262
+ /**
263
+ * Invokes the setter on the provided object.
264
+ *
265
+ * @example
266
+ * context.access.set(instance, value);
267
+ */
268
+ set ( object : This , value : Value ) : void ;
269
+ } ;
259
270
260
271
/**
261
272
* Adds a callback to be invoked either before static initializers are run (when
262
- * decorating a `static` member ), or before instance initializers are run (when
263
- * decorating a non-`static` member ).
273
+ * decorating a `static` element ), or before instance initializers are run (when
274
+ * decorating a non-`static` element ).
264
275
*/
265
276
addInitializer ( initializer : ( this : This ) => void ) : void ;
266
277
}
@@ -322,36 +333,40 @@ interface ClassFieldDecoratorContext<
322
333
This = unknown ,
323
334
Value = unknown ,
324
335
> {
325
- /** The kind of class member that was decorated. */
336
+ /** The kind of class element that was decorated. */
326
337
readonly kind : "field" ;
327
338
328
- /** The name of the decorated class member . */
339
+ /** The name of the decorated class element . */
329
340
readonly name : string | symbol ;
330
341
331
- /** A value indicating whether the class member is a static (`true`) or instance (`false`) member . */
342
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element . */
332
343
readonly static : boolean ;
333
344
334
- /** A value indicating whether the class member has a private name. */
345
+ /** A value indicating whether the class element has a private name. */
335
346
readonly private : boolean ;
336
347
337
- // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494
338
- // /** An object that can be used to access the current value of the class member at runtime. */
339
- // readonly access: {
340
- // /**
341
- // * Gets the value of the field on the provided receiver.
342
- // */
343
- // get(this: This): Value;
348
+ /** An object that can be used to access the current value of the class element at runtime. */
349
+ readonly access : {
350
+ /**
351
+ * Determines whether an object has a property with the same name as the decorated element.
352
+ */
353
+ has ( object : This ) : boolean ;
354
+
355
+ /**
356
+ * Gets the value of the field on the provided object.
357
+ */
358
+ get ( object : This ) : Value ;
344
359
345
- // /**
346
- // * Sets the value of the field on the provided receiver .
347
- // */
348
- // set(this : This, value: Value): void;
349
- // };
360
+ /**
361
+ * Sets the value of the field on the provided object .
362
+ */
363
+ set ( object : This , value : Value ) : void ;
364
+ } ;
350
365
351
366
/**
352
367
* Adds a callback to be invoked either before static initializers are run (when
353
- * decorating a `static` member ), or before instance initializers are run (when
354
- * decorating a non-`static` member ).
368
+ * decorating a `static` element ), or before instance initializers are run (when
369
+ * decorating a non-`static` element ).
355
370
*/
356
371
addInitializer ( initializer : ( this : This ) => void ) : void ;
357
372
}
0 commit comments