Skip to content

Commit 3e9cace

Browse files
authored
fixes to broken declarations missed by tests (#26)
Co-authored-by: Tom <[email protected]>
1 parent 5a61a23 commit 3e9cace

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

core/debug.d.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,17 @@ declare namespace debug {
192192
* Sets the metatable for the given value to the given table (which can be
193193
* nil). Returns value.
194194
*/
195-
function setmetatable<T, TIndex>(
195+
function setmetatable<
196+
T extends object,
197+
TIndex extends object | ((this: T, key: any) => any) | undefined = undefined
198+
>(
196199
value: T,
197-
table: LuaMetatable<T & TIndex, TIndex> | null | undefined
198-
): T & TIndex;
200+
table?: LuaMetatable<T, TIndex> | null
201+
): TIndex extends (this: T, key: infer TKey) => infer TValue
202+
? T & { [K in TKey & string]: TValue }
203+
: TIndex extends object
204+
? T & TIndex
205+
: T;
199206

200207
/**
201208
* This function assigns the value value to the upvalue with index up of the

core/metatable.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Based on https://www.lua.org/manual/5.3/manual.html#2.4
22

3-
interface LuaMetatable<T, TIndex extends object | ((this: T, key: any) => any) | undefined> {
3+
interface LuaMetatable<
4+
T,
5+
TIndex extends object | ((this: T, key: any) => any) | undefined =
6+
| object
7+
| ((this: T, key: any) => any)
8+
| undefined
9+
> {
410
/**
511
* the addition (+) operation. If any operand for an addition is not a number
612
* (nor a string coercible to a number), Lua will try to call a metamethod.

0 commit comments

Comments
 (0)