Skip to content

Commit c6570f8

Browse files
committed
feat: add type annotations for plenary.tbl
1 parent 8293bee commit c6570f8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lua/plenary/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
---@field functional PlenaryFunctional
55
---@field path PlenaryPath
66
---@field scandir PlenaryScandir
7+
---@field tbl PlenaryTbl
78
local plenary = setmetatable({}, {
89
__index = function(t, k)
910
local ok, val = pcall(require, string.format("plenary.%s", k))

lua/plenary/tbl.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
---@class PlenaryTbl
12
local tbl = {}
23

4+
---@generic T, U
5+
---@param original table<T, U>
6+
---@param defaults table<T, U>
7+
---@return table<T, U>
38
function tbl.apply_defaults(original, defaults)
49
if original == nil then
510
original = {}
@@ -16,10 +21,16 @@ function tbl.apply_defaults(original, defaults)
1621
return original
1722
end
1823

24+
---@param ... any
25+
---@return table
1926
function tbl.pack(...)
2027
return { n = select("#", ...), ... }
2128
end
2229

30+
---@param t table
31+
---@param i? integer
32+
---@param j? integer
33+
---@return ...
2334
function tbl.unpack(t, i, j)
2435
return unpack(t, i or 1, j or t.n or #t)
2536
end

0 commit comments

Comments
 (0)