@radomiej/compiler-types 3.0.9-types.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/LICENSE +21 -0
- package/README.md +1 -0
- package/package.json +27 -0
- package/types/Array.d.ts +280 -0
- package/types/Iterable.d.ts +53 -0
- package/types/Map.d.ts +126 -0
- package/types/Promise.d.ts +647 -0
- package/types/Set.d.ts +74 -0
- package/types/SharedTable.d.ts +4 -0
- package/types/String.d.ts +16 -0
- package/types/Symbol.d.ts +19 -0
- package/types/callMacros.d.ts +88 -0
- package/types/core.d.ts +157 -0
- package/types/eslintIgnore.d.ts +16 -0
- package/types/typeUtils.d.ts +126 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 roblox-ts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @rbxts/compiler-types
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@radomiej/compiler-types",
|
|
3
|
+
"version": "3.0.9-types.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "types/core.d.ts",
|
|
6
|
+
"types": "types/core.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"eslint": "npx eslint \"types/**/*.d.ts\" --max-warnings 0"
|
|
9
|
+
},
|
|
10
|
+
"author": "roblox-ts",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"files": [
|
|
13
|
+
"types/*.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@rbxts/types": "^1.0.805",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
|
18
|
+
"@typescript-eslint/parser": "^8.5.0",
|
|
19
|
+
"eslint": "^8.57.0",
|
|
20
|
+
"eslint-config-prettier": "^9.1.0",
|
|
21
|
+
"eslint-plugin-no-autofix": "^2.1.0",
|
|
22
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
23
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
24
|
+
"prettier": "^3.3.3",
|
|
25
|
+
"typescript": "5.9.3"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/types/Array.d.ts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference types="@rbxts/types"/>
|
|
3
|
+
|
|
4
|
+
interface ArrayLike<T> {
|
|
5
|
+
/**
|
|
6
|
+
* **DO NOT USE!**
|
|
7
|
+
*
|
|
8
|
+
* This field exists to force TypeScript to recognize this as a nominal type
|
|
9
|
+
* @hidden
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
readonly _nominal_Array: unique symbol;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the length of the array. This is one higher than the highest index defined in an array.
|
|
16
|
+
*/
|
|
17
|
+
size(): number;
|
|
18
|
+
|
|
19
|
+
readonly [n: number]: T;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** An array object which cannot be written to. */
|
|
23
|
+
interface ReadonlyArray<T> extends ArrayLike<T>, Iterable<T> {
|
|
24
|
+
/**
|
|
25
|
+
* Returns true if empty, otherwise false.
|
|
26
|
+
*/
|
|
27
|
+
isEmpty(this: ReadonlyArray<any>): boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Adds all the elements of an array separated by the specified separator string.
|
|
31
|
+
* @param separator A string used to separate one element of an array from the next in the resulting String. If
|
|
32
|
+
* omitted, the array elements are separated with a comma.
|
|
33
|
+
*/
|
|
34
|
+
join(this: ReadonlyArray<defined>, separator?: string): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Moves elements to array a2. Returns the destination table a2.
|
|
38
|
+
* @param f The beginning of the specified portion of a1.
|
|
39
|
+
* @param e The end of the specified portion of a1.
|
|
40
|
+
* @param t The beginning of the specified portion of a2.
|
|
41
|
+
* @param a2 The target array.
|
|
42
|
+
*/
|
|
43
|
+
move(this: ReadonlyArray<defined>, f: number, e: number, t: number, a2: Array<T>): Array<T>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Moves elements to array a2. Returns the destination table a2. The destination range can overlap with the source
|
|
47
|
+
* range.
|
|
48
|
+
* @param f The beginning of the specified portion of a1.
|
|
49
|
+
* @param e The end of the specified portion of a1.
|
|
50
|
+
* @param t The beginning of the specified portion of a2.
|
|
51
|
+
* @param a2 The target array, or the current array if unspecified.
|
|
52
|
+
*/
|
|
53
|
+
move(this: Array<defined>, f: number, e: number, t: number, a2?: Array<T>): Array<T>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns whether an array includes a certain element.
|
|
57
|
+
* @param searchElement The element to search for.
|
|
58
|
+
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
|
59
|
+
*/
|
|
60
|
+
includes(this: ReadonlyArray<defined>, searchElement: T, fromIndex?: number): boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns the index of the first occurrence of a value in an array, else returns -1.
|
|
64
|
+
* @param searchElement The value to locate in the array.
|
|
65
|
+
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at
|
|
66
|
+
* index 0.
|
|
67
|
+
*/
|
|
68
|
+
indexOf(this: ReadonlyArray<defined>, searchElement: T, fromIndex?: number): number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns whether **all** the members of an array satisfy the specified test.
|
|
72
|
+
* Returns true for empty Arrays.
|
|
73
|
+
* @param callback A function that accepts up to three arguments. The every method calls the callback function for
|
|
74
|
+
* each element in array1 until the callback returns false, or until the end of the array.
|
|
75
|
+
*/
|
|
76
|
+
every(
|
|
77
|
+
this: ReadonlyArray<defined>,
|
|
78
|
+
callback: (value: T, index: number, array: ReadonlyArray<T>) => boolean | undefined,
|
|
79
|
+
): boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns whether the specified callback function returns true for any element of an array.
|
|
83
|
+
* Returns false for empty Arrays.
|
|
84
|
+
* @param callback A function that accepts up to three arguments. The some method calls the callback function for
|
|
85
|
+
* each element in array1 until the callback returns true, or until the end of the array.
|
|
86
|
+
*/
|
|
87
|
+
some(
|
|
88
|
+
this: ReadonlyArray<defined>,
|
|
89
|
+
callback: (value: T, index: number, array: ReadonlyArray<T>) => boolean | undefined,
|
|
90
|
+
): boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Performs the specified action for each element in an array.
|
|
94
|
+
* @param callback A function that accepts up to three arguments. forEach calls the callback function one time for
|
|
95
|
+
* each element in the array.
|
|
96
|
+
*/
|
|
97
|
+
forEach(this: ReadonlyArray<defined>, callback: (value: T, index: number, array: ReadonlyArray<T>) => void): void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
|
101
|
+
* @param callback A function that accepts up to three arguments. The map method calls the callback function one
|
|
102
|
+
* time for each element in the array.
|
|
103
|
+
*/
|
|
104
|
+
map<U>(this: ReadonlyArray<defined>, callback: (value: T, index: number, array: ReadonlyArray<T>) => U): Array<U>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
|
108
|
+
* Undefined values will not be included, so keep in mind this does not create a 1:1 map.
|
|
109
|
+
* @param callback A function that accepts up to three arguments. The map method calls the callback function one
|
|
110
|
+
* time for each element in the array.
|
|
111
|
+
* @example
|
|
112
|
+
* // Gets an Array of all existing characters
|
|
113
|
+
* const characters = playerlist.mapFiltered(plr => plr.Character);
|
|
114
|
+
*/
|
|
115
|
+
mapFiltered<U>(
|
|
116
|
+
this: ReadonlyArray<defined>,
|
|
117
|
+
callback: (value: T, index: number, array: ReadonlyArray<T>) => U,
|
|
118
|
+
): Array<NonNullable<U>>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Removes all undefined values from the array safely
|
|
122
|
+
*/
|
|
123
|
+
filterUndefined(this: ReadonlyArray<T>): Array<NonNullable<T>>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Returns the elements of an array that meet the condition specified in a callback function.
|
|
127
|
+
* @param callback A function that accepts up to three arguments. The filter method calls the callback function one
|
|
128
|
+
* time for each element in the array.
|
|
129
|
+
*/
|
|
130
|
+
filter<S extends T>(
|
|
131
|
+
this: ReadonlyArray<defined>,
|
|
132
|
+
callback: (value: T, index: number, array: ReadonlyArray<T>) => value is S,
|
|
133
|
+
): Array<S>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns the elements of an array that meet the condition specified in a callback function.
|
|
137
|
+
* @param callback A function that accepts up to three arguments. The filter method calls the callback function one
|
|
138
|
+
* time for each element in the array.
|
|
139
|
+
*/
|
|
140
|
+
filter(
|
|
141
|
+
this: ReadonlyArray<defined>,
|
|
142
|
+
callback: (value: T, index: number, array: ReadonlyArray<T>) => boolean | undefined,
|
|
143
|
+
): Array<T>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Calls the specified callback function for all the elements in an array. The return value of the callback function
|
|
147
|
+
* is the accumulated result, and is provided as an argument in the next call to the callback function.
|
|
148
|
+
* @param callback A function that accepts up to four arguments. The reduce method calls the callback function one
|
|
149
|
+
* time for each element in the array.
|
|
150
|
+
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The
|
|
151
|
+
* first call to the callback function provides this value as an argument instead of an array value.
|
|
152
|
+
*/
|
|
153
|
+
reduce(
|
|
154
|
+
this: ReadonlyArray<defined>,
|
|
155
|
+
callback: (accumulator: T, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => T,
|
|
156
|
+
): T;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Calls the specified callback function for all the elements in an array. The return value of the callback function
|
|
160
|
+
* is the accumulated result, and is provided as an argument in the next call to the callback function.
|
|
161
|
+
* @param callback A function that accepts up to four arguments. The reduce method calls the callback function one
|
|
162
|
+
* time for each element in the array.
|
|
163
|
+
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The
|
|
164
|
+
* first call to the callback function provides this value as an argument instead of an array value.
|
|
165
|
+
*/
|
|
166
|
+
reduce<U>(
|
|
167
|
+
this: ReadonlyArray<defined>,
|
|
168
|
+
callback: (accumulator: U, currentValue: T, currentIndex: number, array: ReadonlyArray<T>) => U,
|
|
169
|
+
initialValue: U,
|
|
170
|
+
): U;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns the value of the first element in the array where predicate is true, and undefined
|
|
174
|
+
* otherwise.
|
|
175
|
+
* @param predicate find calls predicate once for each element of the array, in ascending
|
|
176
|
+
* order, until it finds one where predicate returns true. If such an element is found, find
|
|
177
|
+
* immediately returns that element value. Otherwise, find returns undefined.
|
|
178
|
+
*/
|
|
179
|
+
find<S extends T>(
|
|
180
|
+
this: ReadonlyArray<defined>,
|
|
181
|
+
predicate: (value: T, index: number, obj: ReadonlyArray<T>) => value is S,
|
|
182
|
+
): S | undefined;
|
|
183
|
+
find(
|
|
184
|
+
this: ReadonlyArray<defined>,
|
|
185
|
+
predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean | undefined,
|
|
186
|
+
): T | undefined;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it
|
|
190
|
+
* returns -1, indicating no element passed the test.
|
|
191
|
+
* @param predicate findIndex calls predicate once for each element of the array, in ascending
|
|
192
|
+
* order, until it finds one where predicate returns true. If such an element is found, find
|
|
193
|
+
* immediately returns the index at which it was found. Otherwise, find returns -1.
|
|
194
|
+
*/
|
|
195
|
+
findIndex(
|
|
196
|
+
this: ReadonlyArray<defined>,
|
|
197
|
+
predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean | undefined,
|
|
198
|
+
): number;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface Array<T> extends ReadonlyArray<T> {
|
|
202
|
+
/**
|
|
203
|
+
* Appends new elements to an array and returns the new length of the array.
|
|
204
|
+
* @param items New elements of the Array.
|
|
205
|
+
*/
|
|
206
|
+
push(this: Array<defined>, ...items: Array<T>): number;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Removes the last element from an array and returns it.
|
|
210
|
+
*/
|
|
211
|
+
pop(this: Array<defined>): T | undefined;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Removes the first element from an array and returns it.
|
|
215
|
+
*/
|
|
216
|
+
shift(this: Array<defined>): T | undefined;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Inserts new elements at the start of an array and returns the new length of the array.
|
|
220
|
+
* @param items Elements to insert at the start of the Array.
|
|
221
|
+
*/
|
|
222
|
+
unshift(this: Array<defined>, ...items: Array<T>): number;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Inserts `value` into the array at `index` and shifts array members forwards if needed.
|
|
226
|
+
*/
|
|
227
|
+
insert(this: Array<defined>, index: number, value: T): void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Removes the array member at `index` and returns it and shifts array members backwards if needed.
|
|
231
|
+
*/
|
|
232
|
+
remove(this: Array<defined>, index: number): T | undefined;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Removes a value at `index` from this array, replacing it with the last value in this array and popping the last
|
|
236
|
+
* value.
|
|
237
|
+
* Returns the value removed from `index` in this way if it exists, otherwise `undefined`.
|
|
238
|
+
* @param index The index to remove from this array and return
|
|
239
|
+
*/
|
|
240
|
+
unorderedRemove(this: Array<defined>, index: number): T | undefined;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Sorts list elements in a given order, in-place, from `list[1]` to `list[#list]`, so that
|
|
244
|
+
* (`!comp(list[i+1], list[i])` will be true after the sort). Alias to Lua's `table.sort`.
|
|
245
|
+
* @param compareFunction A function that defines the sort order. Returns true when the first element must come
|
|
246
|
+
* before the second. If omitted, the array is sorted according to the `<` operator.
|
|
247
|
+
*/
|
|
248
|
+
sort(this: Array<defined>, compareFunction?: (a: T, b: T) => boolean): Array<T>;
|
|
249
|
+
|
|
250
|
+
/** Deletes all values in the Array */
|
|
251
|
+
clear(this: Array<T>): void;
|
|
252
|
+
|
|
253
|
+
[n: number]: T;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface ArrayConstructor {
|
|
257
|
+
/** Instantiates a new empty array. */
|
|
258
|
+
new <T>(): Array<T>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Instantiates a new preallocated array.
|
|
262
|
+
* If `length` is provided, there will be allocated `length` amount of nil's into the new array.
|
|
263
|
+
* If `value` is provided, instead of nil, the value will be allocated instead.
|
|
264
|
+
*
|
|
265
|
+
* This is the same as `table.create` in Lua.
|
|
266
|
+
*
|
|
267
|
+
* @param length The length of the array to allocate
|
|
268
|
+
* @param value The value that the array will be filled with (amount based on `length`)
|
|
269
|
+
*/
|
|
270
|
+
new <T>(length: number): Array<T>;
|
|
271
|
+
new <T>(length: number, value: T): Array<T>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare const Array: ArrayConstructor;
|
|
275
|
+
|
|
276
|
+
interface TemplateStringsArray extends Array<string> {}
|
|
277
|
+
|
|
278
|
+
type ReadVoxelsArray<T> = Array<Array<Array<T>>> & {
|
|
279
|
+
Size: Vector3;
|
|
280
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference types="@rbxts/types"/>
|
|
3
|
+
|
|
4
|
+
type IteratorResult<Yields, Returns = void> = IteratorYieldResult<Yields> | IteratorReturnResult<Returns>;
|
|
5
|
+
|
|
6
|
+
interface IteratorYieldResult<Yields> {
|
|
7
|
+
done: false;
|
|
8
|
+
value: Yields;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface IteratorReturnResult<Returns> {
|
|
12
|
+
done: true;
|
|
13
|
+
value: Returns;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Iterator<Yields, Returns = void, Next = undefined> {
|
|
17
|
+
// Takes either 0 or 1 arguments - doesn't accept 'undefined'
|
|
18
|
+
next: (...args: [] | [Next]) => IteratorResult<Yields, Returns>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface AsyncIterator<Yields, Returns = any, Next = undefined> {
|
|
22
|
+
next: (...args: [] | [Next]) => Promise<IteratorResult<Yields, Returns>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface Generator<Yields = unknown, Returns = void, Next = unknown> extends Iterator<Yields, Returns, Next> {
|
|
26
|
+
next: (...args: [] | [Next]) => IteratorResult<Yields, Returns>;
|
|
27
|
+
[Symbol.iterator](): Generator<Yields, Returns, Next>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface AsyncGenerator<Yields = unknown, Returns = any, Next = unknown> extends AsyncIterator<Yields, Returns, Next> {
|
|
31
|
+
next: (...args: [] | [Next]) => Promise<IteratorResult<Yields, Returns>>;
|
|
32
|
+
[Symbol.asyncIterator](): AsyncGenerator<Yields, Returns, Next>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface AsyncIterable<T> {
|
|
36
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Iterable<T> {
|
|
40
|
+
[Symbol.iterator](): Iterator<T>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
|
|
44
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface IterableIterator<T> extends Iterator<T> {
|
|
48
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface IterableFunction<T> extends Iterable<T> {
|
|
52
|
+
(): T;
|
|
53
|
+
}
|
package/types/Map.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference types="@rbxts/types"/>
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A Map object which cannot be written to. The Map object holds key-value pairs but doesn't remember the original insertion order of the keys (like JS would). Any value (both objects and primitive values) may be used as either a key or a value.
|
|
6
|
+
* Maps are the best choice for dynamic indexing/newindexing, whereas Objects are better for explicit indexing.
|
|
7
|
+
* @example
|
|
8
|
+
* // ReadonlyMaps are particularly useful for defining readonly-associations with non-numeric, non-string keys.
|
|
9
|
+
* new ReadonlyMap<Enum.HumanoidRigType, () => void>([
|
|
10
|
+
* [Enum.HumanoidRigType.R6, () => {}],
|
|
11
|
+
* [Enum.HumanoidRigType.R15, () => {}],
|
|
12
|
+
* ]);
|
|
13
|
+
* // Do not use Maps when you can easily index from an object:
|
|
14
|
+
*
|
|
15
|
+
* // TS doesn't assume "x" | "y" are the only possible fields.
|
|
16
|
+
* // You could manually type this as ReadonlyMap<"x" | "y", number>
|
|
17
|
+
* const point = new ReadonlyMap([["x", 5], ["y", 10]]);
|
|
18
|
+
* // this is typed as possibly undefined, which isn't ideal
|
|
19
|
+
* print(point.get("x"));
|
|
20
|
+
*
|
|
21
|
+
* // Instead use an object
|
|
22
|
+
* const point = { x: 5, y: 10 } as const;
|
|
23
|
+
* print(point.x);
|
|
24
|
+
*/
|
|
25
|
+
interface ReadonlyMap<K, V> extends Iterable<[K, V]> {
|
|
26
|
+
/**
|
|
27
|
+
* **DO NOT USE!**
|
|
28
|
+
*
|
|
29
|
+
* This field exists to force TypeScript to recognize this as a nominal type
|
|
30
|
+
* @hidden
|
|
31
|
+
* @deprecated
|
|
32
|
+
*/
|
|
33
|
+
readonly _nominal_Map: unique symbol;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if empty, otherwise false.
|
|
37
|
+
*/
|
|
38
|
+
isEmpty(this: ReadonlyMap<K, V>): boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Performs the specified action for each (element / pair of elements) in the Map
|
|
42
|
+
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time
|
|
43
|
+
* for each (element / pair of elements) in the array.
|
|
44
|
+
*/
|
|
45
|
+
forEach(this: ReadonlyMap<K, V>, callbackfn: (value: V, key: K, self: this) => void): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns the number of elements in the Map
|
|
49
|
+
*/
|
|
50
|
+
size(this: ReadonlyMap<K, V>): number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Returns a boolean for whether the given key exists in the Map
|
|
54
|
+
*/
|
|
55
|
+
has(this: ReadonlyMap<K, V>, key: K): boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the value associated with the given key
|
|
59
|
+
*/
|
|
60
|
+
get(this: ReadonlyMap<K, V>, key: K): V | undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ReadonlyMapConstructor {
|
|
64
|
+
new <K, V>(): ReadonlyMap<K, V>;
|
|
65
|
+
new <K, V>(entries: ReadonlyArray<readonly [K, V]>): ReadonlyMap<K, V>;
|
|
66
|
+
}
|
|
67
|
+
declare const ReadonlyMap: ReadonlyMapConstructor;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The Map object holds key-value pairs but doesn't remember the original insertion order of the keys (like JS would). Any value (both objects and primitive values) may be used as either a key or a value.
|
|
71
|
+
* Maps are the best choice for dynamic indexing/newindexing, whereas Objects are better for explicit indexing.
|
|
72
|
+
* @example
|
|
73
|
+
* const playerData = new Map<Player, PlayerData>();
|
|
74
|
+
*
|
|
75
|
+
* function f(plr: Player) {
|
|
76
|
+
* const data = playerData.get(plr); // `data` could be undefined
|
|
77
|
+
* if (data) { // check to make sure `data` is defined
|
|
78
|
+
* print(`${plr.Name} has ${data.NumItems} item${data.NumItems === 1 ? "" : "s"}`);
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* // Do not use Maps when you can easily explicitly index from an object:
|
|
82
|
+
*
|
|
83
|
+
* // TS doesn't assume "x" | "y" are the only possible fields.
|
|
84
|
+
* // You could manually type this as Map<"x" | "y", number>
|
|
85
|
+
* const point = new Map([["x", 5], ["y", 10]]);
|
|
86
|
+
* // this is typed as possibly undefined, because "x" can be deleted
|
|
87
|
+
* print(point.get("x"));
|
|
88
|
+
*
|
|
89
|
+
* // Instead use an object
|
|
90
|
+
* const point = { x: 5, y: 10 };
|
|
91
|
+
* print(point.y++);
|
|
92
|
+
* point.z = 15 // error!
|
|
93
|
+
*/
|
|
94
|
+
interface Map<K, V> extends ReadonlyMap<K, V> {
|
|
95
|
+
/**
|
|
96
|
+
* Associates a key with a value which can be accessed later by `Map.get`
|
|
97
|
+
*/
|
|
98
|
+
set(this: Map<K, V>, key: K, value: V): this;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Deletes the given key from the Map.
|
|
102
|
+
*
|
|
103
|
+
* Returns a boolean indicating whether or not a value was removed.
|
|
104
|
+
*/
|
|
105
|
+
delete(this: Map<K, V>, key: K): boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Deletes all members of the Map
|
|
109
|
+
*/
|
|
110
|
+
clear(this: Map<K, V>): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface MapConstructor {
|
|
114
|
+
new <K, V>(): Map<K, V>;
|
|
115
|
+
new <K, V>(entries: ReadonlyArray<readonly [K, V]>): Map<K, V>;
|
|
116
|
+
}
|
|
117
|
+
declare const Map: MapConstructor;
|
|
118
|
+
|
|
119
|
+
/** A Map object with its `__mode` metamethod set to "k" */
|
|
120
|
+
interface WeakMap<K extends object, V> extends Map<K, V> {}
|
|
121
|
+
|
|
122
|
+
interface WeakMapConstructor {
|
|
123
|
+
new <K extends object, V>(): WeakMap<K, V>;
|
|
124
|
+
new <K extends object, V>(entries: ReadonlyArray<readonly [K, V]>): WeakMap<K, V>;
|
|
125
|
+
}
|
|
126
|
+
declare const WeakMap: WeakMapConstructor;
|