File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -192,10 +192,17 @@ declare namespace debug {
192
192
* Sets the metatable for the given value to the given table (which can be
193
193
* nil). Returns value.
194
194
*/
195
- function setmetatable < T , TIndex > (
195
+ function setmetatable <
196
+ T extends object ,
197
+ TIndex extends object | ( ( this : T , key : any ) => any ) | undefined = undefined
198
+ > (
196
199
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 ;
199
206
200
207
/**
201
208
* This function assigns the value value to the upvalue with index up of the
Original file line number Diff line number Diff line change 1
1
// Based on https://www.lua.org/manual/5.3/manual.html#2.4
2
2
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
+ > {
4
10
/**
5
11
* the addition (+) operation. If any operand for an addition is not a number
6
12
* (nor a string coercible to a number), Lua will try to call a metamethod.
You can’t perform that action at this time.
0 commit comments