-
-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathindex.d.ts
More file actions
697 lines (626 loc) · 31 KB
/
index.d.ts
File metadata and controls
697 lines (626 loc) · 31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/* eslint-disable @typescript-eslint/naming-convention */
type AnyTable = Record<any, any>;
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions,@typescript-eslint/no-empty-object-type
type AnyNotNil = {};
/**
* Indicates a type is a language extension provided by TypescriptToLua when used as a value or function call.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TBrand A string used to uniquely identify the language extension type
*/
declare interface LuaExtension<TBrand extends string> {
readonly __tstlExtension: TBrand;
}
/**
* Indicates a type is a language extension provided by TypescriptToLua when used in a for-of loop.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TBrand A string used to uniquely identify the language extension type
*/
declare interface LuaIterationExtension<TBrand extends string> {
readonly __tstlIterable: TBrand;
}
/**
* Returns multiple values from a function, by wrapping them in a LuaMultiReturn tuple.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param T A tuple type with each element type representing a return value's type.
* @param values Return values.
*/
declare const $multi: (<T extends any[]>(...values: T) => LuaMultiReturn<T>) & LuaExtension<"MultiFunction">;
/**
* Represents multiple return values as a tuple.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param T A tuple type with each element type representing a return value's type.
*/
declare type LuaMultiReturn<T extends any[]> = T & {
readonly __tstlMultiReturn: any;
};
/**
* Creates a Lua-style numeric for loop (for i=start,limit,step) when used in for...of. Not valid in any other context.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param start The first number in the sequence to iterate over.
* @param limit The last number in the sequence to iterate over.
* @param step The amount to increment each iteration.
*/
declare const $range: ((start: number, limit: number, step?: number) => Iterable<number>) &
LuaExtension<"RangeFunction">;
/**
* Transpiles to the global vararg (`...`)
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*/
declare const $vararg: string[] & LuaExtension<"VarargConstant">;
/**
* Represents a Lua-style iterator which is returned from a LuaIterable.
* For simple iterators (with no state), this is just a function.
* For complex iterators that use a state, this is a LuaMultiReturn tuple containing a function, the state, and the initial value to pass to the function.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param state The state object returned from the LuaIterable.
* @param lastValue The last value returned from this function. If iterating LuaMultiReturn values, this is the first value of the tuple.
*/
declare type LuaIterator<TValue, TState> = TState extends undefined
? (this: void) => TValue
: LuaMultiReturn<
[
(
this: void,
state: TState,
lastValue: TValue extends LuaMultiReturn<infer TTuple> ? TTuple[0] : TValue
) => TValue,
TState,
TValue extends LuaMultiReturn<infer TTuple> ? TTuple[0] : TValue
]
>;
/**
* Represents a Lua-style iteratable which iterates single values in a `for...in` loop (ex. `for x in iter() do`).
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TValue The type of value returned each iteration. If this is LuaMultiReturn, multiple values will be returned each iteration.
* @param TState The type of the state value passed back to the iterator function each iteration.
*/
declare type LuaIterable<TValue, TState = undefined> = Iterable<TValue> &
LuaIterator<TValue, TState> &
LuaIterationExtension<"Iterable">;
/**
* Represents an object that can be iterated with pairs()
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the key returned each iteration.
* @param TValue The type of the value returned each iteration.
*/
declare type LuaPairsIterable<TKey extends AnyNotNil, TValue> = Iterable<[TKey, TValue]> &
LuaIterationExtension<"Pairs">;
/**
* Represents an object that can be iterated with pairs(), where only the key value is used.
*
* @param TKey The type of the key returned each iteration.
*/
declare type LuaPairsKeyIterable<TKey extends AnyNotNil> = Iterable<TKey> & LuaIterationExtension<"PairsKey">;
/**
* Calls to functions with this type are translated to `left + right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaAddition<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & LuaExtension<"Addition">;
/**
* Calls to methods with this type are translated to `left + right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaAdditionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"AdditionMethod">;
/**
* Calls to functions with this type are translated to `left - right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaSubtraction<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"Subtraction">;
/**
* Calls to methods with this type are translated to `left - right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaSubtractionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"SubtractionMethod">;
/**
* Calls to functions with this type are translated to `left * right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaMultiplication<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"Multiplication">;
/**
* Calls to methods with this type are translated to `left * right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaMultiplicationMethod<TRight, TReturn> = ((right: TRight) => TReturn) &
LuaExtension<"MultiplicationMethod">;
/**
* Calls to functions with this type are translated to `left / right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaDivision<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & LuaExtension<"Division">;
/**
* Calls to methods with this type are translated to `left / right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaDivisionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"DivisionMethod">;
/**
* Calls to functions with this type are translated to `left % right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaModulo<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & LuaExtension<"Modulo">;
/**
* Calls to methods with this type are translated to `left % right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaModuloMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"ModuloMethod">;
/**
* Calls to functions with this type are translated to `left ^ right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaPower<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & LuaExtension<"Power">;
/**
* Calls to methods with this type are translated to `left ^ right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaPowerMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"PowerMethod">;
/**
* Calls to functions with this type are translated to `left // right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaFloorDivision<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"FloorDivision">;
/**
* Calls to methods with this type are translated to `left // right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaFloorDivisionMethod<TRight, TReturn> = ((right: TRight) => TReturn) &
LuaExtension<"FloorDivisionMethod">;
/**
* Calls to functions with this type are translated to `left & right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseAnd<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"BitwiseAnd">;
/**
* Calls to methods with this type are translated to `left & right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseAndMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"BitwiseAndMethod">;
/**
* Calls to functions with this type are translated to `left | right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseOr<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"BitwiseOr">;
/**
* Calls to methods with this type are translated to `left | right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseOrMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"BitwiseOrMethod">;
/**
* Calls to functions with this type are translated to `left ~ right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseExclusiveOr<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"BitwiseExclusiveOr">;
/**
* Calls to methods with this type are translated to `left ~ right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseExclusiveOrMethod<TRight, TReturn> = ((right: TRight) => TReturn) &
LuaExtension<"BitwiseExclusiveOrMethod">;
/**
* Calls to functions with this type are translated to `left << right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseLeftShift<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"BitwiseLeftShift">;
/**
* Calls to methods with this type are translated to `left << right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseLeftShiftMethod<TRight, TReturn> = ((right: TRight) => TReturn) &
LuaExtension<"BitwiseLeftShiftMethod">;
/**
* Calls to functions with this type are translated to `left >> right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseRightShift<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"BitwiseRightShift">;
/**
* Calls to methods with this type are translated to `left >> right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseRightShiftMethod<TRight, TReturn> = ((right: TRight) => TReturn) &
LuaExtension<"BitwiseRightShiftMethod">;
/**
* Calls to functions with this type are translated to `left .. right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaConcat<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & LuaExtension<"Concat">;
/**
* Calls to methods with this type are translated to `left .. right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaConcatMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"ConcatMethod">;
/**
* Calls to functions with this type are translated to `left < right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLessThan<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & LuaExtension<"LessThan">;
/**
* Calls to methods with this type are translated to `left < right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLessThanMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"LessThanMethod">;
/**
* Calls to functions with this type are translated to `left > right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaGreaterThan<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) &
LuaExtension<"GreaterThan">;
/**
* Calls to methods with this type are translated to `left > right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaGreaterThanMethod<TRight, TReturn> = ((right: TRight) => TReturn) & LuaExtension<"GreaterThanMethod">;
/**
* Calls to functions with this type are translated to `-operand`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TOperand The type of the value in the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaNegation<TOperand, TReturn> = ((operand: TOperand) => TReturn) & LuaExtension<"Negation">;
/**
* Calls to method with this type are translated to `-operand`, where `operand` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaNegationMethod<TReturn> = (() => TReturn) & LuaExtension<"NegationMethod">;
/**
* Calls to functions with this type are translated to `~operand`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TOperand The type of the value in the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseNot<TOperand, TReturn> = ((operand: TOperand) => TReturn) & LuaExtension<"BitwiseNot">;
/**
* Calls to method with this type are translated to `~operand`, where `operand` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseNotMethod<TReturn> = (() => TReturn) & LuaExtension<"BitwiseNotMethod">;
/**
* Calls to functions with this type are translated to `#operand`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TOperand The type of the value in the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLength<TOperand, TReturn> = ((operand: TOperand) => TReturn) & LuaExtension<"Length">;
/**
* Calls to method with this type are translated to `#operand`, where `operand` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLengthMethod<TReturn> = (() => TReturn) & LuaExtension<"LengthMethod">;
/**
* Calls to functions with this type are translated to `table[key]`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TTable The type to access as a Lua table.
* @param TKey The type of the key to use to access the table.
* @param TValue The type of the value stored in the table.
*/
declare type LuaTableGet<TTable extends AnyTable, TKey extends AnyNotNil, TValue> = ((
table: TTable,
key: TKey
) => TValue) &
LuaExtension<"TableGet">;
/**
* Calls to methods with this type are translated to `table[key]`, where `table` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the key to use to access the table.
* @param TValue The type of the value stored in the table.
*/
declare type LuaTableGetMethod<TKey extends AnyNotNil, TValue> = ((key: TKey) => TValue) &
LuaExtension<"TableGetMethod">;
/**
* Calls to functions with this type are translated to `table[key] = value`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TTable The type to access as a Lua table.
* @param TKey The type of the key to use to access the table.
* @param TValue The type of the value to assign to the table.
*/
declare type LuaTableSet<TTable extends AnyTable, TKey extends AnyNotNil, TValue> = ((
table: TTable,
key: TKey,
value: TValue
) => void) &
LuaExtension<"TableSet">;
/**
* Calls to methods with this type are translated to `table[key] = value`, where `table` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the key to use to access the table.
* @param TValue The type of the value to assign to the table.
*/
declare type LuaTableSetMethod<TKey extends AnyNotNil, TValue> = ((key: TKey, value: TValue) => void) &
LuaExtension<"TableSetMethod">;
/**
* Calls to functions with this type are translated to `table[key] = true`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TTable The type to access as a Lua table.
* @param TKey The type of the key to use to access the table.
*/
declare type LuaTableAddKey<TTable extends AnyTable, TKey extends AnyNotNil> = ((table: TTable, key: TKey) => void) &
LuaExtension<"TableAddKey">;
/**
* Calls to methods with this type are translated to `table[key] = true`, where `table` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
* @param TKey The type of the key to use to access the table.
*/
declare type LuaTableAddKeyMethod<TKey extends AnyNotNil> = ((key: TKey) => void) & LuaExtension<"TableAddKeyMethod">;
/**
* Calls to functions with this type are translated to `table[key] ~= nil`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TTable The type to access as a Lua table.
* @param TKey The type of the key to use to access the table.
*/
declare type LuaTableHas<TTable extends AnyTable, TKey extends AnyNotNil> = ((table: TTable, key: TKey) => boolean) &
LuaExtension<"TableHas">;
/**
* Calls to methods with this type are translated to `table[key] ~= nil`, where `table` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the key to use to access the table.
*/
declare type LuaTableHasMethod<TKey extends AnyNotNil> = ((key: TKey) => boolean) & LuaExtension<"TableHasMethod">;
/**
* Calls to functions with this type are translated to `table[key] = nil`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TTable The type to access as a Lua table.
* @param TKey The type of the key to use to access the table.
*/
declare type LuaTableDelete<TTable extends AnyTable, TKey extends AnyNotNil> = ((table: TTable, key: TKey) => boolean) &
LuaExtension<"TableDelete">;
/**
* Calls to methods with this type are translated to `table[key] = nil`, where `table` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the key to use to access the table.
*/
declare type LuaTableDeleteMethod<TKey extends AnyNotNil> = ((key: TKey) => boolean) &
LuaExtension<"TableDeleteMethod">;
/**
* Calls to functions with this type are translated to `next(myTable) == nil`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TTable The type to access as a Lua table.
*/
declare type LuaTableIsEmpty<TTable extends AnyTable> = ((table: TTable) => boolean) & LuaExtension<"TableIsEmpty">;
/**
* Calls to methods with this type are translated to `next(myTable) == nil`, where `table` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*/
declare type LuaTableIsEmptyMethod = (() => boolean) & LuaExtension<"TableIsEmptyMethod">;
/**
* A convenience type for working directly with a Lua table.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the keys used to access the table.
* @param TValue The type of the values stored in the table.
*/
declare interface LuaTable<TKey extends AnyNotNil = AnyNotNil, TValue = any> extends LuaPairsIterable<TKey, TValue> {
length: LuaLengthMethod<number>;
get: LuaTableGetMethod<TKey, TValue>;
set: LuaTableSetMethod<TKey, TValue>;
has: LuaTableHasMethod<TKey>;
delete: LuaTableDeleteMethod<TKey>;
isEmpty: LuaTableIsEmptyMethod;
}
/**
* A convenience type for working directly with a Lua table.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the keys used to access the table.
* @param TValue The type of the values stored in the table.
*/
declare type LuaTableConstructor = (new <TKey extends AnyNotNil = AnyNotNil, TValue = any>() => LuaTable<
TKey,
TValue
>) &
LuaExtension<"TableNew">;
/**
* A convenience type for working directly with a Lua table.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TKey The type of the keys used to access the table.
* @param TValue The type of the values stored in the table.
*/
declare const LuaTable: LuaTableConstructor;
/**
* A convenience type for working directly with a Lua table, used as a map.
*
* This differs from LuaTable in that the `get` method may return `nil`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
* @param K The type of the keys used to access the table.
* @param V The type of the values stored in the table.
*/
declare interface LuaMap<K extends AnyNotNil = AnyNotNil, V = any> extends LuaPairsIterable<K, V> {
get: LuaTableGetMethod<K, V | undefined>;
set: LuaTableSetMethod<K, V>;
has: LuaTableHasMethod<K>;
delete: LuaTableDeleteMethod<K>;
isEmpty: LuaTableIsEmptyMethod;
}
/**
* A convenience type for working directly with a Lua table, used as a map.
*
* This differs from LuaTable in that the `get` method may return `nil`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
* @param K The type of the keys used to access the table.
* @param V The type of the values stored in the table.
*/
declare const LuaMap: (new <K extends AnyNotNil = AnyNotNil, V = any>() => LuaMap<K, V>) & LuaExtension<"TableNew">;
/**
* Readonly version of {@link LuaMap}.
*
* @param K The type of the keys used to access the table.
* @param V The type of the values stored in the table.
*/
declare interface ReadonlyLuaMap<K extends AnyNotNil = AnyNotNil, V = any> extends LuaPairsIterable<K, V> {
get: LuaTableGetMethod<K, V | undefined>;
has: LuaTableHasMethod<K>;
isEmpty: LuaTableIsEmptyMethod;
}
/**
* A convenience type for working directly with a Lua table, used as a set.
*
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
* @param T The type of the keys used to access the table.
*/
declare interface LuaSet<T extends AnyNotNil = AnyNotNil> extends LuaPairsKeyIterable<T> {
add: LuaTableAddKeyMethod<T>;
has: LuaTableHasMethod<T>;
delete: LuaTableDeleteMethod<T>;
isEmpty: LuaTableIsEmptyMethod;
}
/**
* A convenience type for working directly with a Lua table, used as a set.
*
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
* @param T The type of the keys used to access the table.
*/
declare const LuaSet: (new <T extends AnyNotNil = AnyNotNil>() => LuaSet<T>) & LuaExtension<"TableNew">;
/**
* Readonly version of {@link LuaSet}.
*
* @param T The type of the keys used to access the table.
*/
declare interface ReadonlyLuaSet<T extends AnyNotNil = AnyNotNil> extends LuaPairsKeyIterable<T> {
has: LuaTableHasMethod<T>;
isEmpty: LuaTableIsEmptyMethod;
}
interface ObjectConstructor {
/** Returns an array of keys of an object, when iterated with `pairs`. */
keys<K extends AnyNotNil>(o: LuaPairsIterable<K, any> | LuaPairsKeyIterable<K>): K[];
/** Returns an array of values of an object, when iterated with `pairs`. */
values<V>(o: LuaPairsIterable<any, V>): V[];
/** Returns an array of key/values of an object, when iterated with `pairs`. */
entries<K extends AnyNotNil, V>(o: LuaPairsIterable<K, V>): Array<[K, V]>;
}