fix: add type annotations for lx check

Amolith created

Assisted-by: Claude Opus 4.5 via Amp

Change summary

dist/wt      | 5 ++++-
src/main.lua | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)

Detailed changes

dist/wt 🔗

@@ -1273,10 +1273,11 @@ end
 ---@return table[] array of {path: string, branch?: string, bare?: boolean, detached?: boolean}
 local function parse_worktree_list(output)
 	local worktrees = {}
+	---@type {path: string, branch?: string, bare?: boolean, detached?: boolean, head?: string}|nil
 	local current = nil
 	for line in output:gmatch("[^\n]+") do
 		local key, value = line:match("^(%S+)%s*(.*)$")
-		if key == "worktree" then
+		if key == "worktree" and value then
 			if current then
 				table.insert(worktrees, current)
 			end
@@ -1769,6 +1770,8 @@ local function main()
 		os.exit(EXIT_SUCCESS)
 	end
 
+	---@cast command string
+
 	-- Collect remaining args
 	local subargs = {}
 	for i = 2, #arg do

src/main.lua 🔗

@@ -1269,10 +1269,11 @@ end
 ---@return table[] array of {path: string, branch?: string, bare?: boolean, detached?: boolean}
 local function parse_worktree_list(output)
 	local worktrees = {}
+	---@type {path: string, branch?: string, bare?: boolean, detached?: boolean, head?: string}|nil
 	local current = nil
 	for line in output:gmatch("[^\n]+") do
 		local key, value = line:match("^(%S+)%s*(.*)$")
-		if key == "worktree" then
+		if key == "worktree" and value then
 			if current then
 				table.insert(worktrees, current)
 			end
@@ -1765,6 +1766,8 @@ local function main()
 		os.exit(EXIT_SUCCESS)
 	end
 
+	---@cast command string
+
 	-- Collect remaining args
 	local subargs = {}
 	for i = 2, #arg do