@mohsen-azimi/tsz-dev 0.1.5 → 0.1.7

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.
Files changed (112) hide show
  1. package/bin/tsz.js +43 -0
  2. package/bundler/package.json +1 -1
  3. package/bundler/tsz_wasm_bg.js +28 -0
  4. package/bundler/tsz_wasm_bg.wasm +0 -0
  5. package/lib-assets/decorators.d.ts +382 -0
  6. package/lib-assets/decorators.legacy.d.ts +20 -0
  7. package/lib-assets/dom.asynciterable.d.ts +18 -0
  8. package/lib-assets/dom.d.ts +40771 -0
  9. package/lib-assets/dom.iterable.d.ts +18 -0
  10. package/lib-assets/es2015.collection.d.ts +145 -0
  11. package/lib-assets/es2015.core.d.ts +595 -0
  12. package/lib-assets/es2015.d.ts +26 -0
  13. package/lib-assets/es2015.generator.d.ts +75 -0
  14. package/lib-assets/es2015.iterable.d.ts +603 -0
  15. package/lib-assets/es2015.promise.d.ts +79 -0
  16. package/lib-assets/es2015.proxy.d.ts +126 -0
  17. package/lib-assets/es2015.reflect.d.ts +142 -0
  18. package/lib-assets/es2015.symbol.d.ts +44 -0
  19. package/lib-assets/es2015.symbol.wellknown.d.ts +324 -0
  20. package/lib-assets/es2016.array.include.d.ts +114 -0
  21. package/lib-assets/es2016.d.ts +19 -0
  22. package/lib-assets/es2016.full.d.ts +21 -0
  23. package/lib-assets/es2016.intl.d.ts +29 -0
  24. package/lib-assets/es2017.arraybuffer.d.ts +19 -0
  25. package/lib-assets/es2017.d.ts +24 -0
  26. package/lib-assets/es2017.date.d.ts +29 -0
  27. package/lib-assets/es2017.full.d.ts +21 -0
  28. package/lib-assets/es2017.intl.d.ts +42 -0
  29. package/lib-assets/es2017.object.d.ts +47 -0
  30. package/lib-assets/es2017.sharedmemory.d.ts +133 -0
  31. package/lib-assets/es2017.string.d.ts +43 -0
  32. package/lib-assets/es2017.typedarrays.d.ts +51 -0
  33. package/lib-assets/es2018.asyncgenerator.d.ts +75 -0
  34. package/lib-assets/es2018.asynciterable.d.ts +51 -0
  35. package/lib-assets/es2018.d.ts +22 -0
  36. package/lib-assets/es2018.full.d.ts +22 -0
  37. package/lib-assets/es2018.intl.d.ts +81 -0
  38. package/lib-assets/es2018.promise.d.ts +28 -0
  39. package/lib-assets/es2018.regexp.d.ts +35 -0
  40. package/lib-assets/es2019.array.d.ts +77 -0
  41. package/lib-assets/es2019.d.ts +22 -0
  42. package/lib-assets/es2019.full.d.ts +22 -0
  43. package/lib-assets/es2019.intl.d.ts +21 -0
  44. package/lib-assets/es2019.object.d.ts +31 -0
  45. package/lib-assets/es2019.string.d.ts +35 -0
  46. package/lib-assets/es2019.symbol.d.ts +22 -0
  47. package/lib-assets/es2020.bigint.d.ts +763 -0
  48. package/lib-assets/es2020.d.ts +25 -0
  49. package/lib-assets/es2020.date.d.ts +40 -0
  50. package/lib-assets/es2020.full.d.ts +22 -0
  51. package/lib-assets/es2020.intl.d.ts +472 -0
  52. package/lib-assets/es2020.number.d.ts +26 -0
  53. package/lib-assets/es2020.promise.d.ts +45 -0
  54. package/lib-assets/es2020.sharedmemory.d.ts +97 -0
  55. package/lib-assets/es2020.string.d.ts +42 -0
  56. package/lib-assets/es2020.symbol.wellknown.d.ts +39 -0
  57. package/lib-assets/es2021.d.ts +21 -0
  58. package/lib-assets/es2021.full.d.ts +22 -0
  59. package/lib-assets/es2021.intl.d.ts +164 -0
  60. package/lib-assets/es2021.promise.d.ts +46 -0
  61. package/lib-assets/es2021.string.d.ts +31 -0
  62. package/lib-assets/es2021.weakref.d.ts +76 -0
  63. package/lib-assets/es2022.array.d.ts +119 -0
  64. package/lib-assets/es2022.d.ts +23 -0
  65. package/lib-assets/es2022.error.d.ts +73 -0
  66. package/lib-assets/es2022.full.d.ts +22 -0
  67. package/lib-assets/es2022.intl.d.ts +143 -0
  68. package/lib-assets/es2022.object.d.ts +24 -0
  69. package/lib-assets/es2022.regexp.d.ts +37 -0
  70. package/lib-assets/es2022.string.d.ts +23 -0
  71. package/lib-assets/es2023.array.d.ts +922 -0
  72. package/lib-assets/es2023.collection.d.ts +19 -0
  73. package/lib-assets/es2023.d.ts +20 -0
  74. package/lib-assets/es2023.full.d.ts +22 -0
  75. package/lib-assets/es2023.intl.d.ts +54 -0
  76. package/lib-assets/es2024.arraybuffer.d.ts +63 -0
  77. package/lib-assets/es2024.collection.d.ts +29 -0
  78. package/lib-assets/es2024.d.ts +24 -0
  79. package/lib-assets/es2024.full.d.ts +22 -0
  80. package/lib-assets/es2024.object.d.ts +27 -0
  81. package/lib-assets/es2024.promise.d.ts +33 -0
  82. package/lib-assets/es2024.regexp.d.ts +23 -0
  83. package/lib-assets/es2024.sharedmemory.d.ts +66 -0
  84. package/lib-assets/es2024.string.d.ts +27 -0
  85. package/lib-assets/es5.d.ts +4599 -0
  86. package/lib-assets/es5.full.d.ts +20 -0
  87. package/lib-assets/es6.d.ts +21 -0
  88. package/lib-assets/esnext.array.d.ts +33 -0
  89. package/lib-assets/esnext.collection.d.ts +94 -0
  90. package/lib-assets/esnext.d.ts +28 -0
  91. package/lib-assets/esnext.decorators.d.ts +26 -0
  92. package/lib-assets/esnext.disposable.d.ts +191 -0
  93. package/lib-assets/esnext.error.d.ts +22 -0
  94. package/lib-assets/esnext.float16.d.ts +443 -0
  95. package/lib-assets/esnext.full.d.ts +22 -0
  96. package/lib-assets/esnext.intl.d.ts +19 -0
  97. package/lib-assets/esnext.iterator.d.ts +146 -0
  98. package/lib-assets/esnext.promise.d.ts +32 -0
  99. package/lib-assets/esnext.sharedmemory.d.ts +23 -0
  100. package/lib-assets/esnext.typedarrays.d.ts +90 -0
  101. package/lib-assets/lib_manifest.json +855 -0
  102. package/lib-assets/scripthost.d.ts +320 -0
  103. package/lib-assets/tsserverlibrary.d.ts +17 -0
  104. package/lib-assets/typescript.d.ts +11441 -0
  105. package/lib-assets/webworker.asynciterable.d.ts +18 -0
  106. package/lib-assets/webworker.d.ts +13768 -0
  107. package/lib-assets/webworker.importscripts.d.ts +21 -0
  108. package/lib-assets/webworker.iterable.d.ts +18 -0
  109. package/node/package.json +1 -1
  110. package/node/tsz_wasm.js +28 -0
  111. package/node/tsz_wasm_bg.wasm +0 -0
  112. package/package.json +2 -2
package/bin/tsz.js CHANGED
@@ -99,6 +99,49 @@ if (inputFiles.length === 0) {
99
99
  const program = new TsProgram();
100
100
  program.setCompilerOptions(JSON.stringify(options));
101
101
 
102
+ // ─── Load TypeScript lib files ────────────────────────────────────────────────
103
+ // Lib .d.ts files (lib.es5.d.ts, lib.dom.d.ts, etc.) provide global type
104
+ // definitions (Array, String, Promise, console, document, etc.).
105
+ // They are bundled in the package under lib-assets/ with a manifest.
106
+ const libDir = path.join(pkgDir, 'lib-assets');
107
+ const manifestPath = path.join(libDir, 'lib_manifest.json');
108
+
109
+ if (fs.existsSync(manifestPath)) {
110
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
111
+ const libs = manifest.libs || {};
112
+
113
+ // Resolve the default root lib based on target (matches tsc's getDefaultLibFileName).
114
+ // Default target is ES5 → root lib is "es5.full" (equivalent to tsc's "lib.d.ts").
115
+ const targetLibMap = {
116
+ es5: 'es5.full', es2015: 'es6', es2016: 'es2016.full',
117
+ es2017: 'es2017.full', es2018: 'es2018.full', es2019: 'es2019.full',
118
+ es2020: 'es2020.full', es2021: 'es2021.full', es2022: 'es2022.full',
119
+ es2023: 'esnext.full', es2024: 'esnext.full', esnext: 'esnext.full',
120
+ };
121
+ const rootLib = targetLibMap[(options.target || 'es5').toLowerCase()] || 'es5.full';
122
+
123
+ // BFS to resolve all transitive lib references
124
+ const visited = new Set();
125
+ const queue = [rootLib];
126
+ while (queue.length > 0) {
127
+ const name = queue.shift();
128
+ if (!name || visited.has(name)) continue;
129
+ visited.add(name);
130
+ const entry = libs[name];
131
+ if (!entry) continue;
132
+ const filePath = path.join(libDir, entry.fileName);
133
+ try {
134
+ const content = fs.readFileSync(filePath, 'utf8');
135
+ // Use canonical name (lib.es5.d.ts) so tsc-compatible lookups work
136
+ program.addLibFile(entry.canonicalFileName || entry.fileName, content);
137
+ } catch { /* skip missing files */ }
138
+ // Follow references
139
+ if (entry.references) {
140
+ for (const ref of entry.references) queue.push(ref);
141
+ }
142
+ }
143
+ }
144
+
102
145
  for (const file of inputFiles) {
103
146
  try {
104
147
  const text = fs.readFileSync(file, 'utf8');
@@ -5,7 +5,7 @@
5
5
  "Mohsen Azimi <mohsen@users.noreply.github.com>"
6
6
  ],
7
7
  "description": "WebAssembly bindings for the tsz TypeScript compiler",
8
- "version": "0.1.5",
8
+ "version": "0.1.7",
9
9
  "license": "Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",
@@ -4852,6 +4852,10 @@ export function __wbg_new_dd2b680c8bf6ae29(arg0) {
4852
4852
  const ret = new Uint8Array(arg0);
4853
4853
  return ret;
4854
4854
  }
4855
+ export function __wbg_new_no_args_1c7c842f08d00ebb(arg0, arg1) {
4856
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
4857
+ return ret;
4858
+ }
4855
4859
  export function __wbg_next_3482f54c49e8af19() { return handleError(function (arg0) {
4856
4860
  const ret = arg0.next();
4857
4861
  return ret;
@@ -4860,6 +4864,14 @@ export function __wbg_next_418f80d8f5303233(arg0) {
4860
4864
  const ret = arg0.next;
4861
4865
  return ret;
4862
4866
  }
4867
+ export function __wbg_now_2c95c9de01293173(arg0) {
4868
+ const ret = arg0.now();
4869
+ return ret;
4870
+ }
4871
+ export function __wbg_performance_7a3ffd0b17f663ad(arg0) {
4872
+ const ret = arg0.performance;
4873
+ return ret;
4874
+ }
4863
4875
  export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
4864
4876
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
4865
4877
  }
@@ -4880,6 +4892,22 @@ export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
4880
4892
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4881
4893
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4882
4894
  }
4895
+ export function __wbg_static_accessor_GLOBAL_12837167ad935116() {
4896
+ const ret = typeof global === 'undefined' ? null : global;
4897
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4898
+ }
4899
+ export function __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f() {
4900
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
4901
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4902
+ }
4903
+ export function __wbg_static_accessor_SELF_a621d3dfbb60d0ce() {
4904
+ const ret = typeof self === 'undefined' ? null : self;
4905
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4906
+ }
4907
+ export function __wbg_static_accessor_WINDOW_f8727f0cf888e0bd() {
4908
+ const ret = typeof window === 'undefined' ? null : window;
4909
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
4910
+ }
4883
4911
  export function __wbg_value_0546255b415e96c1(arg0) {
4884
4912
  const ret = arg0.value;
4885
4913
  return ret;
Binary file
@@ -0,0 +1,382 @@
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
+ MERCHANTABILITY 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
+ * The decorator context types provided to class element decorators.
19
+ */
20
+ type ClassMemberDecoratorContext =
21
+ | ClassMethodDecoratorContext
22
+ | ClassGetterDecoratorContext
23
+ | ClassSetterDecoratorContext
24
+ | ClassFieldDecoratorContext
25
+ | ClassAccessorDecoratorContext;
26
+
27
+ /**
28
+ * The decorator context types provided to any decorator.
29
+ */
30
+ type DecoratorContext =
31
+ | ClassDecoratorContext
32
+ | ClassMemberDecoratorContext;
33
+
34
+ type DecoratorMetadataObject = Record<PropertyKey, unknown> & object;
35
+
36
+ type DecoratorMetadata = typeof globalThis extends { Symbol: { readonly metadata: symbol; }; } ? DecoratorMetadataObject : DecoratorMetadataObject | undefined;
37
+
38
+ /**
39
+ * Context provided to a class decorator.
40
+ * @template Class The type of the decorated class associated with this context.
41
+ */
42
+ interface ClassDecoratorContext<
43
+ Class extends abstract new (...args: any) => any = abstract new (...args: any) => any,
44
+ > {
45
+ /** The kind of element that was decorated. */
46
+ readonly kind: "class";
47
+
48
+ /** The name of the decorated class. */
49
+ readonly name: string | undefined;
50
+
51
+ /**
52
+ * Adds a callback to be invoked after the class definition has been finalized.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * function customElement(name: string): ClassDecoratorFunction {
57
+ * return (target, context) => {
58
+ * context.addInitializer(function () {
59
+ * customElements.define(name, this);
60
+ * });
61
+ * }
62
+ * }
63
+ *
64
+ * @customElement("my-element")
65
+ * class MyElement {}
66
+ * ```
67
+ */
68
+ addInitializer(initializer: (this: Class) => void): void;
69
+
70
+ readonly metadata: DecoratorMetadata;
71
+ }
72
+
73
+ /**
74
+ * Context provided to a class method decorator.
75
+ * @template This The type on which the class element will be defined. For a static class element, this will be
76
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
77
+ * @template Value The type of the decorated class method.
78
+ */
79
+ interface ClassMethodDecoratorContext<
80
+ This = unknown,
81
+ Value extends (this: This, ...args: any) => any = (this: This, ...args: any) => any,
82
+ > {
83
+ /** The kind of class element that was decorated. */
84
+ readonly kind: "method";
85
+
86
+ /** The name of the decorated class element. */
87
+ readonly name: string | symbol;
88
+
89
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
90
+ readonly static: boolean;
91
+
92
+ /** A value indicating whether the class element has a private name. */
93
+ readonly private: boolean;
94
+
95
+ /** An object that can be used to access the current value of the class element at runtime. */
96
+ readonly access: {
97
+ /**
98
+ * Determines whether an object has a property with the same name as the decorated element.
99
+ */
100
+ has(object: This): boolean;
101
+ /**
102
+ * Gets the current value of the method from the provided object.
103
+ *
104
+ * @example
105
+ * let fn = context.access.get(instance);
106
+ */
107
+ get(object: This): Value;
108
+ };
109
+
110
+ /**
111
+ * Adds a callback to be invoked either after static methods are defined but before
112
+ * static initializers are run (when decorating a `static` element), or before instance
113
+ * initializers are run (when decorating a non-`static` element).
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const bound: ClassMethodDecoratorFunction = (value, context) {
118
+ * if (context.private) throw new TypeError("Not supported on private methods.");
119
+ * context.addInitializer(function () {
120
+ * this[context.name] = this[context.name].bind(this);
121
+ * });
122
+ * }
123
+ *
124
+ * class C {
125
+ * message = "Hello";
126
+ *
127
+ * @bound
128
+ * m() {
129
+ * console.log(this.message);
130
+ * }
131
+ * }
132
+ * ```
133
+ */
134
+ addInitializer(initializer: (this: This) => void): void;
135
+
136
+ readonly metadata: DecoratorMetadata;
137
+ }
138
+
139
+ /**
140
+ * Context provided to a class getter decorator.
141
+ * @template This The type on which the class element will be defined. For a static class element, this will be
142
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
143
+ * @template Value The property type of the decorated class getter.
144
+ */
145
+ interface ClassGetterDecoratorContext<
146
+ This = unknown,
147
+ Value = unknown,
148
+ > {
149
+ /** The kind of class element that was decorated. */
150
+ readonly kind: "getter";
151
+
152
+ /** The name of the decorated class element. */
153
+ readonly name: string | symbol;
154
+
155
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
156
+ readonly static: boolean;
157
+
158
+ /** A value indicating whether the class element has a private name. */
159
+ readonly private: boolean;
160
+
161
+ /** An object that can be used to access the current value of the class element at runtime. */
162
+ readonly access: {
163
+ /**
164
+ * Determines whether an object has a property with the same name as the decorated element.
165
+ */
166
+ has(object: This): boolean;
167
+ /**
168
+ * Invokes the getter on the provided object.
169
+ *
170
+ * @example
171
+ * let value = context.access.get(instance);
172
+ */
173
+ get(object: This): Value;
174
+ };
175
+
176
+ /**
177
+ * Adds a callback to be invoked either after static methods are defined but before
178
+ * static initializers are run (when decorating a `static` element), or before instance
179
+ * initializers are run (when decorating a non-`static` element).
180
+ */
181
+ addInitializer(initializer: (this: This) => void): void;
182
+
183
+ readonly metadata: DecoratorMetadata;
184
+ }
185
+
186
+ /**
187
+ * Context provided to a class setter decorator.
188
+ * @template This The type on which the class element will be defined. For a static class element, this will be
189
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
190
+ * @template Value The type of the decorated class setter.
191
+ */
192
+ interface ClassSetterDecoratorContext<
193
+ This = unknown,
194
+ Value = unknown,
195
+ > {
196
+ /** The kind of class element that was decorated. */
197
+ readonly kind: "setter";
198
+
199
+ /** The name of the decorated class element. */
200
+ readonly name: string | symbol;
201
+
202
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
203
+ readonly static: boolean;
204
+
205
+ /** A value indicating whether the class element has a private name. */
206
+ readonly private: boolean;
207
+
208
+ /** An object that can be used to access the current value of the class element at runtime. */
209
+ readonly access: {
210
+ /**
211
+ * Determines whether an object has a property with the same name as the decorated element.
212
+ */
213
+ has(object: This): boolean;
214
+ /**
215
+ * Invokes the setter on the provided object.
216
+ *
217
+ * @example
218
+ * context.access.set(instance, value);
219
+ */
220
+ set(object: This, value: Value): void;
221
+ };
222
+
223
+ /**
224
+ * Adds a callback to be invoked either after static methods are defined but before
225
+ * static initializers are run (when decorating a `static` element), or before instance
226
+ * initializers are run (when decorating a non-`static` element).
227
+ */
228
+ addInitializer(initializer: (this: This) => void): void;
229
+
230
+ readonly metadata: DecoratorMetadata;
231
+ }
232
+
233
+ /**
234
+ * Context provided to a class `accessor` field decorator.
235
+ * @template This The type on which the class element will be defined. For a static class element, this will be
236
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
237
+ * @template Value The type of decorated class field.
238
+ */
239
+ interface ClassAccessorDecoratorContext<
240
+ This = unknown,
241
+ Value = unknown,
242
+ > {
243
+ /** The kind of class element that was decorated. */
244
+ readonly kind: "accessor";
245
+
246
+ /** The name of the decorated class element. */
247
+ readonly name: string | symbol;
248
+
249
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
250
+ readonly static: boolean;
251
+
252
+ /** A value indicating whether the class element has a private name. */
253
+ readonly private: boolean;
254
+
255
+ /** An object that can be used to access the current value of the class element at runtime. */
256
+ readonly access: {
257
+ /**
258
+ * Determines whether an object has a property with the same name as the decorated element.
259
+ */
260
+ has(object: This): boolean;
261
+
262
+ /**
263
+ * Invokes the getter on the provided object.
264
+ *
265
+ * @example
266
+ * let value = context.access.get(instance);
267
+ */
268
+ get(object: This): Value;
269
+
270
+ /**
271
+ * Invokes the setter on the provided object.
272
+ *
273
+ * @example
274
+ * context.access.set(instance, value);
275
+ */
276
+ set(object: This, value: Value): void;
277
+ };
278
+
279
+ /**
280
+ * Adds a callback to be invoked immediately after the auto `accessor` being
281
+ * decorated is initialized (regardless if the `accessor` is `static` or not).
282
+ */
283
+ addInitializer(initializer: (this: This) => void): void;
284
+
285
+ readonly metadata: DecoratorMetadata;
286
+ }
287
+
288
+ /**
289
+ * Describes the target provided to class `accessor` field decorators.
290
+ * @template This The `this` type to which the target applies.
291
+ * @template Value The property type for the class `accessor` field.
292
+ */
293
+ interface ClassAccessorDecoratorTarget<This, Value> {
294
+ /**
295
+ * Invokes the getter that was defined prior to decorator application.
296
+ *
297
+ * @example
298
+ * let value = target.get.call(instance);
299
+ */
300
+ get(this: This): Value;
301
+
302
+ /**
303
+ * Invokes the setter that was defined prior to decorator application.
304
+ *
305
+ * @example
306
+ * target.set.call(instance, value);
307
+ */
308
+ set(this: This, value: Value): void;
309
+ }
310
+
311
+ /**
312
+ * Describes the allowed return value from a class `accessor` field decorator.
313
+ * @template This The `this` type to which the target applies.
314
+ * @template Value The property type for the class `accessor` field.
315
+ */
316
+ interface ClassAccessorDecoratorResult<This, Value> {
317
+ /**
318
+ * An optional replacement getter function. If not provided, the existing getter function is used instead.
319
+ */
320
+ get?(this: This): Value;
321
+
322
+ /**
323
+ * An optional replacement setter function. If not provided, the existing setter function is used instead.
324
+ */
325
+ set?(this: This, value: Value): void;
326
+
327
+ /**
328
+ * An optional initializer mutator that is invoked when the underlying field initializer is evaluated.
329
+ * @param value The incoming initializer value.
330
+ * @returns The replacement initializer value.
331
+ */
332
+ init?(this: This, value: Value): Value;
333
+ }
334
+
335
+ /**
336
+ * Context provided to a class field decorator.
337
+ * @template This The type on which the class element will be defined. For a static class element, this will be
338
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
339
+ * @template Value The type of the decorated class field.
340
+ */
341
+ interface ClassFieldDecoratorContext<
342
+ This = unknown,
343
+ Value = unknown,
344
+ > {
345
+ /** The kind of class element that was decorated. */
346
+ readonly kind: "field";
347
+
348
+ /** The name of the decorated class element. */
349
+ readonly name: string | symbol;
350
+
351
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
352
+ readonly static: boolean;
353
+
354
+ /** A value indicating whether the class element has a private name. */
355
+ readonly private: boolean;
356
+
357
+ /** An object that can be used to access the current value of the class element at runtime. */
358
+ readonly access: {
359
+ /**
360
+ * Determines whether an object has a property with the same name as the decorated element.
361
+ */
362
+ has(object: This): boolean;
363
+
364
+ /**
365
+ * Gets the value of the field on the provided object.
366
+ */
367
+ get(object: This): Value;
368
+
369
+ /**
370
+ * Sets the value of the field on the provided object.
371
+ */
372
+ set(object: This, value: Value): void;
373
+ };
374
+
375
+ /**
376
+ * Adds a callback to be invoked immediately after the field being decorated
377
+ * is initialized (regardless if the field is `static` or not).
378
+ */
379
+ addInitializer(initializer: (this: This) => void): void;
380
+
381
+ readonly metadata: DecoratorMetadata;
382
+ }
@@ -0,0 +1,20 @@
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
+ MERCHANTABILITY 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
+ declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
18
+ declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
19
+ declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
20
+ declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
@@ -0,0 +1,18 @@
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
+ MERCHANTABILITY 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
+ // This file's contents are now included in the main types file.
18
+ // The file has been left for backward compatibility.