66
77type LuaThread = { readonly __internal__ : unique symbol } ;
88type LuaUserdata = { readonly __internal__ : unique symbol } ;
9- /** @luaIterator */
10- type LuaIterable < T > = Iterable < T > & { readonly __internal__ : unique symbol } ;
11- /** @luaIterator @tupleReturn */
12- type LuaTupleIterable < T extends any [ ] > = Iterable < T > & { readonly __internal__ : unique symbol } ;
139
1410/**
1511 * A global variable (not a function) that holds a string containing the running
@@ -124,7 +120,7 @@ declare function getmetatable<T extends object>(object: T): LuaMetatable<T> | un
124120 * will iterate over the key–value pairs (1,t[1]), (2,t[2]), ..., up to the
125121 * first nil value.
126122 */
127- declare function ipairs < T > ( t : Record < number , T > ) : LuaTupleIterable < [ number , T ] > ;
123+ declare function ipairs < T > ( t : Record < number , T > ) : LuaIterable < LuaMultiReturn < [ number , T ] > > ;
128124
129125/**
130126 * Allows a program to traverse all fields of a table. Its first argument is a
@@ -142,9 +138,8 @@ declare function ipairs<T>(t: Record<number, T>): LuaTupleIterable<[number, T]>;
142138 * The behavior of next is undefined if, during the traversal, you assign any
143139 * value to a non-existent field in the table. You may however modify existing
144140 * fields. In particular, you may clear existing fields.
145- * @tupleReturn
146141 */
147- declare function next ( table : object , index ?: any ) : [ any , any ] | [ ] ;
142+ declare function next ( table : object , index ?: any ) : LuaMultiReturn < [ any , any ] | [ ] > ;
148143
149144/**
150145 * If t has a metamethod __pairs, calls it with t as argument and returns the
@@ -158,7 +153,7 @@ declare function next(table: object, index?: any): [any, any] | [];
158153 * See function next for the caveats of modifying the table during its
159154 * traversal.
160155 */
161- declare function pairs < T > ( t : T ) : LuaTupleIterable < [ keyof T , T [ keyof T ] ] > ;
156+ declare function pairs < T > ( t : T ) : LuaIterable < LuaMultiReturn < [ keyof T , T [ keyof T ] ] > > ;
162157
163158/**
164159 * Calls function f with the given arguments in protected mode. This means that
@@ -167,19 +162,17 @@ declare function pairs<T>(t: T): LuaTupleIterable<[keyof T, T[keyof T]]>;
167162 * is true if the call succeeds without errors. In such case, pcall also returns
168163 * all results from the call, after this first result. In case of any error,
169164 * pcall returns false plus the error message.
170- * @tupleReturn
171165 */
172166declare function pcall < This , Args extends any [ ] , R > (
173167 f : ( this : This , ...args : Args ) => R ,
174168 context : This ,
175169 ...args : Args
176- ) : [ true , R ] | [ false , string ] ;
170+ ) : LuaMultiReturn < [ true , R ] | [ false , string ] > ;
177171
178- /** @tupleReturn */
179172declare function pcall < A extends any [ ] , R > (
180173 f : ( this : void , ...args : A ) => R ,
181174 ...args : A
182- ) : [ true , R ] | [ false , string ] ;
175+ ) : LuaMultiReturn < [ true , R ] | [ false , string ] > ;
183176
184177/**
185178 * Receives any number of arguments and prints their values to stdout, using the
@@ -222,9 +215,8 @@ declare function rawset<T extends object, K extends keyof T>(table: T, index: K,
222215 * negative number indexes from the end (-1 is the last argument). Otherwise,
223216 * index must be the string "#", and select returns the total number of extra
224217 * arguments it received.
225- * @tupleReturn
226218 */
227- declare function select < T > ( index : number , ...args : T [ ] ) : T [ ] ;
219+ declare function select < T > ( index : number , ...args : T [ ] ) : LuaMultiReturn < T [ ] > ;
228220
229221/**
230222 * If index is a number, returns all arguments after argument number index; a
0 commit comments