Skip to content

Commit f46903f

Browse files
committed
apis
1 parent 9587a5a commit f46903f

File tree

4 files changed

+47
-26
lines changed

4 files changed

+47
-26
lines changed

res/std/debug.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ function debug.debug() end
3434
---@return thread
3535
function debug.gethook(thread) end
3636

37+
---@class DebugInfo
38+
---@field linedefined number
39+
---@field lastlinedefined number
40+
---@field currentline number
41+
---@field func function
42+
---@field isvararg boolean
43+
---@field namewhat string
44+
---@field source string
45+
---@field nups number
46+
---@field what string
47+
---@field nparams number
48+
---@field short_src string
49+
3750
---
3851
--- Returns a table with information about a function. You can give the
3952
--- function directly, or you can give a number as the value of `f`,
@@ -54,11 +67,11 @@ function debug.gethook(thread) end
5467
--- with a name for the current function, if a reasonable name can be found,
5568
--- and the expression `debug.getinfo(print)` returns a table with all available
5669
--- information about the `print` function.
57-
---@overload fun(f:table):table
70+
---@overload fun(f:function):DebugInfo
5871
---@param thread thread
59-
---@param f table
72+
---@param f function
6073
---@param what string
61-
---@return table
74+
---@return DebugInfo
6275
function debug.getinfo(thread, f, what) end
6376

6477
---

res/std/global.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function error(message, level) end
8686
--- itself does not use this variable; changing its value does not affect any
8787
--- environment, nor vice versa.
8888
---@class _G
89+
_G = {}
8990

9091
---
9192
--- If `object` does not have a metatable, returns **nil**. Otherwise, if the
@@ -139,7 +140,7 @@ function ipairs(t) end
139140
---@param chunk fun():string
140141
---@param chunkname string
141142
---@param mode string
142-
---@param env nay
143+
---@param env any
143144
function load(chunk, chunkname, mode, env) end
144145

145146
---
@@ -216,7 +217,7 @@ function print(...) end
216217
--- a boolean.
217218
---@param v1 any
218219
---@param v2 any
219-
---@returns boolean
220+
---@return boolean
220221
function rawequal(v1, v2) end
221222

222223
---
@@ -281,8 +282,10 @@ function require(modname) end
281282
--- `index`. a negative number indexes from the end (-1 is the last argument).
282283
--- Otherwise, `index` must be the string "#", and `select` returns
283284
--- the total number of extra arguments it received.
285+
---@generic T
284286
---@param index number|string
285-
---@return any
287+
---@vararg T
288+
---@return T
286289
function select(index, ...) end
287290

288291
---
@@ -292,9 +295,10 @@ function select(index, ...) end
292295
--- metatable has a `"__metatable"` field, raises an error.
293296
---
294297
--- This function returns `table`.
295-
---@param table table
298+
---@generic T
299+
---@param table T
296300
---@param metatable table
297-
---@return table
301+
---@return T
298302
function setmetatable(table, metatable) end
299303

300304
---

res/std/io.lua

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ io = {}
1717
---
1818
--- Equivalent to `file:close()`. Without a file, closes the default output
1919
--- file.
20-
---@overload fun()
20+
---@overload fun():void
2121
---@param file file
2222
function io.close(file) end
2323

@@ -33,9 +33,9 @@ function io.flush() end
3333
---
3434
--- In case of errors this function raises the error, instead of returning an
3535
--- error code.
36-
---@overload fun():number
37-
---@param file file
38-
---@return number
36+
---@overload fun():file
37+
---@param file file | string
38+
---@return file
3939
function io.input(file) end
4040

4141
---
@@ -73,14 +73,15 @@ function io.lines(filename, ...) end
7373
--- some systems to open the file in binary mode.
7474
---@overload fun(filename:string):file
7575
---@param filename string
76-
---@param mode string
76+
---@param mode string | '"r"' | '"w"' | '"a"' | '"r+"' | '"w+"' | '"a+"' | '"rb"' | '"wb"' | '"ab"' | '"rb+"' | '"wb+"' | '"ab+"'
7777
---@return file
7878
function io.open(filename, mode) return file end
7979

8080
---
8181
--- Similar to `io.input`, but operates over the default output file.
82-
---@overload fun()
83-
---@param file file
82+
---@overload fun():file
83+
---@param file file | string
84+
---@return file
8485
function io.output(file) end
8586

8687
---
@@ -89,10 +90,10 @@ function io.output(file) end
8990
--- Starts program `prog` in a separated process and returns a file handle that
9091
--- you can use to read data from this program (if `mode` is "`r`", the default)
9192
--- or to write data to this program (if `mode` is "`w`").
92-
---@overload fun(prog:file):any
93-
---@param prog file
94-
---@param mode string
95-
---@return any
93+
---@overload fun(prog:string):file
94+
---@param prog string
95+
---@param mode string | '"r"' | '"w"'
96+
---@return file
9697
function io.popen(prog, mode) end
9798

9899
---
@@ -191,7 +192,7 @@ function file:read(...) end
191192
--- file (and returns 0); and the call `file:seek("end")` sets the position
192193
--- to the end of the file, and returns its size.
193194
---@overload fun()
194-
---@param whence string
195+
---@param whence string | '"set"' | '"cur"' | '"end"'
195196
---@param offset number
196197
function file:seek(whence, offset) end
197198

@@ -208,7 +209,7 @@ function file:seek(whence, offset) end
208209
--- For the last two cases, `size` specifies the size of the buffer, in
209210
--- bytes. The default is an appropriate size.
210211
---@overload fun(mode:string)
211-
---@param mode string
212+
---@param mode string | '"no"' | '"full"' | '"line"'
212213
---@param size number
213214
function file:setvbuf(mode, size) end
214215

res/std/table.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ table = {}
2020
--- `sep` is the empty string, the default for `i` is 1, and the default for
2121
--- `j` is #list. If `i` is greater than `j`, returns the empty string.
2222
---@overload fun(list:table):string
23+
---@overload fun(list:table, sep:string):string
24+
---@overload fun(list:table, sep:string, i:number):string
2325
---@param list table
2426
---@param sep string
2527
---@param i number
@@ -72,10 +74,11 @@ function table.pack(...) end
7274
---
7375
--- The default value for `pos` is `#list`, so that a call `table.remove(l)`
7476
--- removes the last element of list `l`.
75-
---@overload fun(list:table):any
76-
---@param list table
77+
---@overload fun<V>(list:table<number, V> | V[]):V
78+
---@generic V
79+
---@param list table<number, V>
7780
---@param pos number
78-
---@return any
81+
---@return V
7982
function table.remove(list, pos) end
8083

8184
---
@@ -92,9 +95,9 @@ function table.remove(list, pos) end
9295
---
9396
--- The sort algorithm is not stable: elements considered equal by the given
9497
--- order may have their relative positions changed by the sort.
95-
---@generic V
9698
---@overload fun(list:table):number
97-
---@param list table<number, V>
99+
---@generic V
100+
---@param list table<number, V> | V[]
98101
---@param comp fun(a:V, b:V):number
99102
---@return number
100103
function table.sort(list, comp) end

0 commit comments

Comments
 (0)