@@ -93,6 +93,7 @@ function Spec:list(keys, t, ts)
9393 if vim .tbl_contains (types , type (value )) then
9494 return true
9595 elseif type (value ) == ' table' then
96+ --- @cast value any[]
9697 for i , item in ipairs (value ) do
9798 if type (item ) ~= t then
9899 return false , (' [%d] is %s' ):format (i , type (item ))
@@ -114,8 +115,10 @@ function Spec:nested_list(keys, t, ts)
114115 if type (value ) == t or vim .tbl_contains (types , type (value )) then
115116 return true
116117 elseif type (value ) == ' table' then
118+ --- @cast value any[]
117119 for i , item in ipairs (value ) do
118120 if type (item ) == ' table' then
121+ --- @cast item any[]
119122 for j , nested in ipairs (item ) do
120123 if type (nested ) ~= t then
121124 local info = (' [%d][%d] is %s' ):format (
@@ -150,6 +153,7 @@ function Spec:one_or_list_of(keys, values, ts)
150153 elseif type (value ) ~= ' table' then
151154 return vim .tbl_contains (values , value )
152155 else
156+ --- @cast value any[]
153157 for i , item in ipairs (value ) do
154158 if not vim .tbl_contains (values , item ) then
155159 return false , (' [%d] is %s' ):format (i , item )
165169--- @param ts ? type | type[]
166170--- @return type[] , string
167171function Spec :handle_types (custom , ts )
168- local types
172+ local types --- @type type[]
169173 if not ts then
170174 types = {}
171175 elseif type (ts ) == ' string' then
186190--- @param validation fun ( v : any ): boolean , string ?
187191function Spec :add (keys , kind , message , validation )
188192 if self .config then
189- keys = type (keys ) == ' table' and keys or { keys }
193+ keys = type (keys ) == ' table' and keys or { keys } --- @type string[]
190194 for _ , key in ipairs (keys ) do
191195 self .specs [key ] = {
192196 kind = kind ,
@@ -223,12 +227,12 @@ Validator.spec = Spec.new
223227--- @param specs table<string , render.md.debug.Spec>
224228function Validator :check (path , config , specs )
225229 for key , spec in pairs (specs ) do
226- local root = vim .list_extend ({}, path )
230+ local root = vim .list_extend ({}, path ) --- @type string[]
227231 root [# root + 1 ] = tostring (key )
228232 local value = config [key ]
229233 local ok , info = spec .validation (value )
230234 if not ok then
231- local actual
235+ local actual --- @type string
232236 if spec .kind == Kind .data then
233237 actual = vim .inspect (value )
234238 elseif spec .kind == Kind .type then
@@ -245,7 +249,7 @@ function Validator:check(path, config, specs)
245249 end
246250 end
247251 for key in pairs (config ) do
248- local root = vim .list_extend ({}, path )
252+ local root = vim .list_extend ({}, path ) --- @type string[]
249253 root [# root + 1 ] = tostring (key )
250254 if not specs [key ] then
251255 local message = (' %s - invalid key' ):format (table.concat (root , ' .' ))
0 commit comments