refactor(types): extract inline anonymous types into named classes (#110)

Problem: several functions used inline `{...}` table types in their
`@param` and `@return` annotations, making them hard to read and
impossible to reference from other modules.

Solution: extract each into a named `---@class`: `pending.Metadata`,
`pending.TaskFields`, `pending.CompletionItem`, `pending.SystemResult`,
and `pending.OAuthClientOpts`.
This commit is contained in:
Barrett Ruth 2026-03-08 19:49:49 -04:00 committed by GitHub
parent b06249f101
commit ac02526cf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 123 additions and 45 deletions

View file

@ -1,5 +1,12 @@
local config = require('pending.config')
---@class pending.Metadata
---@field due? string
---@field cat? string
---@field rec? string
---@field rec_mode? 'scheduled'|'completion'
---@field priority? integer
---@class pending.parse
local M = {}
@ -515,7 +522,7 @@ end
---@param text string
---@return string description
---@return { due?: string, cat?: string, rec?: string, rec_mode?: 'scheduled'|'completion' } metadata
---@return pending.Metadata metadata
function M.body(text)
local tokens = {}
for token in text:gmatch('%S+') do
@ -608,7 +615,7 @@ end
---@param text string
---@return string description
---@return { due?: string, cat?: string, rec?: string, rec_mode?: 'scheduled'|'completion' } metadata
---@return pending.Metadata metadata
function M.command_add(text)
local cat_prefix = text:match('^(%S.-):%s')
if cat_prefix then