fix(parse): cast os.date('*t') return to osdate (#3)

Problem: LuaLS types os.date('*t') as string|osdate, causing type
errors when accessing .year, .month, .day, .wday fields in
is_valid_date and resolve_date.

Solution: add --[[@as osdate]] casts on both os.date('*t') calls.
This commit is contained in:
Barrett Ruth 2026-02-24 18:40:46 -05:00 committed by GitHub
parent f21658f138
commit 68dbea7d52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,7 +21,7 @@ local function is_valid_date(s)
return false
end
local t = os.time({ year = y, month = m, day = d })
local check = os.date('*t', t)
local check = os.date('*t', t) --[[@as osdate]]
return check.year == y and check.month == m and check.day == d
end
@ -44,7 +44,7 @@ local weekday_map = {
---@return string|nil
function M.resolve_date(text)
local lower = text:lower()
local today = os.date('*t')
local today = os.date('*t') --[[@as osdate]]
if lower == 'today' then
return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month, day = today.day })) --[[@as string]]