fix(lsp): add parentheses to generated union array types (#27560)

This commit is contained in:
Maria José Solano
2024-02-21 03:31:56 -08:00
committed by GitHub
parent 09651342e7
commit ac0e8323dc
2 changed files with 8 additions and 4 deletions

View File

@@ -224,7 +224,11 @@ function M.gen(opt)
-- ArrayType
elseif type.kind == 'array' then
return parse_type(type.element, prefix) .. '[]'
local parsed_items = parse_type(type.element, prefix)
if type.element.items and #type.element.items > 1 then
parsed_items = '(' .. parsed_items .. ')'
end
return parsed_items .. '[]'
-- OrType
elseif type.kind == 'or' then