fix: resolve remaining LuaLS type errors
Problem: CI lua-typecheck-action reported three categories of errors: 1. parse.lua - multi-assignment of tonumber() results left y/m/d typed as number? rather than integer, failing os.time()'s field types 2. gcal.lua - url_encode returned str:gsub() which yields string+integer but the annotation declared @return string (redundant-return-value) 3. gcal.lua - calendar_id typed string? from find_or_create_calendar was passed to functions expecting string; the existing `if err` guard did not narrow the type for LuaLS Solution: replace the y/m/d multi-assignment with yn/mn/dn locals whose types resolve cleanly to integer; wrap the gsub return in parentheses to discard the count; add `or not calendar_id` to the error guard so LuaLS narrows calendar_id to string for the rest of the scope.
This commit is contained in:
parent
0522cf3263
commit
ebd61ba870
2 changed files with 14 additions and 13 deletions
|
|
@ -99,9 +99,11 @@ end
|
|||
---@param str string
|
||||
---@return string
|
||||
local function url_encode(str)
|
||||
return str:gsub('([^%w%-%.%_%~])', function(c)
|
||||
return string.format('%%%02X', string.byte(c))
|
||||
end)
|
||||
return (
|
||||
str:gsub('([^%w%-%.%_%~])', function(c)
|
||||
return string.format('%%%02X', string.byte(c))
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
---@param method string
|
||||
|
|
@ -449,8 +451,8 @@ function M.sync()
|
|||
end
|
||||
|
||||
local calendar_id, err = find_or_create_calendar(access_token)
|
||||
if err then
|
||||
vim.notify('pending.nvim: ' .. err, vim.log.levels.ERROR)
|
||||
if err or not calendar_id then
|
||||
vim.notify('pending.nvim: ' .. (err or 'calendar not found'), vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue