strict-ts-lib-v5.0 0.4.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.
Files changed (77) hide show
  1. package/README.md +28 -0
  2. package/libs/decorators/index.d.ts +344 -0
  3. package/libs/decorators/legacy/index.d.ts +19 -0
  4. package/libs/dom/index.d.ts +25408 -0
  5. package/libs/dom/iterable/index.d.ts +630 -0
  6. package/libs/es2015/collection/index.d.ts +148 -0
  7. package/libs/es2015/core/index.d.ts +574 -0
  8. package/libs/es2015/generator/index.d.ts +65 -0
  9. package/libs/es2015/index.d.ts +12 -0
  10. package/libs/es2015/iterable/index.d.ts +522 -0
  11. package/libs/es2015/promise/index.d.ts +74 -0
  12. package/libs/es2015/proxy/index.d.ts +131 -0
  13. package/libs/es2015/reflect/index.d.ts +145 -0
  14. package/libs/es2015/symbol/index.d.ts +30 -0
  15. package/libs/es2015/symbol-wellknown/index.d.ts +331 -0
  16. package/libs/es2016/array-include/index.d.ts +115 -0
  17. package/libs/es2016/full/index.d.ts +7 -0
  18. package/libs/es2016/index.d.ts +4 -0
  19. package/libs/es2017/full/index.d.ts +7 -0
  20. package/libs/es2017/index.d.ts +8 -0
  21. package/libs/es2017/intl/index.d.ts +28 -0
  22. package/libs/es2017/object/index.d.ts +115 -0
  23. package/libs/es2017/sharedmemory/index.d.ts +244 -0
  24. package/libs/es2017/string/index.d.ts +29 -0
  25. package/libs/es2017/typedarrays/index.d.ts +37 -0
  26. package/libs/es2018/asyncgenerator/index.d.ts +69 -0
  27. package/libs/es2018/asynciterable/index.d.ts +31 -0
  28. package/libs/es2018/full/index.d.ts +7 -0
  29. package/libs/es2018/index.d.ts +8 -0
  30. package/libs/es2018/intl/index.d.ts +102 -0
  31. package/libs/es2018/promise/index.d.ts +14 -0
  32. package/libs/es2018/regexp/index.d.ts +21 -0
  33. package/libs/es2019/array/index.d.ts +94 -0
  34. package/libs/es2019/full/index.d.ts +7 -0
  35. package/libs/es2019/index.d.ts +8 -0
  36. package/libs/es2019/intl/index.d.ts +7 -0
  37. package/libs/es2019/object/index.d.ts +143 -0
  38. package/libs/es2019/string/index.d.ts +21 -0
  39. package/libs/es2019/symbol/index.d.ts +8 -0
  40. package/libs/es2020/bigint/index.d.ts +833 -0
  41. package/libs/es2020/date/index.d.ts +35 -0
  42. package/libs/es2020/full/index.d.ts +7 -0
  43. package/libs/es2020/index.d.ts +11 -0
  44. package/libs/es2020/intl/index.d.ts +433 -0
  45. package/libs/es2020/number/index.d.ts +15 -0
  46. package/libs/es2020/promise/index.d.ts +37 -0
  47. package/libs/es2020/sharedmemory/index.d.ts +119 -0
  48. package/libs/es2020/string/index.d.ts +12 -0
  49. package/libs/es2020/symbol-wellknown/index.d.ts +21 -0
  50. package/libs/es2021/full/index.d.ts +7 -0
  51. package/libs/es2021/index.d.ts +7 -0
  52. package/libs/es2021/intl/index.d.ts +164 -0
  53. package/libs/es2021/promise/index.d.ts +34 -0
  54. package/libs/es2021/string/index.d.ts +20 -0
  55. package/libs/es2021/weakref/index.d.ts +57 -0
  56. package/libs/es2022/array/index.d.ts +105 -0
  57. package/libs/es2022/error/index.d.ts +57 -0
  58. package/libs/es2022/full/index.d.ts +7 -0
  59. package/libs/es2022/index.d.ts +10 -0
  60. package/libs/es2022/intl/index.d.ts +98 -0
  61. package/libs/es2022/object/index.d.ts +41 -0
  62. package/libs/es2022/regexp/index.d.ts +23 -0
  63. package/libs/es2022/sharedmemory/index.d.ts +37 -0
  64. package/libs/es2022/string/index.d.ts +9 -0
  65. package/libs/es2023/array/index.d.ts +495 -0
  66. package/libs/es2023/full/index.d.ts +7 -0
  67. package/libs/es2023/index.d.ts +4 -0
  68. package/libs/es5/index.d.ts +5709 -0
  69. package/libs/es6/index.d.ts +7 -0
  70. package/libs/esnext/full/index.d.ts +7 -0
  71. package/libs/esnext/index.d.ts +4 -0
  72. package/libs/esnext/intl/index.d.ts +15 -0
  73. package/libs/scripthost/index.d.ts +310 -0
  74. package/libs/webworker/importscripts/index.d.ts +7 -0
  75. package/libs/webworker/index.d.ts +8426 -0
  76. package/libs/webworker/iterable/index.d.ts +439 -0
  77. package/package.json +23 -0
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # strict-ts-lib-v5.0
2
+
3
+ Strict rewrite of TypeScript 5.0.4's built-in
4
+ standard library declarations, distributed as a GitHub Release tarball
5
+ (no npm registry, no auth).
6
+
7
+ ```sh
8
+ npm install -D https://github.com/noshiro-pf/strict-typescript-lib/releases/download/dist-v5.0-0.4.0/strict-ts-lib-v5.0-0.4.0.tgz
9
+ ```
10
+
11
+ Every built-in library ships inside this one package, under `libs/`. Point
12
+ TypeScript at them from your `tsconfig.json`:
13
+
14
+ ```jsonc
15
+ {
16
+ "compilerOptions": {
17
+ "libReplacement": true, // TypeScript 6.0 and later
18
+ "paths": {
19
+ "@typescript/lib-*": ["./node_modules/strict-ts-lib-v5.0/libs/*"],
20
+ },
21
+ },
22
+ }
23
+ ```
24
+
25
+ `paths` is replaced, not merged, by a config that `extends` another, so it
26
+ has to be written in whichever config TypeScript actually loads.
27
+
28
+ See <https://github.com/noshiro-pf/strict-typescript-lib> for usage and version support.
@@ -0,0 +1,344 @@
1
+ /// <reference no-default-lib="true"/>
2
+
3
+ /**
4
+ * The decorator context types provided to class element decorators.
5
+ */
6
+ type ClassMemberDecoratorContext =
7
+ | ClassMethodDecoratorContext
8
+ | ClassGetterDecoratorContext
9
+ | ClassSetterDecoratorContext
10
+ | ClassFieldDecoratorContext
11
+ | ClassAccessorDecoratorContext;
12
+
13
+ /**
14
+ * The decorator context types provided to any decorator.
15
+ */
16
+ type DecoratorContext = ClassDecoratorContext | ClassMemberDecoratorContext;
17
+
18
+ /**
19
+ * Context provided to a class decorator.
20
+ * @template Class The type of the decorated class associated with this context.
21
+ */
22
+ interface ClassDecoratorContext<
23
+ Class extends abstract new (...args: readonly never[]) => unknown =
24
+ abstract new (...args: readonly never[]) => unknown,
25
+ > {
26
+ /** The kind of element that was decorated. */
27
+ readonly kind: 'class';
28
+
29
+ /** The name of the decorated class. */
30
+ readonly name: string | undefined;
31
+
32
+ /**
33
+ * Adds a callback to be invoked after the class definition has been finalized.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * function customElement(name: string): ClassDecoratorFunction {
38
+ * return (target, context) => {
39
+ * context.addInitializer(function () {
40
+ * customElements.define(name, this);
41
+ * });
42
+ * }
43
+ * }
44
+ *
45
+ * @customElement("my-element")
46
+ * class MyElement {}
47
+ * ```
48
+ */
49
+ addInitializer(initializer: (this: Class) => void): void;
50
+ }
51
+
52
+ /**
53
+ * Context provided to a class method decorator.
54
+ * @template This The type on which the class element will be defined. For a static class element, this will be
55
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
56
+ * @template Value The type of the decorated class method.
57
+ */
58
+ interface ClassMethodDecoratorContext<
59
+ This = unknown,
60
+ Value extends (this: This, ...args: readonly never[]) => unknown = (
61
+ this: This,
62
+ ...args: readonly never[]
63
+ ) => unknown,
64
+ > {
65
+ /** The kind of class element that was decorated. */
66
+ readonly kind: 'method';
67
+
68
+ /** The name of the decorated class element. */
69
+ readonly name: string | symbol;
70
+
71
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
72
+ readonly static: boolean;
73
+
74
+ /** A value indicating whether the class element has a private name. */
75
+ readonly private: boolean;
76
+
77
+ /** An object that can be used to access the current value of the class element at runtime. */
78
+ readonly access: {
79
+ /**
80
+ * Determines whether an object has a property with the same name as the decorated element.
81
+ */
82
+ has(object: This): boolean;
83
+ /**
84
+ * Gets the current value of the method from the provided object.
85
+ *
86
+ * @example
87
+ * let fn = context.access.get(instance);
88
+ */
89
+ get(object: This): Value;
90
+ };
91
+
92
+ /**
93
+ * Adds a callback to be invoked either before static initializers are run (when
94
+ * decorating a `static` element), or before instance initializers are run (when
95
+ * decorating a non-`static` element).
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const bound: ClassMethodDecoratorFunction = (value, context) {
100
+ * if (context.private) throw new TypeError("Not supported on private methods.");
101
+ * context.addInitializer(function () {
102
+ * this[context.name] = this[context.name].bind(this);
103
+ * });
104
+ * }
105
+ *
106
+ * class C {
107
+ * message = "Hello";
108
+ *
109
+ * @bound
110
+ * m() {
111
+ * console.log(this.message);
112
+ * }
113
+ * }
114
+ * ```
115
+ */
116
+ addInitializer(initializer: (this: This) => void): void;
117
+ }
118
+
119
+ /**
120
+ * Context provided to a class getter decorator.
121
+ * @template This The type on which the class element will be defined. For a static class element, this will be
122
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
123
+ * @template Value The property type of the decorated class getter.
124
+ */
125
+ interface ClassGetterDecoratorContext<This = unknown, Value = unknown> {
126
+ /** The kind of class element that was decorated. */
127
+ readonly kind: 'getter';
128
+
129
+ /** The name of the decorated class element. */
130
+ readonly name: string | symbol;
131
+
132
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
133
+ readonly static: boolean;
134
+
135
+ /** A value indicating whether the class element has a private name. */
136
+ readonly private: boolean;
137
+
138
+ /** An object that can be used to access the current value of the class element at runtime. */
139
+ readonly access: {
140
+ /**
141
+ * Determines whether an object has a property with the same name as the decorated element.
142
+ */
143
+ has(object: This): boolean;
144
+ /**
145
+ * Invokes the getter on the provided object.
146
+ *
147
+ * @example
148
+ * let value = context.access.get(instance);
149
+ */
150
+ get(object: This): Value;
151
+ };
152
+
153
+ /**
154
+ * Adds a callback to be invoked either before static initializers are run (when
155
+ * decorating a `static` element), or before instance initializers are run (when
156
+ * decorating a non-`static` element).
157
+ */
158
+ addInitializer(initializer: (this: This) => void): void;
159
+ }
160
+
161
+ /**
162
+ * Context provided to a class setter decorator.
163
+ * @template This The type on which the class element will be defined. For a static class element, this will be
164
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
165
+ * @template Value The type of the decorated class setter.
166
+ */
167
+ interface ClassSetterDecoratorContext<This = unknown, Value = unknown> {
168
+ /** The kind of class element that was decorated. */
169
+ readonly kind: 'setter';
170
+
171
+ /** The name of the decorated class element. */
172
+ readonly name: string | symbol;
173
+
174
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
175
+ readonly static: boolean;
176
+
177
+ /** A value indicating whether the class element has a private name. */
178
+ readonly private: boolean;
179
+
180
+ /** An object that can be used to access the current value of the class element at runtime. */
181
+ readonly access: {
182
+ /**
183
+ * Determines whether an object has a property with the same name as the decorated element.
184
+ */
185
+ has(object: This): boolean;
186
+ /**
187
+ * Invokes the setter on the provided object.
188
+ *
189
+ * @example
190
+ * context.access.set(instance, value);
191
+ */
192
+ set(object: This, value: Value): void;
193
+ };
194
+
195
+ /**
196
+ * Adds a callback to be invoked either before static initializers are run (when
197
+ * decorating a `static` element), or before instance initializers are run (when
198
+ * decorating a non-`static` element).
199
+ */
200
+ addInitializer(initializer: (this: This) => void): void;
201
+ }
202
+
203
+ /**
204
+ * Context provided to a class `accessor` field decorator.
205
+ * @template This The type on which the class element will be defined. For a static class element, this will be
206
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
207
+ * @template Value The type of decorated class field.
208
+ */
209
+ interface ClassAccessorDecoratorContext<This = unknown, Value = unknown> {
210
+ /** The kind of class element that was decorated. */
211
+ readonly kind: 'accessor';
212
+
213
+ /** The name of the decorated class element. */
214
+ readonly name: string | symbol;
215
+
216
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
217
+ readonly static: boolean;
218
+
219
+ /** A value indicating whether the class element has a private name. */
220
+ readonly private: boolean;
221
+
222
+ /** An object that can be used to access the current value of the class element at runtime. */
223
+ readonly access: {
224
+ /**
225
+ * Determines whether an object has a property with the same name as the decorated element.
226
+ */
227
+ has(object: This): boolean;
228
+
229
+ /**
230
+ * Invokes the getter on the provided object.
231
+ *
232
+ * @example
233
+ * let value = context.access.get(instance);
234
+ */
235
+ get(object: This): Value;
236
+
237
+ /**
238
+ * Invokes the setter on the provided object.
239
+ *
240
+ * @example
241
+ * context.access.set(instance, value);
242
+ */
243
+ set(object: This, value: Value): void;
244
+ };
245
+
246
+ /**
247
+ * Adds a callback to be invoked either before static initializers are run (when
248
+ * decorating a `static` element), or before instance initializers are run (when
249
+ * decorating a non-`static` element).
250
+ */
251
+ addInitializer(initializer: (this: This) => void): void;
252
+ }
253
+
254
+ /**
255
+ * Describes the target provided to class `accessor` field decorators.
256
+ * @template This The `this` type to which the target applies.
257
+ * @template Value The property type for the class `accessor` field.
258
+ */
259
+ interface ClassAccessorDecoratorTarget<This, Value> {
260
+ /**
261
+ * Invokes the getter that was defined prior to decorator application.
262
+ *
263
+ * @example
264
+ * let value = target.get.call(instance);
265
+ */
266
+ get(this: This): Value;
267
+
268
+ /**
269
+ * Invokes the setter that was defined prior to decorator application.
270
+ *
271
+ * @example
272
+ * target.set.call(instance, value);
273
+ */
274
+ set(this: This, value: Value): void;
275
+ }
276
+
277
+ /**
278
+ * Describes the allowed return value from a class `accessor` field decorator.
279
+ * @template This The `this` type to which the target applies.
280
+ * @template Value The property type for the class `accessor` field.
281
+ */
282
+ interface ClassAccessorDecoratorResult<This, Value> {
283
+ /**
284
+ * An optional replacement getter function. If not provided, the existing getter function is used instead.
285
+ */
286
+ get?(this: This): Value;
287
+
288
+ /**
289
+ * An optional replacement setter function. If not provided, the existing setter function is used instead.
290
+ */
291
+ set?(this: This, value: Value): void;
292
+
293
+ /**
294
+ * An optional initializer mutator that is invoked when the underlying field initializer is evaluated.
295
+ * @param value The incoming initializer value.
296
+ * @returns The replacement initializer value.
297
+ */
298
+ init?(this: This, value: Value): Value;
299
+ }
300
+
301
+ /**
302
+ * Context provided to a class field decorator.
303
+ * @template This The type on which the class element will be defined. For a static class element, this will be
304
+ * the type of the constructor. For a non-static class element, this will be the type of the instance.
305
+ * @template Value The type of the decorated class field.
306
+ */
307
+ interface ClassFieldDecoratorContext<This = unknown, Value = unknown> {
308
+ /** The kind of class element that was decorated. */
309
+ readonly kind: 'field';
310
+
311
+ /** The name of the decorated class element. */
312
+ readonly name: string | symbol;
313
+
314
+ /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */
315
+ readonly static: boolean;
316
+
317
+ /** A value indicating whether the class element has a private name. */
318
+ readonly private: boolean;
319
+
320
+ /** An object that can be used to access the current value of the class element at runtime. */
321
+ readonly access: {
322
+ /**
323
+ * Determines whether an object has a property with the same name as the decorated element.
324
+ */
325
+ has(object: This): boolean;
326
+
327
+ /**
328
+ * Gets the value of the field on the provided object.
329
+ */
330
+ get(object: This): Value;
331
+
332
+ /**
333
+ * Sets the value of the field on the provided object.
334
+ */
335
+ set(object: This, value: Value): void;
336
+ };
337
+
338
+ /**
339
+ * Adds a callback to be invoked either before static initializers are run (when
340
+ * decorating a `static` element), or before instance initializers are run (when
341
+ * decorating a non-`static` element).
342
+ */
343
+ addInitializer(initializer: (this: This) => void): void;
344
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference no-default-lib="true"/>
2
+
3
+ declare type ClassDecorator = <TFunction extends Function>(
4
+ target: TFunction,
5
+ ) => TFunction | void;
6
+ declare type PropertyDecorator = (
7
+ target: Object,
8
+ propertyKey: string | symbol,
9
+ ) => void;
10
+ declare type MethodDecorator = <T>(
11
+ target: Object,
12
+ propertyKey: string | symbol,
13
+ descriptor: TypedPropertyDescriptor<T>,
14
+ ) => TypedPropertyDescriptor<T> | void;
15
+ declare type ParameterDecorator = (
16
+ target: Object,
17
+ propertyKey: string | symbol | undefined,
18
+ parameterIndex: number,
19
+ ) => void;